mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2024-11-20 02:45:00 +00:00
Employed a set of consistent rules for getDroppedBlock(type, data) and renamed it to getBlockBagItem.
This commit is contained in:
parent
d9b8285a35
commit
8e368ceef1
@ -36,7 +36,7 @@ public abstract class BlockBag {
|
|||||||
* @throws BlockBagException
|
* @throws BlockBagException
|
||||||
*/
|
*/
|
||||||
public void storeDroppedBlock(int id, int data) throws BlockBagException {
|
public void storeDroppedBlock(int id, int data) throws BlockBagException {
|
||||||
BaseItem dropped = BlockType.getDroppedBlock(id, data);
|
BaseItem dropped = BlockType.getBlockBagItem(id, data);
|
||||||
if (dropped == null) return;
|
if (dropped == null) return;
|
||||||
if (dropped.getType() == BlockID.AIR) return;
|
if (dropped.getType() == BlockID.AIR) return;
|
||||||
|
|
||||||
@ -121,6 +121,8 @@ public abstract class BlockBag {
|
|||||||
/**
|
/**
|
||||||
* Store a block.
|
* Store a block.
|
||||||
*
|
*
|
||||||
|
* Either this method or storeItem needs to be overridden
|
||||||
|
*
|
||||||
* @param id
|
* @param id
|
||||||
* @throws BlockBagException
|
* @throws BlockBagException
|
||||||
*/
|
*/
|
||||||
@ -131,6 +133,8 @@ public abstract class BlockBag {
|
|||||||
/**
|
/**
|
||||||
* Store a block.
|
* Store a block.
|
||||||
*
|
*
|
||||||
|
* Either this method or storeBlock needs to be overridden
|
||||||
|
*
|
||||||
* @param item
|
* @param item
|
||||||
* @throws BlockBagException
|
* @throws BlockBagException
|
||||||
*/
|
*/
|
||||||
|
@ -857,126 +857,151 @@ public enum BlockType {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* HashMap for getDroppedBlock.
|
* HashMap for getBlockBagItem.
|
||||||
*/
|
*/
|
||||||
private static final Map<Integer, BaseItem> dataBlockDrops = new HashMap<Integer, BaseItem>();
|
private static final Map<Integer, BaseItem> dataBlockBagItems = new HashMap<Integer, BaseItem>();
|
||||||
private static final Map<Integer, BaseItem> nonDataBlockDrops = new HashMap<Integer, BaseItem>();
|
private static final Map<Integer, BaseItem> nonDataBlockBagItems = new HashMap<Integer, BaseItem>();
|
||||||
private static final BaseItem doNotDestroy = new BaseItemStack(BlockID.AIR, 0);
|
private static final BaseItem doNotDestroy = new BaseItemStack(BlockID.AIR, 0);
|
||||||
static {
|
static {
|
||||||
// TODO: consider data values
|
/*
|
||||||
|
* rules:
|
||||||
nonDataBlockDrops.put(BlockID.STONE, new BaseItem(BlockID.COBBLESTONE));
|
*
|
||||||
nonDataBlockDrops.put(BlockID.GRASS, new BaseItem(BlockID.DIRT));
|
* 1. block yields itself => addIdentity
|
||||||
nonDataBlockDrops.put(BlockID.DIRT, new BaseItem(BlockID.DIRT));
|
* 2. block is part of a 2-block object => drop an appropriate item for one of the 2 blocks
|
||||||
nonDataBlockDrops.put(BlockID.COBBLESTONE, new BaseItem(BlockID.COBBLESTONE));
|
* 3. block can be placed by right-clicking an obtainable item on the ground => use that item
|
||||||
nonDataBlockDrops.put(BlockID.WOOD, new BaseItem(BlockID.WOOD));
|
* 4. block yields more than one item => addIdentity
|
||||||
nonDataBlockDrops.put(BlockID.SAPLING, new BaseItem(BlockID.SAPLING));
|
* 5. block yields exactly one item => use that item
|
||||||
nonDataBlockDrops.put(BlockID.BEDROCK, doNotDestroy);
|
* 6. block is a liquid => drop nothing
|
||||||
nonDataBlockDrops.put(BlockID.SAND, new BaseItem(BlockID.SAND));
|
* 7. block is created from thin air by the game other than by the map generator => drop nothing
|
||||||
nonDataBlockDrops.put(BlockID.GRAVEL, new BaseItem(BlockID.GRAVEL));
|
*/
|
||||||
nonDataBlockDrops.put(BlockID.GOLD_ORE, new BaseItem(BlockID.GOLD_ORE));
|
|
||||||
nonDataBlockDrops.put(BlockID.IRON_ORE, new BaseItem(BlockID.IRON_ORE));
|
nonDataBlockBagItems.put(BlockID.STONE, new BaseItem(BlockID.COBBLESTONE)); // rule 5
|
||||||
nonDataBlockDrops.put(BlockID.COAL_ORE, new BaseItem(BlockID.COAL_ORE));
|
nonDataBlockBagItems.put(BlockID.GRASS, new BaseItem(BlockID.DIRT)); // rule 5
|
||||||
nonDataBlockDrops.put(BlockID.LOG, new BaseItem(BlockID.LOG));
|
addIdentity(BlockID.DIRT); // rule 1
|
||||||
nonDataBlockDrops.put(BlockID.LEAVES, new BaseItem(BlockID.LEAVES));
|
addIdentity(BlockID.COBBLESTONE); // rule 1
|
||||||
nonDataBlockDrops.put(BlockID.SPONGE, new BaseItem(BlockID.SPONGE));
|
addIdentity(BlockID.WOOD); // rule 1
|
||||||
nonDataBlockDrops.put(BlockID.GLASS, new BaseItem(BlockID.GLASS)); // Have to drop glass for //undo
|
addIdentities(BlockID.SAPLING, 3); // rule 1
|
||||||
nonDataBlockDrops.put(BlockID.LAPIS_LAZULI_ORE, new BaseItem(BlockID.LAPIS_LAZULI_ORE)); // Block damage drops not implemented
|
nonDataBlockBagItems.put(BlockID.BEDROCK, doNotDestroy); // exception
|
||||||
nonDataBlockDrops.put(BlockID.LAPIS_LAZULI_BLOCK, new BaseItem(BlockID.LAPIS_LAZULI_BLOCK));
|
// WATER, rule 6
|
||||||
nonDataBlockDrops.put(BlockID.DISPENSER, new BaseItem(BlockID.DISPENSER));
|
// STATIONARY_WATER, rule 6
|
||||||
nonDataBlockDrops.put(BlockID.SANDSTONE, new BaseItem(BlockID.SANDSTONE));
|
// LAVA, rule 6
|
||||||
nonDataBlockDrops.put(BlockID.NOTE_BLOCK, new BaseItem(BlockID.NOTE_BLOCK));
|
// STATIONARY_LAVA, rule 6
|
||||||
nonDataBlockDrops.put(BlockID.BED, new BaseItem(ItemID.BED_ITEM));
|
addIdentity(BlockID.SAND); // rule 1
|
||||||
nonDataBlockDrops.put(BlockID.POWERED_RAIL, new BaseItem(BlockID.POWERED_RAIL));
|
addIdentity(BlockID.GRAVEL); // rule 1
|
||||||
nonDataBlockDrops.put(BlockID.DETECTOR_RAIL, new BaseItem(BlockID.DETECTOR_RAIL));
|
addIdentity(BlockID.GOLD_ORE); // rule 1
|
||||||
nonDataBlockDrops.put(BlockID.WEB, new BaseItem(BlockID.WEB));
|
addIdentity(BlockID.IRON_ORE); // rule 1
|
||||||
nonDataBlockDrops.put(BlockID.PISTON_EXTENSION, doNotDestroy);
|
nonDataBlockBagItems.put(BlockID.COAL_ORE, new BaseItem(ItemID.COAL)); // rule 5
|
||||||
nonDataBlockDrops.put(BlockID.CLOTH, new BaseItem(BlockID.CLOTH));
|
addIdentities(BlockID.LOG, 3); // rule 1
|
||||||
nonDataBlockDrops.put(BlockID.PISTON_MOVING_PIECE, doNotDestroy);
|
addIdentities(BlockID.LEAVES, 4); // rule 1 with shears, otherwise rule 3
|
||||||
nonDataBlockDrops.put(BlockID.YELLOW_FLOWER, new BaseItem(BlockID.YELLOW_FLOWER));
|
addIdentity(BlockID.SPONGE); // rule 1
|
||||||
nonDataBlockDrops.put(BlockID.RED_FLOWER, new BaseItem(BlockID.RED_FLOWER));
|
addIdentity(BlockID.GLASS); // rule 3
|
||||||
nonDataBlockDrops.put(BlockID.BROWN_MUSHROOM, new BaseItem(BlockID.BROWN_MUSHROOM));
|
addIdentity(BlockID.LAPIS_LAZULI_ORE); // rule 4
|
||||||
nonDataBlockDrops.put(BlockID.RED_MUSHROOM, new BaseItem(BlockID.RED_MUSHROOM));
|
addIdentity(BlockID.LAPIS_LAZULI_BLOCK); // rule 1
|
||||||
nonDataBlockDrops.put(BlockID.GOLD_BLOCK, new BaseItem(BlockID.GOLD_BLOCK));
|
addIdentity(BlockID.DISPENSER); // rule 1
|
||||||
nonDataBlockDrops.put(BlockID.IRON_BLOCK, new BaseItem(BlockID.IRON_BLOCK));
|
addIdentity(BlockID.SANDSTONE); // rule 1
|
||||||
nonDataBlockDrops.put(BlockID.DOUBLE_STEP, new BaseItem(BlockID.DOUBLE_STEP));
|
addIdentity(BlockID.NOTE_BLOCK); // rule 1
|
||||||
nonDataBlockDrops.put(BlockID.STEP, new BaseItem(BlockID.STEP));
|
addIdentities(BlockID.BED, 8); // rule 2
|
||||||
nonDataBlockDrops.put(BlockID.BRICK, new BaseItem(BlockID.BRICK));
|
addIdentity(BlockID.POWERED_RAIL); // rule 1
|
||||||
nonDataBlockDrops.put(BlockID.BOOKCASE, new BaseItem(BlockID.BOOKCASE));
|
addIdentity(BlockID.DETECTOR_RAIL); // rule 1
|
||||||
nonDataBlockDrops.put(BlockID.MOSSY_COBBLESTONE, new BaseItem(BlockID.MOSSY_COBBLESTONE));
|
addIdentity(BlockID.PISTON_STICKY_BASE);
|
||||||
nonDataBlockDrops.put(BlockID.OBSIDIAN, new BaseItem(BlockID.OBSIDIAN));
|
nonDataBlockBagItems.put(BlockID.WEB, new BaseItem(ItemID.STRING)); // rule 5
|
||||||
nonDataBlockDrops.put(BlockID.TORCH, new BaseItem(BlockID.TORCH));
|
// LONG_GRASS
|
||||||
nonDataBlockDrops.put(BlockID.WOODEN_STAIRS, new BaseItem(BlockID.WOODEN_STAIRS));
|
// DEAD_BUSH
|
||||||
nonDataBlockDrops.put(BlockID.CHEST, new BaseItem(BlockID.CHEST));
|
addIdentity(BlockID.PISTON_BASE);
|
||||||
nonDataBlockDrops.put(BlockID.REDSTONE_WIRE, new BaseItem(ItemID.REDSTONE_DUST));
|
nonDataBlockBagItems.put(BlockID.PISTON_EXTENSION, doNotDestroy); // rule 7
|
||||||
nonDataBlockDrops.put(BlockID.DIAMOND_ORE, new BaseItem(ItemID.DIAMOND));
|
addIdentities(BlockID.CLOTH, 16); // rule 1
|
||||||
nonDataBlockDrops.put(BlockID.DIAMOND_BLOCK, new BaseItem(BlockID.DIAMOND_BLOCK));
|
nonDataBlockBagItems.put(BlockID.PISTON_MOVING_PIECE, doNotDestroy); // rule 7
|
||||||
nonDataBlockDrops.put(BlockID.WORKBENCH, new BaseItem(BlockID.WORKBENCH));
|
addIdentity(BlockID.YELLOW_FLOWER); // rule 1
|
||||||
nonDataBlockDrops.put(BlockID.CROPS, new BaseItem(ItemID.SEEDS));
|
addIdentity(BlockID.RED_FLOWER); // rule 1
|
||||||
nonDataBlockDrops.put(BlockID.SOIL, new BaseItem(BlockID.SOIL));
|
addIdentity(BlockID.BROWN_MUSHROOM); // rule 1
|
||||||
nonDataBlockDrops.put(BlockID.FURNACE, new BaseItem(BlockID.FURNACE));
|
addIdentity(BlockID.RED_MUSHROOM); // rule 1
|
||||||
nonDataBlockDrops.put(BlockID.BURNING_FURNACE, new BaseItem(BlockID.FURNACE));
|
addIdentity(BlockID.GOLD_BLOCK); // rule 1
|
||||||
nonDataBlockDrops.put(BlockID.SIGN_POST, new BaseItem(ItemID.SIGN));
|
addIdentity(BlockID.IRON_BLOCK); // rule 1
|
||||||
nonDataBlockDrops.put(BlockID.WOODEN_DOOR, new BaseItem(ItemID.WOODEN_DOOR_ITEM));
|
addIdentities(BlockID.DOUBLE_STEP, 7); // rule 3
|
||||||
nonDataBlockDrops.put(BlockID.LADDER, new BaseItem(BlockID.LADDER));
|
addIdentities(BlockID.STEP, 7); // rule 1
|
||||||
nonDataBlockDrops.put(BlockID.MINECART_TRACKS, new BaseItem(BlockID.MINECART_TRACKS));
|
addIdentity(BlockID.BRICK); // rule 1
|
||||||
nonDataBlockDrops.put(BlockID.COBBLESTONE_STAIRS, new BaseItem(BlockID.COBBLESTONE_STAIRS));
|
addIdentity(BlockID.TNT);
|
||||||
nonDataBlockDrops.put(BlockID.WALL_SIGN, new BaseItem(ItemID.SIGN));
|
addIdentity(BlockID.BOOKCASE); // rule 3
|
||||||
nonDataBlockDrops.put(BlockID.LEVER, new BaseItem(BlockID.LEVER));
|
addIdentity(BlockID.MOSSY_COBBLESTONE); // rule 1
|
||||||
nonDataBlockDrops.put(BlockID.STONE_PRESSURE_PLATE, new BaseItem(BlockID.STONE_PRESSURE_PLATE));
|
addIdentity(BlockID.OBSIDIAN); // rule 1
|
||||||
nonDataBlockDrops.put(BlockID.IRON_DOOR, new BaseItem(ItemID.IRON_DOOR_ITEM));
|
addIdentity(BlockID.TORCH); // rule 1
|
||||||
nonDataBlockDrops.put(BlockID.WOODEN_PRESSURE_PLATE, new BaseItem(BlockID.WOODEN_PRESSURE_PLATE));
|
// FIRE
|
||||||
nonDataBlockDrops.put(BlockID.REDSTONE_ORE, new BaseItem(ItemID.REDSTONE_DUST));
|
// MOB_SPAWNER
|
||||||
nonDataBlockDrops.put(BlockID.GLOWING_REDSTONE_ORE, new BaseItem(ItemID.REDSTONE_DUST));
|
addIdentity(BlockID.WOODEN_STAIRS); // rule 3
|
||||||
nonDataBlockDrops.put(BlockID.REDSTONE_TORCH_OFF, new BaseItem(BlockID.REDSTONE_TORCH_ON));
|
addIdentity(BlockID.CHEST); // rule 1
|
||||||
nonDataBlockDrops.put(BlockID.REDSTONE_TORCH_ON, new BaseItem(BlockID.REDSTONE_TORCH_ON));
|
nonDataBlockBagItems.put(BlockID.REDSTONE_WIRE, new BaseItem(ItemID.REDSTONE_DUST)); // rule 3
|
||||||
nonDataBlockDrops.put(BlockID.STONE_BUTTON, new BaseItem(BlockID.STONE_BUTTON));
|
nonDataBlockBagItems.put(BlockID.DIAMOND_ORE, new BaseItem(ItemID.DIAMOND)); // rule 5
|
||||||
nonDataBlockDrops.put(BlockID.SNOW, new BaseItem(ItemID.SNOWBALL));
|
addIdentity(BlockID.DIAMOND_BLOCK); // rule 1
|
||||||
nonDataBlockDrops.put(BlockID.ICE, new BaseItem(BlockID.ICE));
|
addIdentity(BlockID.WORKBENCH); // rule 1
|
||||||
nonDataBlockDrops.put(BlockID.SNOW_BLOCK, new BaseItem(BlockID.SNOW_BLOCK));
|
nonDataBlockBagItems.put(BlockID.CROPS, new BaseItem(ItemID.SEEDS)); // rule 3
|
||||||
nonDataBlockDrops.put(BlockID.CLAY, new BaseItem(BlockID.CLAY));
|
nonDataBlockBagItems.put(BlockID.SOIL, new BaseItem(BlockID.DIRT)); // rule 5
|
||||||
nonDataBlockDrops.put(BlockID.REED, new BaseItem(ItemID.SUGAR_CANE_ITEM));
|
addIdentity(BlockID.FURNACE); // rule 1
|
||||||
nonDataBlockDrops.put(BlockID.JUKEBOX, new BaseItem(BlockID.JUKEBOX));
|
nonDataBlockBagItems.put(BlockID.BURNING_FURNACE, new BaseItem(BlockID.FURNACE));
|
||||||
nonDataBlockDrops.put(BlockID.FENCE, new BaseItem(BlockID.FENCE));
|
nonDataBlockBagItems.put(BlockID.SIGN_POST, new BaseItem(ItemID.SIGN)); // rule 3
|
||||||
nonDataBlockDrops.put(BlockID.PUMPKIN, new BaseItem(BlockID.PUMPKIN));
|
addIdentities(BlockID.WOODEN_DOOR, 8); // rule 2
|
||||||
nonDataBlockDrops.put(BlockID.NETHERRACK, new BaseItem(BlockID.NETHERRACK));
|
addIdentity(BlockID.LADDER); // rule 1
|
||||||
nonDataBlockDrops.put(BlockID.SLOW_SAND, new BaseItem(BlockID.SLOW_SAND));
|
addIdentity(BlockID.MINECART_TRACKS); // rule 1
|
||||||
nonDataBlockDrops.put(BlockID.LIGHTSTONE, new BaseItem(ItemID.LIGHTSTONE_DUST));
|
addIdentity(BlockID.COBBLESTONE_STAIRS); // rule 3
|
||||||
nonDataBlockDrops.put(BlockID.JACKOLANTERN, new BaseItem(BlockID.JACKOLANTERN));
|
nonDataBlockBagItems.put(BlockID.WALL_SIGN, new BaseItem(ItemID.SIGN)); // rule 3
|
||||||
nonDataBlockDrops.put(BlockID.CAKE_BLOCK, new BaseItem(ItemID.CAKE_ITEM));
|
addIdentity(BlockID.LEVER); // rule 1
|
||||||
nonDataBlockDrops.put(BlockID.REDSTONE_REPEATER_OFF, new BaseItem(ItemID.REDSTONE_REPEATER));
|
addIdentity(BlockID.STONE_PRESSURE_PLATE); // rule 1
|
||||||
nonDataBlockDrops.put(BlockID.REDSTONE_REPEATER_ON, new BaseItem(ItemID.REDSTONE_REPEATER));
|
addIdentities(BlockID.IRON_DOOR, 8); // rule 2
|
||||||
nonDataBlockDrops.put(BlockID.LOCKED_CHEST, new BaseItem(BlockID.LOCKED_CHEST));
|
addIdentity(BlockID.WOODEN_PRESSURE_PLATE); // rule 1
|
||||||
nonDataBlockDrops.put(BlockID.TRAP_DOOR, new BaseItem(BlockID.TRAP_DOOR));
|
addIdentity(BlockID.REDSTONE_ORE); // rule 4
|
||||||
nonDataBlockDrops.put(BlockID.SILVERFISH_BLOCK, doNotDestroy);
|
nonDataBlockBagItems.put(BlockID.GLOWING_REDSTONE_ORE, new BaseItem(BlockID.REDSTONE_ORE)); // rule 4
|
||||||
nonDataBlockDrops.put(BlockID.STONE_BRICK, new BaseItem(BlockID.STONE_BRICK));
|
nonDataBlockBagItems.put(BlockID.REDSTONE_TORCH_OFF, new BaseItem(BlockID.REDSTONE_TORCH_ON)); // rule 3
|
||||||
nonDataBlockDrops.put(BlockID.BROWN_MUSHROOM_CAP, new BaseItem(BlockID.BROWN_MUSHROOM_CAP));
|
addIdentity(BlockID.REDSTONE_TORCH_ON); // rule 1
|
||||||
nonDataBlockDrops.put(BlockID.RED_MUSHROOM_CAP, new BaseItem(BlockID.RED_MUSHROOM_CAP));
|
addIdentity(BlockID.STONE_BUTTON); // rule 1
|
||||||
nonDataBlockDrops.put(BlockID.IRON_BARS, new BaseItem(BlockID.IRON_BARS));
|
addIdentity(BlockID.SNOW); // rule 1
|
||||||
nonDataBlockDrops.put(BlockID.GLASS_PANE, new BaseItem(BlockID.GLASS_PANE));
|
addIdentity(BlockID.ICE); // exception
|
||||||
nonDataBlockDrops.put(BlockID.MELON_BLOCK, new BaseItem(BlockID.MELON_BLOCK));
|
addIdentity(BlockID.SNOW_BLOCK); // rule 3
|
||||||
nonDataBlockDrops.put(BlockID.PUMPKIN_STEM, new BaseItem(BlockID.PUMPKIN_STEM));
|
addIdentity(BlockID.CACTUS);
|
||||||
nonDataBlockDrops.put(BlockID.MELON_STEM, new BaseItem(BlockID.MELON_STEM));
|
addIdentity(BlockID.CLAY); // rule 3
|
||||||
nonDataBlockDrops.put(BlockID.VINE, doNotDestroy);
|
nonDataBlockBagItems.put(BlockID.REED, new BaseItem(ItemID.SUGAR_CANE_ITEM)); // rule 3
|
||||||
nonDataBlockDrops.put(BlockID.FENCE_GATE, new BaseItem(BlockID.FENCE_GATE));
|
addIdentity(BlockID.JUKEBOX); // rule 1
|
||||||
nonDataBlockDrops.put(BlockID.BRICK_STAIRS, new BaseItem(BlockID.BRICK));
|
addIdentity(BlockID.FENCE); // rule 1
|
||||||
nonDataBlockDrops.put(BlockID.STONE_BRICK_STAIRS, new BaseItem(BlockID.STONE_BRICK));
|
addIdentity(BlockID.PUMPKIN); // rule 1
|
||||||
nonDataBlockDrops.put(BlockID.MYCELIUM, new BaseItem(BlockID.DIRT));
|
addIdentity(BlockID.NETHERRACK); // rule 1
|
||||||
nonDataBlockDrops.put(BlockID.LILY_PAD, new BaseItem(BlockID.LILY_PAD));
|
addIdentity(BlockID.SLOW_SAND); // rule 1
|
||||||
nonDataBlockDrops.put(BlockID.NETHER_BRICK, new BaseItem(BlockID.NETHER_BRICK));
|
addIdentity(BlockID.LIGHTSTONE); // rule 4
|
||||||
nonDataBlockDrops.put(BlockID.NETHER_BRICK_FENCE, new BaseItem(BlockID.NETHER_BRICK_FENCE));
|
// PORTAL
|
||||||
nonDataBlockDrops.put(BlockID.NETHER_BRICK_STAIRS, new BaseItem(BlockID.NETHER_BRICK));
|
addIdentity(BlockID.JACKOLANTERN); // rule 1
|
||||||
nonDataBlockDrops.put(BlockID.NETHER_WART, new BaseItem(ItemID.NETHER_WART_SEED));
|
nonDataBlockBagItems.put(BlockID.CAKE_BLOCK, new BaseItem(ItemID.CAKE_ITEM)); // rule 3
|
||||||
nonDataBlockDrops.put(BlockID.ENCHANTMENT_TABLE, new BaseItem(BlockID.ENCHANTMENT_TABLE));
|
nonDataBlockBagItems.put(BlockID.REDSTONE_REPEATER_OFF, new BaseItem(ItemID.REDSTONE_REPEATER)); // rule 3
|
||||||
nonDataBlockDrops.put(BlockID.BREWING_STAND, new BaseItem(ItemID.BREWING_STAND));
|
nonDataBlockBagItems.put(BlockID.REDSTONE_REPEATER_ON, new BaseItem(ItemID.REDSTONE_REPEATER)); // rule 3
|
||||||
nonDataBlockDrops.put(BlockID.CAULDRON, new BaseItem(ItemID.CAULDRON));
|
addIdentity(BlockID.LOCKED_CHEST); // ???
|
||||||
nonDataBlockDrops.put(BlockID.END_PORTAL, doNotDestroy);
|
addIdentity(BlockID.TRAP_DOOR); // rule 1
|
||||||
nonDataBlockDrops.put(BlockID.END_PORTAL_FRAME, doNotDestroy);
|
nonDataBlockBagItems.put(BlockID.SILVERFISH_BLOCK, doNotDestroy); // exception
|
||||||
nonDataBlockDrops.put(BlockID.END_STONE, new BaseItem(BlockID.END_STONE));
|
addIdentity(BlockID.STONE_BRICK); // rule 1
|
||||||
|
addIdentity(BlockID.BROWN_MUSHROOM_CAP);
|
||||||
|
addIdentity(BlockID.RED_MUSHROOM_CAP);
|
||||||
|
addIdentity(BlockID.IRON_BARS); // rule 1
|
||||||
|
addIdentity(BlockID.GLASS_PANE); // rule 1
|
||||||
|
addIdentity(BlockID.MELON_BLOCK); // rule 3
|
||||||
|
nonDataBlockBagItems.put(BlockID.PUMPKIN_STEM, new BaseItem(ItemID.PUMPKIN_SEEDS)); // rule 3
|
||||||
|
nonDataBlockBagItems.put(BlockID.MELON_STEM, new BaseItem(ItemID.MELON_SEEDS)); // rule 3
|
||||||
|
nonDataBlockBagItems.put(BlockID.VINE, doNotDestroy); // exception
|
||||||
|
addIdentity(BlockID.FENCE_GATE); // rule 1
|
||||||
|
addIdentity(BlockID.BRICK_STAIRS); // rule 3
|
||||||
|
addIdentity(BlockID.STONE_BRICK_STAIRS); // rule 3
|
||||||
|
|
||||||
|
// 1.9 blocks
|
||||||
|
nonDataBlockBagItems.put(BlockID.MYCELIUM, new BaseItem(BlockID.DIRT));
|
||||||
|
addIdentity(BlockID.LILY_PAD);
|
||||||
|
addIdentity(BlockID.NETHER_BRICK);
|
||||||
|
addIdentity(BlockID.NETHER_BRICK_FENCE);
|
||||||
|
addIdentity(BlockID.NETHER_BRICK_STAIRS);
|
||||||
|
nonDataBlockBagItems.put(BlockID.NETHER_WART, new BaseItem(ItemID.NETHER_WART_SEED));
|
||||||
|
addIdentity(BlockID.ENCHANTMENT_TABLE);
|
||||||
|
nonDataBlockBagItems.put(BlockID.BREWING_STAND, new BaseItem(ItemID.BREWING_STAND));
|
||||||
|
nonDataBlockBagItems.put(BlockID.CAULDRON, new BaseItem(ItemID.CAULDRON));
|
||||||
|
nonDataBlockBagItems.put(BlockID.END_PORTAL, doNotDestroy);
|
||||||
|
nonDataBlockBagItems.put(BlockID.END_PORTAL_FRAME, doNotDestroy);
|
||||||
|
addIdentity(BlockID.END_STONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the block or item that would have been dropped. If nothing is
|
* Get the block or item that this block can be constructed from. If nothing is
|
||||||
* dropped, a block with a BaseItemStack of type AIR and size 0 will be returned.
|
* dropped, a block with a BaseItemStack of type AIR and size 0 will be returned.
|
||||||
* If the block should not be destroyed (i.e. bedrock), null will be returned.
|
* If the block should not be destroyed (i.e. bedrock), null will be returned.
|
||||||
*
|
*
|
||||||
@ -984,11 +1009,11 @@ public enum BlockType {
|
|||||||
* @param data
|
* @param data
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static BaseItem getDroppedBlock(int type, int data) {
|
public static BaseItem getBlockBagItem(int type, int data) {
|
||||||
BaseItem dropped = nonDataBlockDrops.get(type);
|
BaseItem dropped = nonDataBlockBagItems.get(type);
|
||||||
if (dropped != null) return dropped;
|
if (dropped != null) return dropped;
|
||||||
|
|
||||||
dropped = dataBlockDrops.get(typeDataKey(type, data));
|
dropped = dataBlockBagItems.get(typeDataKey(type, data));
|
||||||
|
|
||||||
if (dropped == null) {
|
if (dropped == null) {
|
||||||
return new BaseItemStack(BlockID.AIR, 0);
|
return new BaseItemStack(BlockID.AIR, 0);
|
||||||
@ -1001,6 +1026,16 @@ public enum BlockType {
|
|||||||
return dropped;
|
return dropped;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void addIdentity(int type) {
|
||||||
|
nonDataBlockBagItems.put(type, new BaseItem(type));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void addIdentities(int type, int maxData) {
|
||||||
|
for (int data = 0; data < maxData; ++data) {
|
||||||
|
dataBlockBagItems.put(typeDataKey(type, data), new BaseItem(BlockID.LEAVES, (short) data));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the block or item that would have been dropped. If nothing is
|
* Get the block or item that would have been dropped. If nothing is
|
||||||
* dropped, 0 will be returned. If the block should not be destroyed
|
* dropped, 0 will be returned. If the block should not be destroyed
|
||||||
@ -1012,7 +1047,7 @@ public enum BlockType {
|
|||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public static int getDroppedBlock(int id) {
|
public static int getDroppedBlock(int id) {
|
||||||
BaseItem dropped = nonDataBlockDrops.get(id);
|
BaseItem dropped = nonDataBlockBagItems.get(id);
|
||||||
if (dropped == null) {
|
if (dropped == null) {
|
||||||
return BlockID.AIR;
|
return BlockID.AIR;
|
||||||
}
|
}
|
||||||
|
@ -26,6 +26,7 @@ import com.sk89q.worldedit.bags.*;
|
|||||||
import com.sk89q.worldedit.blocks.BaseItem;
|
import com.sk89q.worldedit.blocks.BaseItem;
|
||||||
import com.sk89q.worldedit.blocks.BaseItemStack;
|
import com.sk89q.worldedit.blocks.BaseItemStack;
|
||||||
import com.sk89q.worldedit.blocks.BlockID;
|
import com.sk89q.worldedit.blocks.BlockID;
|
||||||
|
import com.sk89q.worldedit.blocks.ItemType;
|
||||||
|
|
||||||
public class BukkitPlayerBlockBag extends BlockBag {
|
public class BukkitPlayerBlockBag extends BlockBag {
|
||||||
/**
|
/**
|
||||||
@ -121,7 +122,7 @@ public class BukkitPlayerBlockBag extends BlockBag {
|
|||||||
final int damage = item.getDamage();
|
final int damage = item.getDamage();
|
||||||
int amount = (item instanceof BaseItemStack) ? ((BaseItemStack) item).getAmount() : 1;
|
int amount = (item instanceof BaseItemStack) ? ((BaseItemStack) item).getAmount() : 1;
|
||||||
assert(amount <= 64);
|
assert(amount <= 64);
|
||||||
boolean usesDamageValue = false; // TODO: Use ItemType.usesDamageValue once it's fixed.
|
boolean usesDamageValue = ItemType.usesDamageValue(id);
|
||||||
|
|
||||||
if (id == BlockID.AIR) {
|
if (id == BlockID.AIR) {
|
||||||
throw new IllegalArgumentException("Can't store air block");
|
throw new IllegalArgumentException("Can't store air block");
|
||||||
@ -137,7 +138,7 @@ public class BukkitPlayerBlockBag extends BlockBag {
|
|||||||
if (bukkitItem == null) {
|
if (bukkitItem == null) {
|
||||||
// Delay using up a free slot until we know there are no stacks
|
// Delay using up a free slot until we know there are no stacks
|
||||||
// of this item to merge into
|
// of this item to merge into
|
||||||
|
|
||||||
if (freeSlot == -1) {
|
if (freeSlot == -1) {
|
||||||
freeSlot = slot;
|
freeSlot = slot;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user