small performance optimization for the block breaking robots

This commit is contained in:
Hea3veN 2015-01-21 22:35:44 -03:00
parent 39410dc5af
commit f2e3166a51

View file

@ -101,16 +101,19 @@ public class PathFinding {
private boolean searchForTarget(int range) { private boolean searchForTarget(int range) {
for (int dx = -range; dx <= range; dx++) { for (int dx = -range; dx <= range; dx++) {
for (int dy = -range; dy <= range; dy++) { for (int dz = -range; dz <= range; dz++) {
for (int dz = -range; dz <= range; dz++) { int x = start.x + dx;
int x = start.x + dx; int z = start.z + dz;
int y = Math.max(0, start.y + dy); if (world.getChunkProvider().chunkExists (x >> 4, z >> 4)) {
int z = start.z + dz; int height = world.getChunkFromChunkCoords(x >> 4, z >> 4).getHeightValue(x & 0xF, z & 0xF);
if (zone != null && !zone.contains(x, y, z)) { for (int dy = -range; dy <= height; dy++) {
continue; int y = Math.max(0, start.y + dy);
} if (zone != null && !zone.contains(x, y, z)) {
if (pathFound.matches(world, x, y, z)) { continue;
return false; }
if (pathFound.matches(world, x, y, z)) {
return false;
}
} }
} }
} }