Optimized all of the public static boolean BlockType.*(int id) functions by using HashSets and put the blockDrops HashMap next to the getDroppedBlock function.

This commit is contained in:
TomyLobo 2011-09-16 04:25:20 +02:00
parent f0308efdd0
commit 7798319896

View File

@ -19,10 +19,12 @@
package com.sk89q.worldedit.blocks; package com.sk89q.worldedit.blocks;
import java.util.HashSet;
import java.util.Map; import java.util.Map;
import java.util.HashMap; import java.util.HashMap;
import java.util.EnumSet; import java.util.EnumSet;
import java.util.Map.Entry; import java.util.Map.Entry;
import java.util.Set;
import com.sk89q.util.StringUtil; import com.sk89q.util.StringUtil;
@ -143,113 +145,6 @@ public enum BlockType {
BRICK_STAIRS(BlockID.BRICK_STAIRS, "Brick stairs", "brickstairs", "bricksteps"), BRICK_STAIRS(BlockID.BRICK_STAIRS, "Brick stairs", "brickstairs", "bricksteps"),
STONE_BRICK_STAIRS(BlockID.STONE_BRICK_STAIRS, "Stone brick stairs", "stonebrickstairs", "smoothstonebrickstairs"); STONE_BRICK_STAIRS(BlockID.STONE_BRICK_STAIRS, "Stone brick stairs", "stonebrickstairs", "smoothstonebrickstairs");
/**
* Stores a list of dropped blocks for blocks.
*/
private static final Map<Integer,Integer> blockDrops = new HashMap<Integer,Integer>();
/**
* Static constructor.
*/
static {
blockDrops.put(BlockID.STONE, BlockID.COBBLESTONE);
blockDrops.put(BlockID.GRASS, BlockID.DIRT);
blockDrops.put(BlockID.DIRT, BlockID.DIRT);
blockDrops.put(BlockID.COBBLESTONE, BlockID.COBBLESTONE);
blockDrops.put(BlockID.WOOD, BlockID.WOOD);
blockDrops.put(BlockID.SAPLING, BlockID.SAPLING);
blockDrops.put(BlockID.BEDROCK, -1);
blockDrops.put(BlockID.SAND, BlockID.SAND);
blockDrops.put(BlockID.GRAVEL, BlockID.GRAVEL);
blockDrops.put(BlockID.GOLD_ORE, BlockID.GOLD_ORE);
blockDrops.put(BlockID.IRON_ORE, BlockID.IRON_ORE);
blockDrops.put(BlockID.COAL_ORE, BlockID.COAL_ORE);
blockDrops.put(BlockID.LOG, BlockID.LOG);
blockDrops.put(BlockID.LEAVES, BlockID.LEAVES);
blockDrops.put(BlockID.SPONGE, BlockID.SPONGE);
blockDrops.put(BlockID.GLASS, BlockID.GLASS); // Have to drop glass for //undo
blockDrops.put(BlockID.LAPIS_LAZULI_ORE, BlockID.LAPIS_LAZULI_ORE); // Block damage drops not implemented
blockDrops.put(BlockID.LAPIS_LAZULI_BLOCK, BlockID.LAPIS_LAZULI_BLOCK);
blockDrops.put(BlockID.DISPENSER, BlockID.DISPENSER);
blockDrops.put(BlockID.SANDSTONE, BlockID.SANDSTONE);
blockDrops.put(BlockID.NOTE_BLOCK, BlockID.NOTE_BLOCK);
blockDrops.put(BlockID.BED, ItemType.BED_ITEM.getID());
blockDrops.put(BlockID.POWERED_RAIL, BlockID.POWERED_RAIL);
blockDrops.put(BlockID.DETECTOR_RAIL, BlockID.DETECTOR_RAIL);
blockDrops.put(BlockID.WEB, BlockID.WEB);
blockDrops.put(BlockID.PISTON_EXTENSION, -1);
blockDrops.put(BlockID.CLOTH, BlockID.CLOTH);
blockDrops.put(BlockID.PISTON_MOVING_PIECE, -1);
blockDrops.put(BlockID.YELLOW_FLOWER, BlockID.YELLOW_FLOWER);
blockDrops.put(BlockID.RED_FLOWER, BlockID.RED_FLOWER);
blockDrops.put(BlockID.BROWN_MUSHROOM, BlockID.BROWN_MUSHROOM);
blockDrops.put(BlockID.RED_MUSHROOM, BlockID.RED_MUSHROOM);
blockDrops.put(BlockID.GOLD_BLOCK, BlockID.GOLD_BLOCK);
blockDrops.put(BlockID.IRON_BLOCK, BlockID.IRON_BLOCK);
blockDrops.put(BlockID.DOUBLE_STEP, BlockID.DOUBLE_STEP);
blockDrops.put(BlockID.STEP, BlockID.STEP);
blockDrops.put(BlockID.BRICK, BlockID.BRICK);
blockDrops.put(BlockID.BOOKCASE, BlockID.BOOKCASE);
blockDrops.put(BlockID.MOSSY_COBBLESTONE, BlockID.MOSSY_COBBLESTONE);
blockDrops.put(BlockID.OBSIDIAN, BlockID.OBSIDIAN);
blockDrops.put(BlockID.TORCH, BlockID.TORCH);
blockDrops.put(BlockID.WOODEN_STAIRS, BlockID.WOODEN_STAIRS);
blockDrops.put(BlockID.CHEST, BlockID.CHEST);
blockDrops.put(BlockID.REDSTONE_WIRE, ItemType.REDSTONE_DUST.getID());
blockDrops.put(BlockID.DIAMOND_ORE, ItemType.DIAMOND.getID());
blockDrops.put(BlockID.DIAMOND_BLOCK, BlockID.DIAMOND_BLOCK);
blockDrops.put(BlockID.WORKBENCH, BlockID.WORKBENCH);
blockDrops.put(BlockID.CROPS, ItemType.SEEDS.getID());
blockDrops.put(BlockID.SOIL, BlockID.SOIL);
blockDrops.put(BlockID.FURNACE, BlockID.FURNACE);
blockDrops.put(BlockID.BURNING_FURNACE, BlockID.FURNACE);
blockDrops.put(BlockID.SIGN_POST, ItemType.SIGN.getID());
blockDrops.put(BlockID.WOODEN_DOOR, ItemType.WOODEN_DOOR_ITEM.getID());
blockDrops.put(BlockID.LADDER, BlockID.LADDER);
blockDrops.put(BlockID.MINECART_TRACKS, BlockID.MINECART_TRACKS);
blockDrops.put(BlockID.COBBLESTONE_STAIRS, BlockID.COBBLESTONE_STAIRS);
blockDrops.put(BlockID.WALL_SIGN, ItemType.SIGN.getID());
blockDrops.put(BlockID.LEVER, BlockID.LEVER);
blockDrops.put(BlockID.STONE_PRESSURE_PLATE, BlockID.STONE_PRESSURE_PLATE);
blockDrops.put(BlockID.IRON_DOOR, ItemType.IRON_DOOR_ITEM.getID());
blockDrops.put(BlockID.WOODEN_PRESSURE_PLATE, BlockID.WOODEN_PRESSURE_PLATE);
blockDrops.put(BlockID.REDSTONE_ORE, ItemType.REDSTONE_DUST.getID());
blockDrops.put(BlockID.GLOWING_REDSTONE_ORE, ItemType.REDSTONE_DUST.getID());
blockDrops.put(BlockID.REDSTONE_TORCH_OFF, BlockID.REDSTONE_TORCH_ON);
blockDrops.put(BlockID.REDSTONE_TORCH_ON, BlockID.REDSTONE_TORCH_ON);
blockDrops.put(BlockID.STONE_BUTTON, BlockID.STONE_BUTTON);
blockDrops.put(BlockID.SNOW, ItemType.SNOWBALL.getID());
blockDrops.put(BlockID.ICE, BlockID.ICE);
blockDrops.put(BlockID.SNOW_BLOCK, BlockID.SNOW_BLOCK);
blockDrops.put(BlockID.CLAY, BlockID.CLAY);
blockDrops.put(BlockID.REED, ItemType.SUGAR_CANE_ITEM.getID());
blockDrops.put(BlockID.JUKEBOX, BlockID.JUKEBOX);
blockDrops.put(BlockID.FENCE, BlockID.FENCE);
blockDrops.put(BlockID.PUMPKIN, BlockID.PUMPKIN);
blockDrops.put(BlockID.NETHERRACK, BlockID.NETHERRACK);
blockDrops.put(BlockID.SLOW_SAND, BlockID.SLOW_SAND);
blockDrops.put(BlockID.LIGHTSTONE, ItemType.LIGHTSTONE_DUST.getID());
blockDrops.put(BlockID.JACKOLANTERN, BlockID.JACKOLANTERN);
blockDrops.put(BlockID.CAKE_BLOCK, ItemType.CAKE_ITEM.getID());
blockDrops.put(BlockID.REDSTONE_REPEATER_OFF, ItemType.REDSTONE_REPEATER.getID());
blockDrops.put(BlockID.REDSTONE_REPEATER_ON, ItemType.REDSTONE_REPEATER.getID());
blockDrops.put(BlockID.LOCKED_CHEST, BlockID.LOCKED_CHEST);
blockDrops.put(BlockID.TRAP_DOOR, BlockID.TRAP_DOOR);
blockDrops.put(BlockID.SILVERFISH_BLOCK, -1);
blockDrops.put(BlockID.STONE_BRICK, BlockID.STONE_BRICK);
blockDrops.put(BlockID.BROWN_MUSHROOM_CAP, BlockID.BROWN_MUSHROOM_CAP); // the wiki has the 2 mushroom caps the other way round
blockDrops.put(BlockID.RED_MUSHROOM_CAP, BlockID.RED_MUSHROOM_CAP);
blockDrops.put(BlockID.IRON_BARS, BlockID.IRON_BARS);
blockDrops.put(BlockID.GLASS_PANE, BlockID.GLASS_PANE);
blockDrops.put(BlockID.MELON_BLOCK, BlockID.MELON_BLOCK);
blockDrops.put(BlockID.PUMPKIN_STEM, BlockID.PUMPKIN_STEM);
blockDrops.put(BlockID.MELON_STEM, BlockID.MELON_STEM);
blockDrops.put(BlockID.VINE, -1);
blockDrops.put(BlockID.FENCE_GATE, BlockID.FENCE_GATE);
blockDrops.put(BlockID.BRICK_STAIRS, BlockID.BRICK);
blockDrops.put(BlockID.STONE_BRICK_STAIRS, BlockID.STONE_BRICK);
}
/** /**
* Stores a map of the IDs for fast access. * Stores a map of the IDs for fast access.
*/ */
@ -373,13 +268,49 @@ public enum BlockType {
return name; return name;
} }
/** /**
* Checks to see whether a block should be placed last. * HashSet for shouldPlaceLast.
*
* @return
*/ */
public boolean shouldPlaceLast() { private static final Set<Integer> shouldPlaceLast = new HashSet<Integer>();
return shouldPlaceLast(id); static {
shouldPlaceLast.add(BlockID.SAPLING);
shouldPlaceLast.add(BlockID.BED);
shouldPlaceLast.add(BlockID.POWERED_RAIL);
shouldPlaceLast.add(BlockID.DETECTOR_RAIL);
shouldPlaceLast.add(BlockID.LONG_GRASS);
shouldPlaceLast.add(BlockID.DEAD_BUSH);
shouldPlaceLast.add(BlockID.YELLOW_FLOWER);
shouldPlaceLast.add(BlockID.RED_FLOWER);
shouldPlaceLast.add(BlockID.BROWN_MUSHROOM);
shouldPlaceLast.add(BlockID.RED_MUSHROOM);
shouldPlaceLast.add(BlockID.TORCH);
shouldPlaceLast.add(BlockID.FIRE);
shouldPlaceLast.add(BlockID.REDSTONE_WIRE);
shouldPlaceLast.add(BlockID.CROPS);
shouldPlaceLast.add(BlockID.SIGN_POST);
shouldPlaceLast.add(BlockID.WOODEN_DOOR);
shouldPlaceLast.add(BlockID.LADDER);
shouldPlaceLast.add(BlockID.MINECART_TRACKS);
shouldPlaceLast.add(BlockID.WALL_SIGN);
shouldPlaceLast.add(BlockID.LEVER);
shouldPlaceLast.add(BlockID.STONE_PRESSURE_PLATE);
shouldPlaceLast.add(BlockID.IRON_DOOR);
shouldPlaceLast.add(BlockID.WOODEN_PRESSURE_PLATE);
shouldPlaceLast.add(BlockID.REDSTONE_TORCH_OFF);
shouldPlaceLast.add(BlockID.REDSTONE_TORCH_ON);
shouldPlaceLast.add(BlockID.STONE_BUTTON);
shouldPlaceLast.add(BlockID.SNOW);
shouldPlaceLast.add(BlockID.CACTUS);
shouldPlaceLast.add(BlockID.REED);
shouldPlaceLast.add(BlockID.PORTAL);
shouldPlaceLast.add(BlockID.CAKE_BLOCK);
shouldPlaceLast.add(BlockID.REDSTONE_REPEATER_OFF);
shouldPlaceLast.add(BlockID.REDSTONE_REPEATER_ON);
shouldPlaceLast.add(BlockID.TRAP_DOOR);
shouldPlaceLast.add(BlockID.GLASS_PANE);
shouldPlaceLast.add(BlockID.VINE);
shouldPlaceLast.add(BlockID.FENCE_GATE);
} }
/** /**
@ -389,43 +320,57 @@ public enum BlockType {
* @return * @return
*/ */
public static boolean shouldPlaceLast(int id) { public static boolean shouldPlaceLast(int id) {
return id == BlockID.SAPLING return shouldPlaceLast.contains(id);
|| id == BlockID.BED }
|| id == BlockID.POWERED_RAIL
|| id == BlockID.DETECTOR_RAIL /**
|| id == BlockID.LONG_GRASS * Checks to see whether this block should be placed last.
|| id == BlockID.DEAD_BUSH *
|| id == BlockID.YELLOW_FLOWER * @return
|| id == BlockID.RED_FLOWER */
|| id == BlockID.BROWN_MUSHROOM public boolean shouldPlaceLast() {
|| id == BlockID.RED_MUSHROOM return shouldPlaceLast.contains(id);
|| id == BlockID.TORCH }
|| id == BlockID.FIRE
|| id == BlockID.REDSTONE_WIRE /**
|| id == BlockID.CROPS * HashSet for canPassThrough.
|| id == BlockID.SIGN_POST */
|| id == BlockID.WOODEN_DOOR private static final Set<Integer> canPassThrough = new HashSet<Integer>();
|| id == BlockID.LADDER static {
|| id == BlockID.MINECART_TRACKS canPassThrough.add(BlockID.AIR);
|| id == BlockID.WALL_SIGN canPassThrough.add(BlockID.WATER);
|| id == BlockID.LEVER canPassThrough.add(BlockID.STATIONARY_WATER);
|| id == BlockID.STONE_PRESSURE_PLATE canPassThrough.add(BlockID.SAPLING);
|| id == BlockID.IRON_DOOR canPassThrough.add(BlockID.POWERED_RAIL);
|| id == BlockID.WOODEN_PRESSURE_PLATE canPassThrough.add(BlockID.DETECTOR_RAIL);
|| id == BlockID.REDSTONE_TORCH_OFF canPassThrough.add(BlockID.WEB);
|| id == BlockID.REDSTONE_TORCH_ON canPassThrough.add(BlockID.LONG_GRASS);
|| id == BlockID.STONE_BUTTON canPassThrough.add(BlockID.DEAD_BUSH);
|| id == BlockID.SNOW canPassThrough.add(BlockID.YELLOW_FLOWER);
|| id == BlockID.CACTUS canPassThrough.add(BlockID.RED_FLOWER);
|| id == BlockID.REED canPassThrough.add(BlockID.BROWN_MUSHROOM);
|| id == BlockID.PORTAL canPassThrough.add(BlockID.RED_MUSHROOM);
|| id == BlockID.CAKE_BLOCK canPassThrough.add(BlockID.TORCH);
|| id == BlockID.REDSTONE_REPEATER_OFF canPassThrough.add(BlockID.FIRE);
|| id == BlockID.REDSTONE_REPEATER_ON canPassThrough.add(BlockID.REDSTONE_WIRE);
|| id == BlockID.TRAP_DOOR canPassThrough.add(BlockID.CROPS);
|| id == BlockID.GLASS_PANE canPassThrough.add(BlockID.SIGN_POST);
|| id == BlockID.VINE canPassThrough.add(BlockID.LADDER);
|| id == BlockID.FENCE_GATE; canPassThrough.add(BlockID.MINECART_TRACKS);
canPassThrough.add(BlockID.WALL_SIGN);
canPassThrough.add(BlockID.LEVER);
canPassThrough.add(BlockID.STONE_PRESSURE_PLATE);
canPassThrough.add(BlockID.WOODEN_PRESSURE_PLATE);
canPassThrough.add(BlockID.REDSTONE_TORCH_OFF);
canPassThrough.add(BlockID.REDSTONE_TORCH_ON);
canPassThrough.add(BlockID.STONE_BUTTON);
canPassThrough.add(BlockID.SNOW);
canPassThrough.add(BlockID.REED);
canPassThrough.add(BlockID.PORTAL);
canPassThrough.add(BlockID.REDSTONE_REPEATER_OFF);
canPassThrough.add(BlockID.REDSTONE_REPEATER_ON);
canPassThrough.add(BlockID.FENCE_GATE);
canPassThrough.add(BlockID.VINE);
} }
/** /**
@ -435,40 +380,71 @@ public enum BlockType {
* @return * @return
*/ */
public static boolean canPassThrough(int id) { public static boolean canPassThrough(int id) {
return id == BlockID.AIR return canPassThrough.contains(id);
|| id == BlockID.WATER
|| id == BlockID.STATIONARY_WATER }
|| id == BlockID.SAPLING
|| id == BlockID.POWERED_RAIL /**
|| id == BlockID.DETECTOR_RAIL * HashSet for usesData.
|| id == BlockID.WEB */
|| id == BlockID.LONG_GRASS private static final Set<Integer> usesData = new HashSet<Integer>();
|| id == BlockID.DEAD_BUSH static {
|| id == BlockID.YELLOW_FLOWER usesData.add(BlockID.SAPLING);
|| id == BlockID.RED_FLOWER usesData.add(BlockID.WATER);
|| id == BlockID.BROWN_MUSHROOM usesData.add(BlockID.STATIONARY_WATER);
|| id == BlockID.RED_MUSHROOM usesData.add(BlockID.LAVA);
|| id == BlockID.TORCH usesData.add(BlockID.STATIONARY_LAVA);
|| id == BlockID.FIRE usesData.add(BlockID.LOG);
|| id == BlockID.REDSTONE_WIRE usesData.add(BlockID.LEAVES);
|| id == BlockID.CROPS usesData.add(BlockID.DISPENSER);
|| id == BlockID.SIGN_POST usesData.add(BlockID.NOTE_BLOCK);
|| id == BlockID.LADDER usesData.add(BlockID.BED);
|| id == BlockID.MINECART_TRACKS usesData.add(BlockID.POWERED_RAIL);
|| id == BlockID.WALL_SIGN usesData.add(BlockID.DETECTOR_RAIL);
|| id == BlockID.LEVER usesData.add(BlockID.PISTON_STICKY_BASE);
|| id == BlockID.STONE_PRESSURE_PLATE usesData.add(BlockID.LONG_GRASS);
|| id == BlockID.WOODEN_PRESSURE_PLATE usesData.add(BlockID.PISTON_BASE);
|| id == BlockID.REDSTONE_TORCH_OFF usesData.add(BlockID.PISTON_EXTENSION);
|| id == BlockID.REDSTONE_TORCH_ON usesData.add(BlockID.CLOTH);
|| id == BlockID.STONE_BUTTON usesData.add(BlockID.DOUBLE_STEP);
|| id == BlockID.SNOW usesData.add(BlockID.STEP);
|| id == BlockID.REED usesData.add(BlockID.TORCH);
|| id == BlockID.PORTAL usesData.add(BlockID.WOODEN_STAIRS);
|| id == BlockID.REDSTONE_REPEATER_OFF usesData.add(BlockID.REDSTONE_WIRE);
|| id == BlockID.REDSTONE_REPEATER_ON usesData.add(BlockID.CROPS);
|| id == BlockID.FENCE_GATE usesData.add(BlockID.SOIL);
|| id == BlockID.VINE; usesData.add(BlockID.FURNACE);
usesData.add(BlockID.BURNING_FURNACE);
usesData.add(BlockID.SIGN_POST);
usesData.add(BlockID.WOODEN_DOOR);
usesData.add(BlockID.LADDER);
usesData.add(BlockID.MINECART_TRACKS);
usesData.add(BlockID.COBBLESTONE_STAIRS);
usesData.add(BlockID.WALL_SIGN);
usesData.add(BlockID.LEVER);
usesData.add(BlockID.STONE_PRESSURE_PLATE);
usesData.add(BlockID.IRON_DOOR);
usesData.add(BlockID.WOODEN_PRESSURE_PLATE);
usesData.add(BlockID.REDSTONE_TORCH_OFF);
usesData.add(BlockID.REDSTONE_TORCH_ON);
usesData.add(BlockID.STONE_BUTTON);
usesData.add(BlockID.SNOW);
usesData.add(BlockID.CACTUS);
usesData.add(BlockID.PUMPKIN);
usesData.add(BlockID.JACKOLANTERN);
usesData.add(BlockID.CAKE_BLOCK);
usesData.add(BlockID.REDSTONE_REPEATER_OFF);
usesData.add(BlockID.REDSTONE_REPEATER_ON);
usesData.add(BlockID.TRAP_DOOR);
usesData.add(BlockID.STONE_BRICK);
usesData.add(BlockID.RED_MUSHROOM_CAP);
usesData.add(BlockID.BROWN_MUSHROOM_CAP);
usesData.add(BlockID.PUMPKIN_STEM);
usesData.add(BlockID.MELON_STEM);
usesData.add(BlockID.VINE);
usesData.add(BlockID.FENCE_GATE);
usesData.add(BlockID.BRICK_STAIRS);
usesData.add(BlockID.STONE_BRICK_STAIRS);
} }
/** /**
@ -478,62 +454,18 @@ public enum BlockType {
* @return * @return
*/ */
public static boolean usesData(int id) { public static boolean usesData(int id) {
return id == BlockID.SAPLING return usesData.contains(id);
|| id == BlockID.WATER }
|| id == BlockID.STATIONARY_WATER
|| id == BlockID.LAVA /**
|| id == BlockID.STATIONARY_LAVA * HashSet for isContainerBlock.
|| id == BlockID.LOG */
|| id == BlockID.LEAVES private static final Set<Integer> isContainerBlock = new HashSet<Integer>();
|| id == BlockID.DISPENSER static {
|| id == BlockID.NOTE_BLOCK isContainerBlock.add(BlockID.DISPENSER);
|| id == BlockID.BED isContainerBlock.add(BlockID.FURNACE);
|| id == BlockID.POWERED_RAIL isContainerBlock.add(BlockID.BURNING_FURNACE);
|| id == BlockID.DETECTOR_RAIL isContainerBlock.add(BlockID.CHEST);
|| id == BlockID.PISTON_STICKY_BASE
|| id == BlockID.LONG_GRASS
|| id == BlockID.PISTON_BASE
|| id == BlockID.PISTON_EXTENSION
|| id == BlockID.CLOTH
|| id == BlockID.DOUBLE_STEP
|| id == BlockID.STEP
|| id == BlockID.TORCH
|| id == BlockID.WOODEN_STAIRS
|| id == BlockID.REDSTONE_WIRE
|| id == BlockID.CROPS
|| id == BlockID.SOIL
|| id == BlockID.FURNACE
|| id == BlockID.BURNING_FURNACE
|| id == BlockID.SIGN_POST
|| id == BlockID.WOODEN_DOOR
|| id == BlockID.LADDER
|| id == BlockID.MINECART_TRACKS
|| id == BlockID.COBBLESTONE_STAIRS
|| id == BlockID.WALL_SIGN
|| id == BlockID.LEVER
|| id == BlockID.STONE_PRESSURE_PLATE
|| id == BlockID.IRON_DOOR
|| id == BlockID.WOODEN_PRESSURE_PLATE
|| id == BlockID.REDSTONE_TORCH_OFF
|| id == BlockID.REDSTONE_TORCH_ON
|| id == BlockID.STONE_BUTTON
|| id == BlockID.SNOW
|| id == BlockID.CACTUS
|| id == BlockID.PUMPKIN
|| id == BlockID.JACKOLANTERN
|| id == BlockID.CAKE_BLOCK
|| id == BlockID.REDSTONE_REPEATER_OFF
|| id == BlockID.REDSTONE_REPEATER_ON
|| id == BlockID.TRAP_DOOR
|| id == BlockID.STONE_BRICK
|| id == BlockID.RED_MUSHROOM_CAP
|| id == BlockID.BROWN_MUSHROOM_CAP
|| id == BlockID.PUMPKIN_STEM
|| id == BlockID.MELON_STEM
|| id == BlockID.VINE
|| id == BlockID.FENCE_GATE
|| id == BlockID.BRICK_STAIRS
|| id == BlockID.STONE_BRICK_STAIRS;
} }
/** /**
@ -543,10 +475,32 @@ public enum BlockType {
* @return * @return
*/ */
public static boolean isContainerBlock(int id) { public static boolean isContainerBlock(int id) {
return id == BlockID.DISPENSER return isContainerBlock.contains(id);
|| id == BlockID.FURNACE }
|| id == BlockID.BURNING_FURNACE
|| id == BlockID.CHEST; /**
* HashSet for isRedstoneBlock.
*/
private static final Set<Integer> isRedstoneBlock = new HashSet<Integer>();
static {
isRedstoneBlock.add(BlockID.POWERED_RAIL);
isRedstoneBlock.add(BlockID.DETECTOR_RAIL);
isRedstoneBlock.add(BlockID.PISTON_STICKY_BASE);
isRedstoneBlock.add(BlockID.PISTON_BASE);
isRedstoneBlock.add(BlockID.LEVER);
isRedstoneBlock.add(BlockID.STONE_PRESSURE_PLATE);
isRedstoneBlock.add(BlockID.WOODEN_PRESSURE_PLATE);
isRedstoneBlock.add(BlockID.REDSTONE_TORCH_OFF);
isRedstoneBlock.add(BlockID.REDSTONE_TORCH_ON);
isRedstoneBlock.add(BlockID.STONE_BUTTON);
isRedstoneBlock.add(BlockID.REDSTONE_WIRE);
isRedstoneBlock.add(BlockID.WOODEN_DOOR);
isRedstoneBlock.add(BlockID.IRON_DOOR);
isRedstoneBlock.add(BlockID.TNT);
isRedstoneBlock.add(BlockID.DISPENSER);
isRedstoneBlock.add(BlockID.NOTE_BLOCK);
isRedstoneBlock.add(BlockID.REDSTONE_REPEATER_OFF);
isRedstoneBlock.add(BlockID.REDSTONE_REPEATER_ON);
} }
/** /**
@ -556,24 +510,19 @@ public enum BlockType {
* @return * @return
*/ */
public static boolean isRedstoneBlock(int id) { public static boolean isRedstoneBlock(int id) {
return id == BlockID.POWERED_RAIL return isRedstoneBlock.contains(id);
|| id == BlockID.DETECTOR_RAIL }
|| id == BlockID.PISTON_STICKY_BASE
|| id == BlockID.PISTON_BASE /**
|| id == BlockID.LEVER * HashSet for canTransferRedstone.
|| id == BlockID.STONE_PRESSURE_PLATE */
|| id == BlockID.WOODEN_PRESSURE_PLATE private static final Set<Integer> canTransferRedstone = new HashSet<Integer>();
|| id == BlockID.REDSTONE_TORCH_OFF static {
|| id == BlockID.REDSTONE_TORCH_ON canTransferRedstone.add(BlockID.REDSTONE_TORCH_OFF);
|| id == BlockID.STONE_BUTTON canTransferRedstone.add(BlockID.REDSTONE_TORCH_ON);
|| id == BlockID.REDSTONE_WIRE canTransferRedstone.add(BlockID.REDSTONE_WIRE);
|| id == BlockID.WOODEN_DOOR canTransferRedstone.add(BlockID.REDSTONE_REPEATER_OFF);
|| id == BlockID.IRON_DOOR canTransferRedstone.add(BlockID.REDSTONE_REPEATER_ON);
|| id == BlockID.TNT
|| id == BlockID.DISPENSER
|| id == BlockID.NOTE_BLOCK
|| id == BlockID.REDSTONE_REPEATER_OFF
|| id == BlockID.REDSTONE_REPEATER_ON;
} }
/** /**
@ -584,11 +533,21 @@ public enum BlockType {
* @return * @return
*/ */
public static boolean canTransferRedstone(int id) { public static boolean canTransferRedstone(int id) {
return id == BlockID.REDSTONE_TORCH_OFF return canTransferRedstone.contains(id);
|| id == BlockID.REDSTONE_TORCH_ON }
|| id == BlockID.REDSTONE_WIRE
|| id == BlockID.REDSTONE_REPEATER_OFF /**
|| id == BlockID.REDSTONE_REPEATER_ON; * HashSet for isRedstoneSource.
*/
private static final Set<Integer> isRedstoneSource = new HashSet<Integer>();
static {
isRedstoneSource.add(BlockID.DETECTOR_RAIL);
isRedstoneSource.add(BlockID.REDSTONE_TORCH_OFF);
isRedstoneSource.add(BlockID.REDSTONE_TORCH_ON);
isRedstoneSource.add(BlockID.LEVER);
isRedstoneSource.add(BlockID.STONE_PRESSURE_PLATE);
isRedstoneSource.add(BlockID.WOODEN_PRESSURE_PLATE);
isRedstoneSource.add(BlockID.STONE_BUTTON);
} }
/** /**
@ -598,13 +557,17 @@ public enum BlockType {
* @return * @return
*/ */
public static boolean isRedstoneSource(int id) { public static boolean isRedstoneSource(int id) {
return id == BlockID.DETECTOR_RAIL return isRedstoneSource.contains(id);
|| id == BlockID.REDSTONE_TORCH_OFF }
|| id == BlockID.REDSTONE_TORCH_ON
|| id == BlockID.LEVER /**
|| id == BlockID.STONE_PRESSURE_PLATE * HashSet for isRailBlock.
|| id == BlockID.WOODEN_PRESSURE_PLATE */
|| id == BlockID.STONE_BUTTON; private static final Set<Integer> isRailBlock = new HashSet<Integer>();
static {
isRailBlock.add(BlockID.POWERED_RAIL);
isRailBlock.add(BlockID.DETECTOR_RAIL);
isRailBlock.add(BlockID.MINECART_TRACKS);
} }
/** /**
@ -614,9 +577,36 @@ public enum BlockType {
* @return * @return
*/ */
public static boolean isRailBlock(int id) { public static boolean isRailBlock(int id) {
return id == BlockID.POWERED_RAIL return isRailBlock.contains(id);
|| id == BlockID.DETECTOR_RAIL }
|| id == BlockID.MINECART_TRACKS;
/**
* HashSet for isNaturalBlock.
*/
private static final Set<Integer> isNaturalBlock = new HashSet<Integer>();
static {
isNaturalBlock.add(BlockID.STONE);
isNaturalBlock.add(BlockID.GRASS);
isNaturalBlock.add(BlockID.DIRT);
// isNaturalBlock.add(BlockID.COBBLESTONE); // technically can occur next to water and lava
isNaturalBlock.add(BlockID.BEDROCK);
isNaturalBlock.add(BlockID.SAND);
isNaturalBlock.add(BlockID.GRAVEL);
isNaturalBlock.add(BlockID.CLAY);
// hell
isNaturalBlock.add(BlockID.NETHERSTONE);
isNaturalBlock.add(BlockID.SLOW_SAND);
isNaturalBlock.add(BlockID.LIGHTSTONE);
// ores
isNaturalBlock.add(BlockID.COAL_ORE);
isNaturalBlock.add(BlockID.IRON_ORE);
isNaturalBlock.add(BlockID.GOLD_ORE);
isNaturalBlock.add(BlockID.LAPIS_LAZULI_ORE);
isNaturalBlock.add(BlockID.DIAMOND_ORE);
isNaturalBlock.add(BlockID.REDSTONE_ORE);
isNaturalBlock.add(BlockID.GLOWING_REDSTONE_ORE);
} }
/** /**
@ -626,26 +616,110 @@ public enum BlockType {
* @return * @return
*/ */
public static boolean isNaturalBlock(int id) { public static boolean isNaturalBlock(int id) {
return id == BlockID.STONE return isNaturalBlock.contains(id);
|| id == BlockID.GRASS }
|| id == BlockID.DIRT
// || id == BlockID.COBBLESTONE // technically can occur next to water and lava /**
|| id == BlockID.BEDROCK * HashMap for getDroppedBlock.
|| id == BlockID.SAND */
|| id == BlockID.GRAVEL private static final Map<Integer, Integer> blockDrops = new HashMap<Integer, Integer>();
|| id == BlockID.CLAY static {
// hell blockDrops.put(BlockID.STONE, BlockID.COBBLESTONE);
|| id == BlockID.NETHERSTONE blockDrops.put(BlockID.GRASS, BlockID.DIRT);
|| id == BlockID.SLOW_SAND blockDrops.put(BlockID.DIRT, BlockID.DIRT);
|| id == BlockID.LIGHTSTONE blockDrops.put(BlockID.COBBLESTONE, BlockID.COBBLESTONE);
// ores blockDrops.put(BlockID.WOOD, BlockID.WOOD);
|| id == BlockID.COAL_ORE blockDrops.put(BlockID.SAPLING, BlockID.SAPLING);
|| id == BlockID.IRON_ORE blockDrops.put(BlockID.BEDROCK, -1);
|| id == BlockID.GOLD_ORE blockDrops.put(BlockID.SAND, BlockID.SAND);
|| id == BlockID.LAPIS_LAZULI_ORE blockDrops.put(BlockID.GRAVEL, BlockID.GRAVEL);
|| id == BlockID.DIAMOND_ORE blockDrops.put(BlockID.GOLD_ORE, BlockID.GOLD_ORE);
|| id == BlockID.REDSTONE_ORE blockDrops.put(BlockID.IRON_ORE, BlockID.IRON_ORE);
|| id == BlockID.GLOWING_REDSTONE_ORE; blockDrops.put(BlockID.COAL_ORE, BlockID.COAL_ORE);
blockDrops.put(BlockID.LOG, BlockID.LOG);
blockDrops.put(BlockID.LEAVES, BlockID.LEAVES);
blockDrops.put(BlockID.SPONGE, BlockID.SPONGE);
blockDrops.put(BlockID.GLASS, BlockID.GLASS); // Have to drop glass for //undo
blockDrops.put(BlockID.LAPIS_LAZULI_ORE, BlockID.LAPIS_LAZULI_ORE); // Block damage drops not implemented
blockDrops.put(BlockID.LAPIS_LAZULI_BLOCK, BlockID.LAPIS_LAZULI_BLOCK);
blockDrops.put(BlockID.DISPENSER, BlockID.DISPENSER);
blockDrops.put(BlockID.SANDSTONE, BlockID.SANDSTONE);
blockDrops.put(BlockID.NOTE_BLOCK, BlockID.NOTE_BLOCK);
blockDrops.put(BlockID.BED, ItemType.BED_ITEM.getID());
blockDrops.put(BlockID.POWERED_RAIL, BlockID.POWERED_RAIL);
blockDrops.put(BlockID.DETECTOR_RAIL, BlockID.DETECTOR_RAIL);
blockDrops.put(BlockID.WEB, BlockID.WEB);
blockDrops.put(BlockID.PISTON_EXTENSION, -1);
blockDrops.put(BlockID.CLOTH, BlockID.CLOTH);
blockDrops.put(BlockID.PISTON_MOVING_PIECE, -1);
blockDrops.put(BlockID.YELLOW_FLOWER, BlockID.YELLOW_FLOWER);
blockDrops.put(BlockID.RED_FLOWER, BlockID.RED_FLOWER);
blockDrops.put(BlockID.BROWN_MUSHROOM, BlockID.BROWN_MUSHROOM);
blockDrops.put(BlockID.RED_MUSHROOM, BlockID.RED_MUSHROOM);
blockDrops.put(BlockID.GOLD_BLOCK, BlockID.GOLD_BLOCK);
blockDrops.put(BlockID.IRON_BLOCK, BlockID.IRON_BLOCK);
blockDrops.put(BlockID.DOUBLE_STEP, BlockID.DOUBLE_STEP);
blockDrops.put(BlockID.STEP, BlockID.STEP);
blockDrops.put(BlockID.BRICK, BlockID.BRICK);
blockDrops.put(BlockID.BOOKCASE, BlockID.BOOKCASE);
blockDrops.put(BlockID.MOSSY_COBBLESTONE, BlockID.MOSSY_COBBLESTONE);
blockDrops.put(BlockID.OBSIDIAN, BlockID.OBSIDIAN);
blockDrops.put(BlockID.TORCH, BlockID.TORCH);
blockDrops.put(BlockID.WOODEN_STAIRS, BlockID.WOODEN_STAIRS);
blockDrops.put(BlockID.CHEST, BlockID.CHEST);
blockDrops.put(BlockID.REDSTONE_WIRE, ItemType.REDSTONE_DUST.getID());
blockDrops.put(BlockID.DIAMOND_ORE, ItemType.DIAMOND.getID());
blockDrops.put(BlockID.DIAMOND_BLOCK, BlockID.DIAMOND_BLOCK);
blockDrops.put(BlockID.WORKBENCH, BlockID.WORKBENCH);
blockDrops.put(BlockID.CROPS, ItemType.SEEDS.getID());
blockDrops.put(BlockID.SOIL, BlockID.SOIL);
blockDrops.put(BlockID.FURNACE, BlockID.FURNACE);
blockDrops.put(BlockID.BURNING_FURNACE, BlockID.FURNACE);
blockDrops.put(BlockID.SIGN_POST, ItemType.SIGN.getID());
blockDrops.put(BlockID.WOODEN_DOOR, ItemType.WOODEN_DOOR_ITEM.getID());
blockDrops.put(BlockID.LADDER, BlockID.LADDER);
blockDrops.put(BlockID.MINECART_TRACKS, BlockID.MINECART_TRACKS);
blockDrops.put(BlockID.COBBLESTONE_STAIRS, BlockID.COBBLESTONE_STAIRS);
blockDrops.put(BlockID.WALL_SIGN, ItemType.SIGN.getID());
blockDrops.put(BlockID.LEVER, BlockID.LEVER);
blockDrops.put(BlockID.STONE_PRESSURE_PLATE, BlockID.STONE_PRESSURE_PLATE);
blockDrops.put(BlockID.IRON_DOOR, ItemType.IRON_DOOR_ITEM.getID());
blockDrops.put(BlockID.WOODEN_PRESSURE_PLATE, BlockID.WOODEN_PRESSURE_PLATE);
blockDrops.put(BlockID.REDSTONE_ORE, ItemType.REDSTONE_DUST.getID());
blockDrops.put(BlockID.GLOWING_REDSTONE_ORE, ItemType.REDSTONE_DUST.getID());
blockDrops.put(BlockID.REDSTONE_TORCH_OFF, BlockID.REDSTONE_TORCH_ON);
blockDrops.put(BlockID.REDSTONE_TORCH_ON, BlockID.REDSTONE_TORCH_ON);
blockDrops.put(BlockID.STONE_BUTTON, BlockID.STONE_BUTTON);
blockDrops.put(BlockID.SNOW, ItemType.SNOWBALL.getID());
blockDrops.put(BlockID.ICE, BlockID.ICE);
blockDrops.put(BlockID.SNOW_BLOCK, BlockID.SNOW_BLOCK);
blockDrops.put(BlockID.CLAY, BlockID.CLAY);
blockDrops.put(BlockID.REED, ItemType.SUGAR_CANE_ITEM.getID());
blockDrops.put(BlockID.JUKEBOX, BlockID.JUKEBOX);
blockDrops.put(BlockID.FENCE, BlockID.FENCE);
blockDrops.put(BlockID.PUMPKIN, BlockID.PUMPKIN);
blockDrops.put(BlockID.NETHERRACK, BlockID.NETHERRACK);
blockDrops.put(BlockID.SLOW_SAND, BlockID.SLOW_SAND);
blockDrops.put(BlockID.LIGHTSTONE, ItemType.LIGHTSTONE_DUST.getID());
blockDrops.put(BlockID.JACKOLANTERN, BlockID.JACKOLANTERN);
blockDrops.put(BlockID.CAKE_BLOCK, ItemType.CAKE_ITEM.getID());
blockDrops.put(BlockID.REDSTONE_REPEATER_OFF, ItemType.REDSTONE_REPEATER.getID());
blockDrops.put(BlockID.REDSTONE_REPEATER_ON, ItemType.REDSTONE_REPEATER.getID());
blockDrops.put(BlockID.LOCKED_CHEST, BlockID.LOCKED_CHEST);
blockDrops.put(BlockID.TRAP_DOOR, BlockID.TRAP_DOOR);
blockDrops.put(BlockID.SILVERFISH_BLOCK, -1);
blockDrops.put(BlockID.STONE_BRICK, BlockID.STONE_BRICK);
blockDrops.put(BlockID.BROWN_MUSHROOM_CAP, BlockID.BROWN_MUSHROOM_CAP); // the wiki has the 2 mushroom caps the other way round
blockDrops.put(BlockID.RED_MUSHROOM_CAP, BlockID.RED_MUSHROOM_CAP);
blockDrops.put(BlockID.IRON_BARS, BlockID.IRON_BARS);
blockDrops.put(BlockID.GLASS_PANE, BlockID.GLASS_PANE);
blockDrops.put(BlockID.MELON_BLOCK, BlockID.MELON_BLOCK);
blockDrops.put(BlockID.PUMPKIN_STEM, BlockID.PUMPKIN_STEM);
blockDrops.put(BlockID.MELON_STEM, BlockID.MELON_STEM);
blockDrops.put(BlockID.VINE, -1);
blockDrops.put(BlockID.FENCE_GATE, BlockID.FENCE_GATE);
blockDrops.put(BlockID.BRICK_STAIRS, BlockID.BRICK);
blockDrops.put(BlockID.STONE_BRICK_STAIRS, BlockID.STONE_BRICK);
} }
/** /**