@Override public void findFreePosition() { findFreePosition(getBlockIn()); }
@Override public boolean ascendUpwards(int distance, boolean alwaysGlass) { final Location pos = getBlockIn(); final int x = pos.getBlockX(); final int initialY = Math.max(0, pos.getBlockY()); int y = Math.max(0, pos.getBlockY() + 1); final int z = pos.getBlockZ(); final int maxY = Math.min(getWorld().getMaxY() + 1, initialY + distance); final Extent world = getLocation().getExtent(); while (y <= world.getMaximumPoint().getY() + 2) { if (world.getBlock(BlockVector3.at(x, y, z)).getBlockType().getMaterial().isMovementBlocker()) { break; // Hit something } else if (y > maxY + 1) { break; } else if (y == maxY + 1) { floatAt(x, y - 1, z, alwaysGlass); return true; } ++y; } return false; }
@Override public boolean ascendToCeiling(int clearance, boolean alwaysGlass) { Location pos = getBlockIn(); int x = pos.getBlockX(); int initialY = Math.max(0, pos.getBlockY()); int y = Math.max(0, pos.getBlockY() + 2); int z = pos.getBlockZ(); Extent world = getLocation().getExtent(); // No free space above if (!world.getBlock(BlockVector3.at(x, y, z)).getBlockType().getMaterial().isAir()) { return false; } while (y <= world.getMaximumPoint().getY()) { // Found a ceiling! if (world.getBlock(BlockVector3.at(x, y, z)).getBlockType().getMaterial().isMovementBlocker()) { int platformY = Math.max(initialY, y - 3 - clearance); floatAt(x, platformY + 1, z, alwaysGlass); return true; } ++y; } return false; }
@Override public boolean ascendLevel() { final Location pos = getBlockIn(); final int x = pos.getBlockX(); int y = Math.max(0, pos.getBlockY());
@Override public boolean descendLevel() { final Location pos = getBlockIn(); final int x = pos.getBlockX(); int y = Math.max(0, pos.getBlockY() - 1);