Mirror von
https://github.com/IntellectualSites/FastAsyncWorldEdit.git
synchronisiert 2024-11-13 22:50:06 +01:00
Employed a set of consistent rules for getDroppedBlock(type, data) and renamed it to getBlockBagItem.
Dieser Commit ist enthalten in:
Ursprung
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:
|
||||||
|
*
|
||||||
|
* 1. block yields itself => addIdentity
|
||||||
|
* 2. block is part of a 2-block object => drop an appropriate item for one of the 2 blocks
|
||||||
|
* 3. block can be placed by right-clicking an obtainable item on the ground => use that item
|
||||||
|
* 4. block yields more than one item => addIdentity
|
||||||
|
* 5. block yields exactly one item => use that item
|
||||||
|
* 6. block is a liquid => drop nothing
|
||||||
|
* 7. block is created from thin air by the game other than by the map generator => drop nothing
|
||||||
|
*/
|
||||||
|
|
||||||
nonDataBlockDrops.put(BlockID.STONE, new BaseItem(BlockID.COBBLESTONE));
|
nonDataBlockBagItems.put(BlockID.STONE, new BaseItem(BlockID.COBBLESTONE)); // rule 5
|
||||||
nonDataBlockDrops.put(BlockID.GRASS, new BaseItem(BlockID.DIRT));
|
nonDataBlockBagItems.put(BlockID.GRASS, new BaseItem(BlockID.DIRT)); // rule 5
|
||||||
nonDataBlockDrops.put(BlockID.DIRT, new BaseItem(BlockID.DIRT));
|
addIdentity(BlockID.DIRT); // rule 1
|
||||||
nonDataBlockDrops.put(BlockID.COBBLESTONE, new BaseItem(BlockID.COBBLESTONE));
|
addIdentity(BlockID.COBBLESTONE); // rule 1
|
||||||
nonDataBlockDrops.put(BlockID.WOOD, new BaseItem(BlockID.WOOD));
|
addIdentity(BlockID.WOOD); // rule 1
|
||||||
nonDataBlockDrops.put(BlockID.SAPLING, new BaseItem(BlockID.SAPLING));
|
addIdentities(BlockID.SAPLING, 3); // rule 1
|
||||||
nonDataBlockDrops.put(BlockID.BEDROCK, doNotDestroy);
|
nonDataBlockBagItems.put(BlockID.BEDROCK, doNotDestroy); // exception
|
||||||
nonDataBlockDrops.put(BlockID.SAND, new BaseItem(BlockID.SAND));
|
// WATER, rule 6
|
||||||
nonDataBlockDrops.put(BlockID.GRAVEL, new BaseItem(BlockID.GRAVEL));
|
// STATIONARY_WATER, rule 6
|
||||||
nonDataBlockDrops.put(BlockID.GOLD_ORE, new BaseItem(BlockID.GOLD_ORE));
|
// LAVA, rule 6
|
||||||
nonDataBlockDrops.put(BlockID.IRON_ORE, new BaseItem(BlockID.IRON_ORE));
|
// STATIONARY_LAVA, rule 6
|
||||||
nonDataBlockDrops.put(BlockID.COAL_ORE, new BaseItem(BlockID.COAL_ORE));
|
addIdentity(BlockID.SAND); // rule 1
|
||||||
nonDataBlockDrops.put(BlockID.LOG, new BaseItem(BlockID.LOG));
|
addIdentity(BlockID.GRAVEL); // rule 1
|
||||||
nonDataBlockDrops.put(BlockID.LEAVES, new BaseItem(BlockID.LEAVES));
|
addIdentity(BlockID.GOLD_ORE); // rule 1
|
||||||
nonDataBlockDrops.put(BlockID.SPONGE, new BaseItem(BlockID.SPONGE));
|
addIdentity(BlockID.IRON_ORE); // rule 1
|
||||||
nonDataBlockDrops.put(BlockID.GLASS, new BaseItem(BlockID.GLASS)); // Have to drop glass for //undo
|
nonDataBlockBagItems.put(BlockID.COAL_ORE, new BaseItem(ItemID.COAL)); // rule 5
|
||||||
nonDataBlockDrops.put(BlockID.LAPIS_LAZULI_ORE, new BaseItem(BlockID.LAPIS_LAZULI_ORE)); // Block damage drops not implemented
|
addIdentities(BlockID.LOG, 3); // rule 1
|
||||||
nonDataBlockDrops.put(BlockID.LAPIS_LAZULI_BLOCK, new BaseItem(BlockID.LAPIS_LAZULI_BLOCK));
|
addIdentities(BlockID.LEAVES, 4); // rule 1 with shears, otherwise rule 3
|
||||||
nonDataBlockDrops.put(BlockID.DISPENSER, new BaseItem(BlockID.DISPENSER));
|
addIdentity(BlockID.SPONGE); // rule 1
|
||||||
nonDataBlockDrops.put(BlockID.SANDSTONE, new BaseItem(BlockID.SANDSTONE));
|
addIdentity(BlockID.GLASS); // rule 3
|
||||||
nonDataBlockDrops.put(BlockID.NOTE_BLOCK, new BaseItem(BlockID.NOTE_BLOCK));
|
addIdentity(BlockID.LAPIS_LAZULI_ORE); // rule 4
|
||||||
nonDataBlockDrops.put(BlockID.BED, new BaseItem(ItemID.BED_ITEM));
|
addIdentity(BlockID.LAPIS_LAZULI_BLOCK); // rule 1
|
||||||
nonDataBlockDrops.put(BlockID.POWERED_RAIL, new BaseItem(BlockID.POWERED_RAIL));
|
addIdentity(BlockID.DISPENSER); // rule 1
|
||||||
nonDataBlockDrops.put(BlockID.DETECTOR_RAIL, new BaseItem(BlockID.DETECTOR_RAIL));
|
addIdentity(BlockID.SANDSTONE); // rule 1
|
||||||
nonDataBlockDrops.put(BlockID.WEB, new BaseItem(BlockID.WEB));
|
addIdentity(BlockID.NOTE_BLOCK); // rule 1
|
||||||
nonDataBlockDrops.put(BlockID.PISTON_EXTENSION, doNotDestroy);
|
addIdentities(BlockID.BED, 8); // rule 2
|
||||||
nonDataBlockDrops.put(BlockID.CLOTH, new BaseItem(BlockID.CLOTH));
|
addIdentity(BlockID.POWERED_RAIL); // rule 1
|
||||||
nonDataBlockDrops.put(BlockID.PISTON_MOVING_PIECE, doNotDestroy);
|
addIdentity(BlockID.DETECTOR_RAIL); // rule 1
|
||||||
nonDataBlockDrops.put(BlockID.YELLOW_FLOWER, new BaseItem(BlockID.YELLOW_FLOWER));
|
addIdentity(BlockID.PISTON_STICKY_BASE);
|
||||||
nonDataBlockDrops.put(BlockID.RED_FLOWER, new BaseItem(BlockID.RED_FLOWER));
|
nonDataBlockBagItems.put(BlockID.WEB, new BaseItem(ItemID.STRING)); // rule 5
|
||||||
nonDataBlockDrops.put(BlockID.BROWN_MUSHROOM, new BaseItem(BlockID.BROWN_MUSHROOM));
|
// LONG_GRASS
|
||||||
nonDataBlockDrops.put(BlockID.RED_MUSHROOM, new BaseItem(BlockID.RED_MUSHROOM));
|
// DEAD_BUSH
|
||||||
nonDataBlockDrops.put(BlockID.GOLD_BLOCK, new BaseItem(BlockID.GOLD_BLOCK));
|
addIdentity(BlockID.PISTON_BASE);
|
||||||
nonDataBlockDrops.put(BlockID.IRON_BLOCK, new BaseItem(BlockID.IRON_BLOCK));
|
nonDataBlockBagItems.put(BlockID.PISTON_EXTENSION, doNotDestroy); // rule 7
|
||||||
nonDataBlockDrops.put(BlockID.DOUBLE_STEP, new BaseItem(BlockID.DOUBLE_STEP));
|
addIdentities(BlockID.CLOTH, 16); // rule 1
|
||||||
nonDataBlockDrops.put(BlockID.STEP, new BaseItem(BlockID.STEP));
|
nonDataBlockBagItems.put(BlockID.PISTON_MOVING_PIECE, doNotDestroy); // rule 7
|
||||||
nonDataBlockDrops.put(BlockID.BRICK, new BaseItem(BlockID.BRICK));
|
addIdentity(BlockID.YELLOW_FLOWER); // rule 1
|
||||||
nonDataBlockDrops.put(BlockID.BOOKCASE, new BaseItem(BlockID.BOOKCASE));
|
addIdentity(BlockID.RED_FLOWER); // rule 1
|
||||||
nonDataBlockDrops.put(BlockID.MOSSY_COBBLESTONE, new BaseItem(BlockID.MOSSY_COBBLESTONE));
|
addIdentity(BlockID.BROWN_MUSHROOM); // rule 1
|
||||||
nonDataBlockDrops.put(BlockID.OBSIDIAN, new BaseItem(BlockID.OBSIDIAN));
|
addIdentity(BlockID.RED_MUSHROOM); // rule 1
|
||||||
nonDataBlockDrops.put(BlockID.TORCH, new BaseItem(BlockID.TORCH));
|
addIdentity(BlockID.GOLD_BLOCK); // rule 1
|
||||||
nonDataBlockDrops.put(BlockID.WOODEN_STAIRS, new BaseItem(BlockID.WOODEN_STAIRS));
|
addIdentity(BlockID.IRON_BLOCK); // rule 1
|
||||||
nonDataBlockDrops.put(BlockID.CHEST, new BaseItem(BlockID.CHEST));
|
addIdentities(BlockID.DOUBLE_STEP, 7); // rule 3
|
||||||
nonDataBlockDrops.put(BlockID.REDSTONE_WIRE, new BaseItem(ItemID.REDSTONE_DUST));
|
addIdentities(BlockID.STEP, 7); // rule 1
|
||||||
nonDataBlockDrops.put(BlockID.DIAMOND_ORE, new BaseItem(ItemID.DIAMOND));
|
addIdentity(BlockID.BRICK); // rule 1
|
||||||
nonDataBlockDrops.put(BlockID.DIAMOND_BLOCK, new BaseItem(BlockID.DIAMOND_BLOCK));
|
addIdentity(BlockID.TNT);
|
||||||
nonDataBlockDrops.put(BlockID.WORKBENCH, new BaseItem(BlockID.WORKBENCH));
|
addIdentity(BlockID.BOOKCASE); // rule 3
|
||||||
nonDataBlockDrops.put(BlockID.CROPS, new BaseItem(ItemID.SEEDS));
|
addIdentity(BlockID.MOSSY_COBBLESTONE); // rule 1
|
||||||
nonDataBlockDrops.put(BlockID.SOIL, new BaseItem(BlockID.SOIL));
|
addIdentity(BlockID.OBSIDIAN); // rule 1
|
||||||
nonDataBlockDrops.put(BlockID.FURNACE, new BaseItem(BlockID.FURNACE));
|
addIdentity(BlockID.TORCH); // rule 1
|
||||||
nonDataBlockDrops.put(BlockID.BURNING_FURNACE, new BaseItem(BlockID.FURNACE));
|
// FIRE
|
||||||
nonDataBlockDrops.put(BlockID.SIGN_POST, new BaseItem(ItemID.SIGN));
|
// MOB_SPAWNER
|
||||||
nonDataBlockDrops.put(BlockID.WOODEN_DOOR, new BaseItem(ItemID.WOODEN_DOOR_ITEM));
|
addIdentity(BlockID.WOODEN_STAIRS); // rule 3
|
||||||
nonDataBlockDrops.put(BlockID.LADDER, new BaseItem(BlockID.LADDER));
|
addIdentity(BlockID.CHEST); // rule 1
|
||||||
nonDataBlockDrops.put(BlockID.MINECART_TRACKS, new BaseItem(BlockID.MINECART_TRACKS));
|
nonDataBlockBagItems.put(BlockID.REDSTONE_WIRE, new BaseItem(ItemID.REDSTONE_DUST)); // rule 3
|
||||||
nonDataBlockDrops.put(BlockID.COBBLESTONE_STAIRS, new BaseItem(BlockID.COBBLESTONE_STAIRS));
|
nonDataBlockBagItems.put(BlockID.DIAMOND_ORE, new BaseItem(ItemID.DIAMOND)); // rule 5
|
||||||
nonDataBlockDrops.put(BlockID.WALL_SIGN, new BaseItem(ItemID.SIGN));
|
addIdentity(BlockID.DIAMOND_BLOCK); // rule 1
|
||||||
nonDataBlockDrops.put(BlockID.LEVER, new BaseItem(BlockID.LEVER));
|
addIdentity(BlockID.WORKBENCH); // rule 1
|
||||||
nonDataBlockDrops.put(BlockID.STONE_PRESSURE_PLATE, new BaseItem(BlockID.STONE_PRESSURE_PLATE));
|
nonDataBlockBagItems.put(BlockID.CROPS, new BaseItem(ItemID.SEEDS)); // rule 3
|
||||||
nonDataBlockDrops.put(BlockID.IRON_DOOR, new BaseItem(ItemID.IRON_DOOR_ITEM));
|
nonDataBlockBagItems.put(BlockID.SOIL, new BaseItem(BlockID.DIRT)); // rule 5
|
||||||
nonDataBlockDrops.put(BlockID.WOODEN_PRESSURE_PLATE, new BaseItem(BlockID.WOODEN_PRESSURE_PLATE));
|
addIdentity(BlockID.FURNACE); // rule 1
|
||||||
nonDataBlockDrops.put(BlockID.REDSTONE_ORE, new BaseItem(ItemID.REDSTONE_DUST));
|
nonDataBlockBagItems.put(BlockID.BURNING_FURNACE, new BaseItem(BlockID.FURNACE));
|
||||||
nonDataBlockDrops.put(BlockID.GLOWING_REDSTONE_ORE, new BaseItem(ItemID.REDSTONE_DUST));
|
nonDataBlockBagItems.put(BlockID.SIGN_POST, new BaseItem(ItemID.SIGN)); // rule 3
|
||||||
nonDataBlockDrops.put(BlockID.REDSTONE_TORCH_OFF, new BaseItem(BlockID.REDSTONE_TORCH_ON));
|
addIdentities(BlockID.WOODEN_DOOR, 8); // rule 2
|
||||||
nonDataBlockDrops.put(BlockID.REDSTONE_TORCH_ON, new BaseItem(BlockID.REDSTONE_TORCH_ON));
|
addIdentity(BlockID.LADDER); // rule 1
|
||||||
nonDataBlockDrops.put(BlockID.STONE_BUTTON, new BaseItem(BlockID.STONE_BUTTON));
|
addIdentity(BlockID.MINECART_TRACKS); // rule 1
|
||||||
nonDataBlockDrops.put(BlockID.SNOW, new BaseItem(ItemID.SNOWBALL));
|
addIdentity(BlockID.COBBLESTONE_STAIRS); // rule 3
|
||||||
nonDataBlockDrops.put(BlockID.ICE, new BaseItem(BlockID.ICE));
|
nonDataBlockBagItems.put(BlockID.WALL_SIGN, new BaseItem(ItemID.SIGN)); // rule 3
|
||||||
nonDataBlockDrops.put(BlockID.SNOW_BLOCK, new BaseItem(BlockID.SNOW_BLOCK));
|
addIdentity(BlockID.LEVER); // rule 1
|
||||||
nonDataBlockDrops.put(BlockID.CLAY, new BaseItem(BlockID.CLAY));
|
addIdentity(BlockID.STONE_PRESSURE_PLATE); // rule 1
|
||||||
nonDataBlockDrops.put(BlockID.REED, new BaseItem(ItemID.SUGAR_CANE_ITEM));
|
addIdentities(BlockID.IRON_DOOR, 8); // rule 2
|
||||||
nonDataBlockDrops.put(BlockID.JUKEBOX, new BaseItem(BlockID.JUKEBOX));
|
addIdentity(BlockID.WOODEN_PRESSURE_PLATE); // rule 1
|
||||||
nonDataBlockDrops.put(BlockID.FENCE, new BaseItem(BlockID.FENCE));
|
addIdentity(BlockID.REDSTONE_ORE); // rule 4
|
||||||
nonDataBlockDrops.put(BlockID.PUMPKIN, new BaseItem(BlockID.PUMPKIN));
|
nonDataBlockBagItems.put(BlockID.GLOWING_REDSTONE_ORE, new BaseItem(BlockID.REDSTONE_ORE)); // rule 4
|
||||||
nonDataBlockDrops.put(BlockID.NETHERRACK, new BaseItem(BlockID.NETHERRACK));
|
nonDataBlockBagItems.put(BlockID.REDSTONE_TORCH_OFF, new BaseItem(BlockID.REDSTONE_TORCH_ON)); // rule 3
|
||||||
nonDataBlockDrops.put(BlockID.SLOW_SAND, new BaseItem(BlockID.SLOW_SAND));
|
addIdentity(BlockID.REDSTONE_TORCH_ON); // rule 1
|
||||||
nonDataBlockDrops.put(BlockID.LIGHTSTONE, new BaseItem(ItemID.LIGHTSTONE_DUST));
|
addIdentity(BlockID.STONE_BUTTON); // rule 1
|
||||||
nonDataBlockDrops.put(BlockID.JACKOLANTERN, new BaseItem(BlockID.JACKOLANTERN));
|
addIdentity(BlockID.SNOW); // rule 1
|
||||||
nonDataBlockDrops.put(BlockID.CAKE_BLOCK, new BaseItem(ItemID.CAKE_ITEM));
|
addIdentity(BlockID.ICE); // exception
|
||||||
nonDataBlockDrops.put(BlockID.REDSTONE_REPEATER_OFF, new BaseItem(ItemID.REDSTONE_REPEATER));
|
addIdentity(BlockID.SNOW_BLOCK); // rule 3
|
||||||
nonDataBlockDrops.put(BlockID.REDSTONE_REPEATER_ON, new BaseItem(ItemID.REDSTONE_REPEATER));
|
addIdentity(BlockID.CACTUS);
|
||||||
nonDataBlockDrops.put(BlockID.LOCKED_CHEST, new BaseItem(BlockID.LOCKED_CHEST));
|
addIdentity(BlockID.CLAY); // rule 3
|
||||||
nonDataBlockDrops.put(BlockID.TRAP_DOOR, new BaseItem(BlockID.TRAP_DOOR));
|
nonDataBlockBagItems.put(BlockID.REED, new BaseItem(ItemID.SUGAR_CANE_ITEM)); // rule 3
|
||||||
nonDataBlockDrops.put(BlockID.SILVERFISH_BLOCK, doNotDestroy);
|
addIdentity(BlockID.JUKEBOX); // rule 1
|
||||||
nonDataBlockDrops.put(BlockID.STONE_BRICK, new BaseItem(BlockID.STONE_BRICK));
|
addIdentity(BlockID.FENCE); // rule 1
|
||||||
nonDataBlockDrops.put(BlockID.BROWN_MUSHROOM_CAP, new BaseItem(BlockID.BROWN_MUSHROOM_CAP));
|
addIdentity(BlockID.PUMPKIN); // rule 1
|
||||||
nonDataBlockDrops.put(BlockID.RED_MUSHROOM_CAP, new BaseItem(BlockID.RED_MUSHROOM_CAP));
|
addIdentity(BlockID.NETHERRACK); // rule 1
|
||||||
nonDataBlockDrops.put(BlockID.IRON_BARS, new BaseItem(BlockID.IRON_BARS));
|
addIdentity(BlockID.SLOW_SAND); // rule 1
|
||||||
nonDataBlockDrops.put(BlockID.GLASS_PANE, new BaseItem(BlockID.GLASS_PANE));
|
addIdentity(BlockID.LIGHTSTONE); // rule 4
|
||||||
nonDataBlockDrops.put(BlockID.MELON_BLOCK, new BaseItem(BlockID.MELON_BLOCK));
|
// PORTAL
|
||||||
nonDataBlockDrops.put(BlockID.PUMPKIN_STEM, new BaseItem(BlockID.PUMPKIN_STEM));
|
addIdentity(BlockID.JACKOLANTERN); // rule 1
|
||||||
nonDataBlockDrops.put(BlockID.MELON_STEM, new BaseItem(BlockID.MELON_STEM));
|
nonDataBlockBagItems.put(BlockID.CAKE_BLOCK, new BaseItem(ItemID.CAKE_ITEM)); // rule 3
|
||||||
nonDataBlockDrops.put(BlockID.VINE, doNotDestroy);
|
nonDataBlockBagItems.put(BlockID.REDSTONE_REPEATER_OFF, new BaseItem(ItemID.REDSTONE_REPEATER)); // rule 3
|
||||||
nonDataBlockDrops.put(BlockID.FENCE_GATE, new BaseItem(BlockID.FENCE_GATE));
|
nonDataBlockBagItems.put(BlockID.REDSTONE_REPEATER_ON, new BaseItem(ItemID.REDSTONE_REPEATER)); // rule 3
|
||||||
nonDataBlockDrops.put(BlockID.BRICK_STAIRS, new BaseItem(BlockID.BRICK));
|
addIdentity(BlockID.LOCKED_CHEST); // ???
|
||||||
nonDataBlockDrops.put(BlockID.STONE_BRICK_STAIRS, new BaseItem(BlockID.STONE_BRICK));
|
addIdentity(BlockID.TRAP_DOOR); // rule 1
|
||||||
nonDataBlockDrops.put(BlockID.MYCELIUM, new BaseItem(BlockID.DIRT));
|
nonDataBlockBagItems.put(BlockID.SILVERFISH_BLOCK, doNotDestroy); // exception
|
||||||
nonDataBlockDrops.put(BlockID.LILY_PAD, new BaseItem(BlockID.LILY_PAD));
|
addIdentity(BlockID.STONE_BRICK); // rule 1
|
||||||
nonDataBlockDrops.put(BlockID.NETHER_BRICK, new BaseItem(BlockID.NETHER_BRICK));
|
addIdentity(BlockID.BROWN_MUSHROOM_CAP);
|
||||||
nonDataBlockDrops.put(BlockID.NETHER_BRICK_FENCE, new BaseItem(BlockID.NETHER_BRICK_FENCE));
|
addIdentity(BlockID.RED_MUSHROOM_CAP);
|
||||||
nonDataBlockDrops.put(BlockID.NETHER_BRICK_STAIRS, new BaseItem(BlockID.NETHER_BRICK));
|
addIdentity(BlockID.IRON_BARS); // rule 1
|
||||||
nonDataBlockDrops.put(BlockID.NETHER_WART, new BaseItem(ItemID.NETHER_WART_SEED));
|
addIdentity(BlockID.GLASS_PANE); // rule 1
|
||||||
nonDataBlockDrops.put(BlockID.ENCHANTMENT_TABLE, new BaseItem(BlockID.ENCHANTMENT_TABLE));
|
addIdentity(BlockID.MELON_BLOCK); // rule 3
|
||||||
nonDataBlockDrops.put(BlockID.BREWING_STAND, new BaseItem(ItemID.BREWING_STAND));
|
nonDataBlockBagItems.put(BlockID.PUMPKIN_STEM, new BaseItem(ItemID.PUMPKIN_SEEDS)); // rule 3
|
||||||
nonDataBlockDrops.put(BlockID.CAULDRON, new BaseItem(ItemID.CAULDRON));
|
nonDataBlockBagItems.put(BlockID.MELON_STEM, new BaseItem(ItemID.MELON_SEEDS)); // rule 3
|
||||||
nonDataBlockDrops.put(BlockID.END_PORTAL, doNotDestroy);
|
nonDataBlockBagItems.put(BlockID.VINE, doNotDestroy); // exception
|
||||||
nonDataBlockDrops.put(BlockID.END_PORTAL_FRAME, doNotDestroy);
|
addIdentity(BlockID.FENCE_GATE); // rule 1
|
||||||
nonDataBlockDrops.put(BlockID.END_STONE, new BaseItem(BlockID.END_STONE));
|
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");
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren