McWizzardDev
Kuhfänger
Guten Abend,
ich sitze gerade an meinem JumpDown Plugin und möchte für die LuckyBlocks alle Blöcke in der Luft bekommen, dies habe ich bisher so gemacht:
Problem: Dies braucht ca. 30 Sekunden, aber das soll max. 1-2 Sekunden dauern, habt ihr eine Idee, wie ich die Blöcke besser herausbekomme. Es würde auch gehen, wenn man das einmal machen muss und dann sich alles in einer config speichert, aber dort weiß ich nicht, wie ich die Blöcke wieder auslese
ich sitze gerade an meinem JumpDown Plugin und möchte für die LuckyBlocks alle Blöcke in der Luft bekommen, dies habe ich bisher so gemacht:
Code:
for(Chunk chunk : world.getLoadedChunks()) {
for(int x = 0; x < 16; x++) {
for(int y = 0; y < 256; y++) {
for(int z = 0; z < 16; z++) {
Block b = chunk.getBlock(x, y, z);
if(b.getRelative(BlockFace.DOWN).getType().equals(Material.AIR) && b.getRelative(BlockFace.UP).getType().equals(Material.AIR) &&
b.getRelative(BlockFace.SOUTH).getType().equals(Material.AIR) && b.getRelative(BlockFace.NORTH).getType().equals(Material.AIR)
&& b.getRelative(BlockFace.WEST).getType().equals(Material.AIR) && b.getRelative(BlockFace.EAST).getType().equals(Material.AIR)) {
if(!(b.getType().equals(Material.AIR))) {
Location loc1 = Locations.getLocation("spawn.1");
Location loc2 = Locations.getLocation("spawn.2");
Location loc3 = Locations.getLocation("spawn.3");
if(!(b.getLocation().getY() == loc1.getY() || b.getLocation().getY() == loc2.getY() || b.getLocation().getY() == loc3.getY())) {
if(loc1.distance(b.getLocation()) < 5000) {
luckyblocks.add(b);
}
}
}
}
}
}
}
}
Problem: Dies braucht ca. 30 Sekunden, aber das soll max. 1-2 Sekunden dauern, habt ihr eine Idee, wie ich die Blöcke besser herausbekomme. Es würde auch gehen, wenn man das einmal machen muss und dann sich alles in einer config speichert, aber dort weiß ich nicht, wie ich die Blöcke wieder auslese