From 7276bcccab5b3c82a7cc69309d1e2590a0cf50c0 Mon Sep 17 00:00:00 2001 From: KHobbits Date: Sat, 8 Jun 2013 21:26:11 +0100 Subject: [PATCH] Trapdoors should be treated as half blocks, not transparent blocks. --- .../src/com/earth2me/essentials/Util.java | 91 +++++++++---------- 1 file changed, 45 insertions(+), 46 deletions(-) diff --git a/Essentials/src/com/earth2me/essentials/Util.java b/Essentials/src/com/earth2me/essentials/Util.java index a1f364ab8..58ffa5d44 100644 --- a/Essentials/src/com/earth2me/essentials/Util.java +++ b/Essentials/src/com/earth2me/essentials/Util.java @@ -234,59 +234,58 @@ public class Util return c.getTimeInMillis(); } // The player can stand inside these materials - private static final Set AIR_MATERIALS = new HashSet(); - private static final HashSet AIR_MATERIALS_TARGET = new HashSet(); + private static final Set UNSAFE_MATERIALS = new HashSet(); + private static final HashSet TRANSPARENT_MATERIALS = new HashSet(); static { - AIR_MATERIALS.add(Material.AIR.getId()); - AIR_MATERIALS.add(Material.SAPLING.getId()); - AIR_MATERIALS.add(Material.POWERED_RAIL.getId()); - AIR_MATERIALS.add(Material.DETECTOR_RAIL.getId()); - AIR_MATERIALS.add(Material.LONG_GRASS.getId()); - AIR_MATERIALS.add(Material.DEAD_BUSH.getId()); - AIR_MATERIALS.add(Material.YELLOW_FLOWER.getId()); - AIR_MATERIALS.add(Material.RED_ROSE.getId()); - AIR_MATERIALS.add(Material.BROWN_MUSHROOM.getId()); - AIR_MATERIALS.add(Material.RED_MUSHROOM.getId()); - AIR_MATERIALS.add(Material.TORCH.getId()); - AIR_MATERIALS.add(Material.REDSTONE_WIRE.getId()); - AIR_MATERIALS.add(Material.SEEDS.getId()); - AIR_MATERIALS.add(Material.SIGN_POST.getId()); - AIR_MATERIALS.add(Material.WOODEN_DOOR.getId()); - AIR_MATERIALS.add(Material.LADDER.getId()); - AIR_MATERIALS.add(Material.RAILS.getId()); - AIR_MATERIALS.add(Material.WALL_SIGN.getId()); - AIR_MATERIALS.add(Material.LEVER.getId()); - AIR_MATERIALS.add(Material.STONE_PLATE.getId()); - AIR_MATERIALS.add(Material.IRON_DOOR_BLOCK.getId()); - AIR_MATERIALS.add(Material.WOOD_PLATE.getId()); - AIR_MATERIALS.add(Material.REDSTONE_TORCH_OFF.getId()); - AIR_MATERIALS.add(Material.REDSTONE_TORCH_ON.getId()); - AIR_MATERIALS.add(Material.STONE_BUTTON.getId()); - AIR_MATERIALS.add(Material.SNOW.getId()); - AIR_MATERIALS.add(Material.SUGAR_CANE_BLOCK.getId()); - AIR_MATERIALS.add(Material.DIODE_BLOCK_OFF.getId()); - AIR_MATERIALS.add(Material.DIODE_BLOCK_ON.getId()); - AIR_MATERIALS.add(Material.TRAP_DOOR.getId()); - AIR_MATERIALS.add(Material.PUMPKIN_STEM.getId()); - AIR_MATERIALS.add(Material.MELON_STEM.getId()); - AIR_MATERIALS.add(Material.VINE.getId()); - AIR_MATERIALS.add(Material.FENCE_GATE.getId()); - AIR_MATERIALS.add(Material.WATER_LILY.getId()); - AIR_MATERIALS.add(Material.NETHER_WARTS.getId()); + UNSAFE_MATERIALS.add(Material.AIR.getId()); + UNSAFE_MATERIALS.add(Material.SAPLING.getId()); + UNSAFE_MATERIALS.add(Material.POWERED_RAIL.getId()); + UNSAFE_MATERIALS.add(Material.DETECTOR_RAIL.getId()); + UNSAFE_MATERIALS.add(Material.LONG_GRASS.getId()); + UNSAFE_MATERIALS.add(Material.DEAD_BUSH.getId()); + UNSAFE_MATERIALS.add(Material.YELLOW_FLOWER.getId()); + UNSAFE_MATERIALS.add(Material.RED_ROSE.getId()); + UNSAFE_MATERIALS.add(Material.BROWN_MUSHROOM.getId()); + UNSAFE_MATERIALS.add(Material.RED_MUSHROOM.getId()); + UNSAFE_MATERIALS.add(Material.TORCH.getId()); + UNSAFE_MATERIALS.add(Material.REDSTONE_WIRE.getId()); + UNSAFE_MATERIALS.add(Material.SEEDS.getId()); + UNSAFE_MATERIALS.add(Material.SIGN_POST.getId()); + UNSAFE_MATERIALS.add(Material.WOODEN_DOOR.getId()); + UNSAFE_MATERIALS.add(Material.LADDER.getId()); + UNSAFE_MATERIALS.add(Material.RAILS.getId()); + UNSAFE_MATERIALS.add(Material.WALL_SIGN.getId()); + UNSAFE_MATERIALS.add(Material.LEVER.getId()); + UNSAFE_MATERIALS.add(Material.STONE_PLATE.getId()); + UNSAFE_MATERIALS.add(Material.IRON_DOOR_BLOCK.getId()); + UNSAFE_MATERIALS.add(Material.WOOD_PLATE.getId()); + UNSAFE_MATERIALS.add(Material.REDSTONE_TORCH_OFF.getId()); + UNSAFE_MATERIALS.add(Material.REDSTONE_TORCH_ON.getId()); + UNSAFE_MATERIALS.add(Material.STONE_BUTTON.getId()); + UNSAFE_MATERIALS.add(Material.SNOW.getId()); + UNSAFE_MATERIALS.add(Material.SUGAR_CANE_BLOCK.getId()); + UNSAFE_MATERIALS.add(Material.DIODE_BLOCK_OFF.getId()); + UNSAFE_MATERIALS.add(Material.DIODE_BLOCK_ON.getId()); + UNSAFE_MATERIALS.add(Material.PUMPKIN_STEM.getId()); + UNSAFE_MATERIALS.add(Material.MELON_STEM.getId()); + UNSAFE_MATERIALS.add(Material.VINE.getId()); + UNSAFE_MATERIALS.add(Material.FENCE_GATE.getId()); + UNSAFE_MATERIALS.add(Material.WATER_LILY.getId()); + UNSAFE_MATERIALS.add(Material.NETHER_WARTS.getId()); - for (Integer integer : AIR_MATERIALS) + for (Integer integer : UNSAFE_MATERIALS) { - AIR_MATERIALS_TARGET.add(integer.byteValue()); + TRANSPARENT_MATERIALS.add(integer.byteValue()); } - AIR_MATERIALS_TARGET.add((byte)Material.WATER.getId()); - AIR_MATERIALS_TARGET.add((byte)Material.STATIONARY_WATER.getId()); + TRANSPARENT_MATERIALS.add((byte)Material.WATER.getId()); + TRANSPARENT_MATERIALS.add((byte)Material.STATIONARY_WATER.getId()); } public static Location getTarget(final LivingEntity entity) throws Exception { - final Block block = entity.getTargetBlock(AIR_MATERIALS_TARGET, 300); + final Block block = entity.getTargetBlock(TRANSPARENT_MATERIALS, 300); if (block == null) { throw new Exception("Not targeting a block"); @@ -408,7 +407,7 @@ public class Util private static boolean isBlockAboveAir(final World world, final int x, final int y, final int z) { - return AIR_MATERIALS.contains(world.getBlockAt(x, y - 1, z).getType().getId()); + return UNSAFE_MATERIALS.contains(world.getBlockAt(x, y - 1, z).getType().getId()); } public static boolean isBlockUnsafe(final World world, final int x, final int y, final int z) @@ -438,8 +437,8 @@ public class Util return true; } - if ((!AIR_MATERIALS.contains(world.getBlockAt(x, y, z).getType().getId())) - || (!AIR_MATERIALS.contains(world.getBlockAt(x, y + 1, z).getType().getId()))) + if ((!UNSAFE_MATERIALS.contains(world.getBlockAt(x, y, z).getType().getId())) + || (!UNSAFE_MATERIALS.contains(world.getBlockAt(x, y + 1, z).getType().getId()))) { return true; }