From b31d77536a042f1ff0ea11877d1337522f1e627b Mon Sep 17 00:00:00 2001 From: TomyLobo Date: Mon, 24 Oct 2011 20:46:17 +0200 Subject: [PATCH] Added some new functions to BlockType. - emitsLight which returns whether the given block type emits light - isTranslucent, which returns whether the block lets any light pass --- .../com/sk89q/worldedit/blocks/BlockType.java | 107 ++++++++++++++++++ 1 file changed, 107 insertions(+) diff --git a/src/main/java/com/sk89q/worldedit/blocks/BlockType.java b/src/main/java/com/sk89q/worldedit/blocks/BlockType.java index ad917b237..2e1f8c60f 100644 --- a/src/main/java/com/sk89q/worldedit/blocks/BlockType.java +++ b/src/main/java/com/sk89q/worldedit/blocks/BlockType.java @@ -623,6 +623,113 @@ public enum BlockType { return isNaturalTerrainBlock.contains(id); } + /** + * HashSet for emitsLight. + */ + private static final Set emitsLight = new HashSet(); + static { + emitsLight.add(BlockID.LAVA); + emitsLight.add(BlockID.STATIONARY_LAVA); + emitsLight.add(BlockID.BROWN_MUSHROOM); + emitsLight.add(BlockID.RED_MUSHROOM); + emitsLight.add(BlockID.TORCH); + emitsLight.add(BlockID.FIRE); + emitsLight.add(BlockID.BURNING_FURNACE); + emitsLight.add(BlockID.GLOWING_REDSTONE_ORE); + emitsLight.add(BlockID.REDSTONE_TORCH_ON); + emitsLight.add(BlockID.LIGHTSTONE); + emitsLight.add(BlockID.PORTAL); + emitsLight.add(BlockID.JACKOLANTERN); + emitsLight.add(BlockID.REDSTONE_REPEATER_ON); + emitsLight.add(BlockID.LOCKED_CHEST); + emitsLight.add(BlockID.BROWN_MUSHROOM_CAP); + emitsLight.add(BlockID.RED_MUSHROOM_CAP); + } + + /** + * Checks if the block type emits light + * + * @param id + * @return + */ + public static boolean emitsLight(int id) { + return emitsLight.contains(id); + } + + /** + * HashSet for emitsLight. + */ + private static final Set isTranslucent = new HashSet(); + static { + isTranslucent.add(BlockID.AIR); + isTranslucent.add(BlockID.SAPLING); + isTranslucent.add(BlockID.WATER); + isTranslucent.add(BlockID.STATIONARY_WATER); + //isTranslucent.add(BlockID.LEAVES); + isTranslucent.add(BlockID.GLASS); + isTranslucent.add(BlockID.BED); + isTranslucent.add(BlockID.POWERED_RAIL); + isTranslucent.add(BlockID.DETECTOR_RAIL); + //isTranslucent.add(BlockID.PISTON_STICKY_BASE); + isTranslucent.add(BlockID.WEB); + isTranslucent.add(BlockID.LONG_GRASS); + isTranslucent.add(BlockID.DEAD_BUSH); + //isTranslucent.add(BlockID.PISTON_BASE); + //isTranslucent.add(BlockID.PISTON_EXTENSION); + //isTranslucent.add(BlockID.PISTON_MOVING_PIECE); + isTranslucent.add(BlockID.YELLOW_FLOWER); + isTranslucent.add(BlockID.RED_FLOWER); + isTranslucent.add(BlockID.BROWN_MUSHROOM); + isTranslucent.add(BlockID.RED_MUSHROOM); + isTranslucent.add(BlockID.TORCH); + isTranslucent.add(BlockID.FIRE); + //isTranslucent.add(BlockID.MOB_SPAWNER); + //isTranslucent.add(BlockID.WOODEN_STAIRS); + isTranslucent.add(BlockID.REDSTONE_WIRE); + isTranslucent.add(BlockID.CROPS); + isTranslucent.add(BlockID.SIGN_POST); + isTranslucent.add(BlockID.WOODEN_DOOR); + isTranslucent.add(BlockID.LADDER); + isTranslucent.add(BlockID.MINECART_TRACKS); + //isTranslucent.add(BlockID.COBBLESTONE_STAIRS); + isTranslucent.add(BlockID.WALL_SIGN); + isTranslucent.add(BlockID.LEVER); + isTranslucent.add(BlockID.STONE_PRESSURE_PLATE); + isTranslucent.add(BlockID.IRON_DOOR); + isTranslucent.add(BlockID.WOODEN_PRESSURE_PLATE); + isTranslucent.add(BlockID.REDSTONE_TORCH_OFF); + isTranslucent.add(BlockID.REDSTONE_TORCH_ON); + isTranslucent.add(BlockID.STONE_BUTTON); + isTranslucent.add(BlockID.SNOW); + isTranslucent.add(BlockID.ICE); + //isTranslucent.add(BlockID.CACTUS); + isTranslucent.add(BlockID.REED); + isTranslucent.add(BlockID.FENCE); + isTranslucent.add(BlockID.PORTAL); + isTranslucent.add(BlockID.CAKE_BLOCK); + isTranslucent.add(BlockID.REDSTONE_REPEATER_OFF); + isTranslucent.add(BlockID.REDSTONE_REPEATER_ON); + isTranslucent.add(BlockID.TRAP_DOOR); + isTranslucent.add(BlockID.IRON_BARS); + isTranslucent.add(BlockID.GLASS_PANE); + isTranslucent.add(BlockID.PUMPKIN_STEM); + isTranslucent.add(BlockID.MELON_STEM); + isTranslucent.add(BlockID.VINE); + isTranslucent.add(BlockID.FENCE_GATE); + //isTranslucent.add(BlockID.BRICK_STAIRS); + isTranslucent.add(BlockID.STONE_BRICK_STAIRS); + } + + /** + * Checks if the block type lets light through + * + * @param id + * @return + */ + public static boolean isTranslucent(int id) { + return isTranslucent.contains(id); + } + /** * HashMap for getDroppedBlock. */