@Override public boolean isSolid() { return material.isSolid(); }
@Override public void onNearBlockChanged(GlowBlock block, BlockFace face, GlowBlock changedBlock, Material oldType, byte oldData, Material newType, byte newData) { if (face == BlockFace.UP && newType.isSolid()) { block.setType(Material.DIRT); } } }
private boolean hasNearSolidBlock(GlowBlock block) { // check there's at least a solid block around for (BlockFace face : SIDES) { if (block.getRelative(face).getType().isSolid()) { return true; } } return false; } }
@Override public boolean canPlaceAt(GlowPlayer player, GlowBlock block, BlockFace against) { switch (against) { case NORTH: case SOUTH: case EAST: case WEST: return block.getRelative(against.getOppositeFace()).getType().isSolid(); case UP: return block.getRelative(against).getType().isSolid(); default: return false; } }
private boolean isValidMovement(Entity vehicle, Location oldLocation, Location newLocation) { if (!(vehicle instanceof Boat)) { return true; } boolean workOnLand = ((Boat) vehicle).getWorkOnLand(); if (workOnLand) { return true; } Material type = oldLocation.getBlock().getType(); if (type != Material.WATER && type != Material.STATIONARY_WATER) { return true; } return !newLocation.getBlock().getType().isSolid(); } }
@Override protected void pulsePhysics() { if (location.getBlock().getType().isSolid()) { setRawLocation(location.clone().add(0, 0.2, 0), false); } super.pulsePhysics(); }
@Override public boolean canPlaceAt(GlowPlayer player, GlowBlock block, BlockFace against) { if (player != null) { BlockFace direction = getOppositeBlockFace(player.getLocation(), false) .getOppositeFace(); final GlowBlock otherEnd = block.getRelative(direction); return otherEnd.getType() == Material.AIR && otherEnd.getRelative(BlockFace.DOWN).getType().isSolid(); } else { return false; } }
/** * Builds a 1x1 column out of the given block, replacing non-solid blocks starting at a given * location and proceeding downward until a solid block is reached. * * @param pos the highest point to possibly replace, relative to this structure's root * point * @param type the block type to fill * @param data the block data */ public void setBlockDownward(Vector pos, Material type, MaterialData data) { Vector vec = translate(pos); if (boundingBox.isVectorInside(vec)) { int x = vec.getBlockX(); int y = vec.getBlockY(); int z = vec.getBlockZ(); while (!world.getBlockAt(x, y, z).getType().isSolid() && y > 1) { delegate.setTypeAndData(world, x, y, z, type, data); y--; } } }
/** * Generates or extends a cactus, if there is space. */ @Override public boolean generate(World world, Random random, int x, int y, int z) { if (world.getBlockAt(x, y, z).isEmpty()) { int height = random.nextInt(random.nextInt(3) + 1) + 1; for (int n = y; n < y + height; n++) { Block block = world.getBlockAt(x, n, z); Material typeBelow = block.getRelative(BlockFace.DOWN).getType(); if ((typeBelow == Material.SAND || typeBelow == Material.CACTUS) && block.getRelative(BlockFace.UP).isEmpty()) { for (BlockFace face : FACES) { if (block.getRelative(face).getType().isSolid()) { return n > y; } } BlockState state = block.getState(); state.setType(Material.CACTUS); state.setData(new MaterialData(Material.CACTUS)); state.update(true); } } } return true; } }
if ((Math.abs(x - l.getBlockX()) != radius || Math.abs(z - l.getBlockZ()) != radius || random.nextBoolean()) && !delegate.getBlockState(world, x, y, z).getType().isSolid()) { delegate .setTypeAndRawData(world, x, y, z, Material.LEAVES, leavesType);
/** * Builds a 1x1 column out of the given block, replacing non-solid blocks starting at a given * location and proceeding downward until a solid block is reached. * * @param pos the highest point to possibly replace, relative to this structure's root * point * @param type the block type to fill * @param data the block data */ public void setBlockDownward(Vector pos, Material type, int data) { Vector vec = translate(pos); if (boundingBox.isVectorInside(vec)) { int y = vec.getBlockY(); while (!world.getBlockAt(vec.getBlockX(), y, vec.getBlockZ()).getType().isSolid() && y > 1) { delegate.setTypeAndRawData(world, vec.getBlockX(), y, vec.getBlockZ(), type, data); y--; } } }
@Override public boolean canPlaceAt(GlowPlayer player, GlowBlock block, BlockFace against) { if (block.getRelative(BlockFace.DOWN).getType().isSolid()) { return true; } GlowBlock target = block.getRelative(BlockFace.DOWN); switch (target.getType()) { case WOOD_STAIRS: case COBBLESTONE_STAIRS: case BRICK_STAIRS: case SMOOTH_STAIRS: case NETHER_BRICK_STAIRS: case SANDSTONE_STAIRS: case SPRUCE_WOOD_STAIRS: case BIRCH_WOOD_STAIRS: case JUNGLE_WOOD_STAIRS: case QUARTZ_STAIRS: case ACACIA_STAIRS: case DARK_OAK_STAIRS: return ((Stairs) target.getState().getData()).isInverted(); case STEP: case WOOD_STEP: return ((Step) target.getState().getData()).isInverted(); case GLOWSTONE: return true; default: return false; } }
private void extraUpdate(GlowBlock block) { ItemTable itemTable = ItemTable.instance(); GlowBlock target = block.getRelative(BlockFace.UP); if (target.getType().isSolid()) { for (BlockFace face2 : ADJACENT) { GlowBlock target2 = target.getRelative(face2); BlockType notifyType = itemTable.getBlock(target2.getType()); if (notifyType != null) { if (target2.getFace(block) == null) { notifyType .onNearBlockChanged(target2, BlockFace.SELF, block, block.getType(), block.getData(), block.getType(), block.getData()); } notifyType.onRedstoneUpdate(target2); } } } }
private static void updateConnected(GlowBlock block) { ItemTable itemTable = ItemTable.instance(); for (BlockFace face : calculateConnections(block)) { GlowBlock target = block.getRelative(face); if (target.getType().isSolid()) { for (BlockFace face2 : ADJACENT) { GlowBlock target2 = target.getRelative(face2); BlockType notifyType = itemTable.getBlock(target2.getType()); if (notifyType != null) { if (target2.getFace(block) == null) { notifyType .onNearBlockChanged(target2, BlockFace.SELF, block, block.getType(), block.getData(), block.getType(), block.getData()); } notifyType.onRedstoneUpdate(target2); } } } } }
private boolean canPlace(byte[] lakeMap, World world, int sourceX, int sourceY, int sourceZ) { for (int x = 0; x < MAX_DIAMETER; x++) { for (int z = 0; z < MAX_DIAMETER; z++) { for (int y = 0; y < MAX_HEIGHT; y++) { if (isLakeBlock(lakeMap, x, y, z) || (((x >= (MAX_DIAMETER - 1)) || !isLakeBlock(lakeMap, x + 1, y, z)) && ((x <= 0) || !isLakeBlock(lakeMap, x - 1, y, z)) && ((z >= (MAX_DIAMETER - 1)) || !isLakeBlock(lakeMap, x, y, z + 1)) && ((z <= 0) || !isLakeBlock(lakeMap, x, y, z - 1)) && ((z >= (MAX_HEIGHT - 1)) || !isLakeBlock(lakeMap, x, y + 1, z)) && ((z <= 0) || !isLakeBlock(lakeMap, x, y - 1, z)))) { continue; } Block block = world.getBlockAt(sourceX + x, sourceY + y, sourceZ + z); if (y >= MAX_HEIGHT / 2 && (block.isLiquid() || block.getType() == Material.ICE)) { return false; // there's already some liquids above } else if (y < MAX_HEIGHT / 2 && !block.getType().isSolid() && block.getType() != type) { return false; // bottom must be solid and do not overlap with another liquid type } } } } return true; }
private void extraUpdate(GlowBlock block) { Button button = (Button) block.getState().getData(); ItemTable itemTable = ItemTable.instance(); GlowBlock target = block.getRelative(button.getAttachedFace()); if (target.getType().isSolid()) { for (BlockFace face2 : ADJACENT) { GlowBlock target2 = target.getRelative(face2); BlockType notifyType = itemTable.getBlock(target2.getType()); if (notifyType != null) { if (target2.getFace(block) == null) { notifyType .onNearBlockChanged(target2, BlockFace.SELF, block, block.getType(), block.getData(), block.getType(), block.getData()); } notifyType.onRedstoneUpdate(target2); } } } }
private void extraUpdate(GlowBlock block) { Diode diode = (Diode) block.getState().getData(); ItemTable itemTable = ItemTable.instance(); GlowBlock target = block.getRelative(diode.getFacing()); if (target.getType().isSolid()) { for (BlockFace face2 : ADJACENT) { GlowBlock target2 = target.getRelative(face2); BlockType notifyType = itemTable.getBlock(target2.getType()); if (notifyType != null) { if (target2.getFace(block) == null) { notifyType .onNearBlockChanged(target2, BlockFace.SELF, block, block.getType(), block.getData(), block.getType(), block.getData()); } notifyType.onRedstoneUpdate(target2); } } } }
private void extraUpdate(GlowBlock block) { Lever lever = (Lever) block.getState().getData(); ItemTable itemTable = ItemTable.instance(); GlowBlock target = block.getRelative(lever.getAttachedFace()); if (target.getType().isSolid()) { for (BlockFace face2 : ADJACENT) { GlowBlock target2 = target.getRelative(face2); BlockType notifyType = itemTable.getBlock(target2.getType()); if (notifyType != null) { if (target2.getFace(block) == null) { notifyType .onNearBlockChanged(target2, BlockFace.SELF, block, block.getType(), block.getData(), block.getType(), block.getData()); } notifyType.onRedstoneUpdate(target2); } } } } }