capped tree detection search depth
This commit is contained in:
parent
cf2671380b
commit
4c269e6938
1 changed files with 6 additions and 1 deletions
|
@ -12,11 +12,14 @@ import net.minecraft.util.math.Vec3d;
|
|||
import net.minecraft.world.World;
|
||||
|
||||
public class Util {
|
||||
public static final int MAX_SEARCH_DEPTH = 100;
|
||||
|
||||
public static boolean isTreeNaturallyGrown(World world, BlockPos pos) {
|
||||
LinkedList<BlockPos> queue = new LinkedList<BlockPos>();
|
||||
queue.push(pos.up());
|
||||
int search_depth = 0;
|
||||
|
||||
while (!queue.isEmpty()) {
|
||||
while (!queue.isEmpty() && search_depth >= MAX_SEARCH_DEPTH) {
|
||||
BlockPos nextPos = queue.pop();
|
||||
|
||||
BlockPos[] dirs = { nextPos.north(), nextPos.east(), nextPos.south(), nextPos.west(), nextPos.up() };
|
||||
|
@ -30,6 +33,8 @@ public class Util {
|
|||
queue.push(dir);
|
||||
}
|
||||
}
|
||||
|
||||
search_depth++;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
|
Loading…
Reference in a new issue