From 66253ff8913534db97840f6ac36194e3ae85d863 Mon Sep 17 00:00:00 2001 From: TomyLobo Date: Sun, 17 Nov 2013 16:15:22 +0100 Subject: [PATCH] Added BlockType.getBlockForItem. --- .../com/sk89q/worldedit/blocks/BlockType.java | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/src/main/java/com/sk89q/worldedit/blocks/BlockType.java b/src/main/java/com/sk89q/worldedit/blocks/BlockType.java index 8e99003c4..3eeff5ef9 100644 --- a/src/main/java/com/sk89q/worldedit/blocks/BlockType.java +++ b/src/main/java/com/sk89q/worldedit/blocks/BlockType.java @@ -283,6 +283,39 @@ public enum BlockType { } } + private static Map itemBlockMapping = new HashMap(); + static { + itemBlockMapping.put(ItemID.FLINT_AND_TINDER, new BaseBlock(BlockID.FIRE, -1)); + itemBlockMapping.put(ItemID.STRING, new BaseBlock(BlockID.TRIPWIRE, -1)); + itemBlockMapping.put(ItemID.SEEDS, new BaseBlock(BlockID.CROPS, -1)); + itemBlockMapping.put(ItemID.SIGN, new BaseBlock(BlockID.SIGN_POST, -1)); + itemBlockMapping.put(ItemID.WOODEN_DOOR_ITEM, new BaseBlock(BlockID.WOODEN_DOOR, -1)); + itemBlockMapping.put(ItemID.WATER_BUCKET, new BaseBlock(BlockID.STATIONARY_WATER, -1)); + itemBlockMapping.put(ItemID.LAVA_BUCKET, new BaseBlock(BlockID.STATIONARY_LAVA, -1)); + itemBlockMapping.put(ItemID.IRON_DOOR_ITEM, new BaseBlock(BlockID.IRON_DOOR, -1)); + itemBlockMapping.put(ItemID.REDSTONE_DUST, new BaseBlock(BlockID.REDSTONE_WIRE, -1)); + itemBlockMapping.put(ItemID.SUGAR_CANE_ITEM, new BaseBlock(BlockID.REED, -1)); + itemBlockMapping.put(ItemID.BED_ITEM, new BaseBlock(BlockID.BED, -1)); + itemBlockMapping.put(ItemID.REDSTONE_REPEATER, new BaseBlock(BlockID.REDSTONE_REPEATER_OFF, -1)); + itemBlockMapping.put(ItemID.PUMPKIN_SEEDS, new BaseBlock(BlockID.PUMPKIN_STEM, -1)); + itemBlockMapping.put(ItemID.MELON_SEEDS, new BaseBlock(BlockID.MELON_STEM, -1)); + itemBlockMapping.put(ItemID.NETHER_WART_SEED, new BaseBlock(BlockID.NETHER_WART, -1)); + itemBlockMapping.put(ItemID.BREWING_STAND, new BaseBlock(BlockID.BREWING_STAND, -1)); + itemBlockMapping.put(ItemID.CAULDRON, new BaseBlock(BlockID.CAULDRON, -1)); + itemBlockMapping.put(ItemID.FLOWER_POT, new BaseBlock(BlockID.FLOWER_POT, -1)); + itemBlockMapping.put(ItemID.CARROT, new BaseBlock(BlockID.CARROTS, -1)); + itemBlockMapping.put(ItemID.POTATO, new BaseBlock(BlockID.POTATOES, -1)); + itemBlockMapping.put(ItemID.COMPARATOR, new BaseBlock(BlockID.COMPARATOR_OFF, -1)); + + // These are just for fun: + itemBlockMapping.put(ItemID.BUCKET, new BaseBlock(BlockID.AIR, -1)); // There's nothing in the bucket, what did you expect? + itemBlockMapping.put(ItemID.MILK_BUCKET, new BaseBlock(BlockID.SNOW, -1)); // Whoops, spilled the milk + } + + public static BaseBlock getBlockForItem(int typeId) { + return itemBlockMapping.get(typeId); + } + /** * Get block numeric ID. *