@Override public boolean ascendToCeiling(int clearance) { return ascendToCeiling(clearance, true); }
@Override public boolean ascendUpwards(int distance) { return ascendUpwards(distance, true); }
@Override public void findFreePosition() { findFreePosition(getBlockIn()); }
@Override public void setPosition(Vector3 pos) { setPosition(pos, getLocation().getPitch(), getLocation().getYaw()); }
@Override public Direction getCardinalDirection(int yawOffset) { if (getLocation().getPitch() > 67.5) { return Direction.DOWN; } if (getLocation().getPitch() < -67.5) { return Direction.UP; } // From hey0's code double rot = (getLocation().getYaw() + yawOffset) % 360; //let's use real yaw now if (rot < 0) { rot += 360.0; } return getDirection(rot); }
@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()); setPosition(platform.toVector3().add(0.5, 1, 0.5)); return true;
@Override public void floatAt(int x, int y, int z, boolean alwaysGlass) { if (alwaysGlass || !player.getAllowFlight()) { super.floatAt(x, y, z, alwaysGlass); return; } setPosition(Vector3.at(x + 0.5, y, z + 0.5)); player.setFlying(true); }
int searchDist = 0; TargetBlock hitBlox = new TargetBlock(this, range, 0.2); Extent world = getLocation().getExtent(); Location block; boolean firstBlock = true; setOnGround(block); return true;
@Override public boolean isHoldingPickAxe() { ItemType item = getItemInHand(HandSide.MAIN_HAND).getType(); return item == ItemTypes.IRON_PICKAXE || item == ItemTypes.WOODEN_PICKAXE || item == ItemTypes.STONE_PICKAXE || item == ItemTypes.DIAMOND_PICKAXE || item == ItemTypes.GOLDEN_PICKAXE; }
@Override public Location getBlockIn() { return getLocation().setPosition(getLocation().toVector().floor()); }
@Override public Direction getCardinalDirection() { return getCardinalDirection(0); }
@Override public Location getBlockTrace(int range) { return getBlockTrace(range, false); }
@Override public void floatAt(int x, int y, int z, boolean alwaysGlass) { try { BlockVector3 spot = BlockVector3.at(x, y - 1, z); if (!getLocation().getExtent().getBlock(spot).getBlockType().getMaterial().isMovementBlocker()) { getLocation().getExtent().setBlock(spot, BlockTypes.GLASS.getDefaultState()); } } catch (WorldEditException e) { e.printStackTrace(); } setPosition(Vector3.at(x + 0.5, y, z + 0.5)); }
@Override public boolean descendLevel() { final Location pos = getBlockIn(); final int x = pos.getBlockX(); int y = Math.max(0, pos.getBlockY() - 1); setPosition(platform.toVector3().add(0.5, 1, 0.5)); return true;
@Override public BaseBlock getBlockInHand(HandSide handSide) throws WorldEditException { final ItemType typeId = getItemInHand(handSide).getType(); if (typeId.hasBlockType()) { return typeId.getBlockType().getDefaultState().toBaseBlock(); } else { throw new NotABlockException(); } }
@Override public Location getBlockOn() { return getLocation().setPosition(getLocation().setY(getLocation().getY() - 1).toVector().floor()); }