Permalink
Browse files

Continue moving out of legacy BlockType

  • Loading branch information...
me4502 committed Jul 2, 2018
1 parent b205d30 commit 35dd54b91e3048f8a7c366565ad397cfa527326f
@@ -379,9 +379,7 @@ public boolean setBlock(Vector position, BlockStateHolder block, boolean notifyA
@Override
public LazyBlock getLazyBlock(Vector position) {
World world = getWorld();
Block bukkitBlock = world.getBlockAt(position.getBlockX(), position.getBlockY(), position.getBlockZ());
return new LazyBlock(bukkitBlock.getTypeId(), bukkitBlock.getData(), this, position);
return new LazyBlock(getBlock(position), this, position);
}
@Override
@@ -390,8 +388,7 @@ public BaseBlock getFullBlock(Vector position) {
if (adapter != null) {
return adapter.getBlock(BukkitAdapter.adapt(getWorld(), position));
} else {
Block bukkitBlock = getWorld().getBlockAt(position.getBlockX(), position.getBlockY(), position.getBlockZ());
return new BaseBlock(bukkitBlock.getTypeId(), bukkitBlock.getData());
return new BaseBlock(getBlock(position));
}
}
@@ -1529,7 +1529,7 @@ public int simulateSnow(Vector position, double radius) throws MaxChangedBlocksE
}
// Snow should not cover these blocks
if (BlockType.isTranslucent(id.getLegacyId())) {
if (id.getMaterial().isTranslucent()) {
// Add snow on leaves
if (BlockCategories.LEAVES.contains(id)) {
break;
@@ -114,19 +114,6 @@ public BaseBlock(int id, int data) {
this(id);
}
/**
* Construct a block with the given ID, data value and NBT data structure.
*
* @param id ID value
* @param data data value
* @param nbtData NBT data, which may be null
*/
@Deprecated
public BaseBlock(int id, int data, @Nullable CompoundTag nbtData) {
this(id);
this.nbtData = nbtData;
}
/**
* Create a clone of another block.
*
@@ -136,16 +123,6 @@ public BaseBlock(BaseBlock other) {
this(other.toImmutableState(), other.getNbtData());
}
/**
* Get the legacy numerical ID of the block.
*
* @return legacy numerical ID
*/
@Deprecated
public int getId() {
return this.blockState.getBlockType().getLegacyId();
}
/**
* Get the block's data value.
*
@@ -32,23 +32,18 @@
public static final int DIRT = 3;
public static final int SAPLING = 6;
public static final int BEDROCK = 7;
public static final int WATER = 8; // FLOWING_WATER
public static final int STATIONARY_WATER = 9; // WATER
public static final int SAND = 12;
public static final int GRAVEL = 13;
public static final int GOLD_ORE = 14;
public static final int IRON_ORE = 15;
public static final int COAL_ORE = 16;
public static final int LOG = 17;
public static final int LEAVES = 18;
public static final int GLASS = 20;
public static final int LAPIS_LAZULI_ORE = 21; // LAPIS_ORE
public static final int DISPENSER = 23;
public static final int BED = 26;
public static final int POWERED_RAIL = 27; // GOLDEN_RAIL
public static final int DETECTOR_RAIL = 28;
public static final int PISTON_STICKY_BASE = 29; // STICKY_PISTON
public static final int WEB = 30;
public static final int LONG_GRASS = 31; // TALLGRASS
public static final int DEAD_BUSH = 32; // DEADBUSH
public static final int PISTON_BASE = 33; // PISTON
@@ -62,7 +57,6 @@
public static final int TNT = 46;
public static final int TORCH = 50;
public static final int FIRE = 51;
public static final int MOB_SPAWNER = 52;
@Deprecated
public static final int WOODEN_STAIRS = 53;
public static final int OAK_WOOD_STAIRS = 53; // OAK_STAIRS
@@ -88,7 +82,6 @@
public static final int REDSTONE_TORCH_ON = 76; // LIT_REDSTONE_TORCH
public static final int STONE_BUTTON = 77;
public static final int SNOW = 78; // SNOW_LAYER
public static final int ICE = 79;
public static final int CACTUS = 81;
public static final int CLAY = 82;
public static final int REED = 83; // REEDS
@@ -109,8 +102,6 @@
public static final int TRAP_DOOR = 96; // TRAPDOOR
public static final int BROWN_MUSHROOM_CAP = 99; // BROWN_MUSHROOM_BLOCK
public static final int RED_MUSHROOM_CAP = 100; // RED_MUSHROOM_BLOCK
public static final int IRON_BARS = 101;
public static final int GLASS_PANE = 102;
public static final int PUMPKIN_STEM = 104;
public static final int MELON_STEM = 105;
public static final int VINE = 106;
@@ -119,7 +110,6 @@
public static final int STONE_BRICK_STAIRS = 109;
public static final int MYCELIUM = 110;
public static final int LILY_PAD = 111; // WATERLILY
public static final int NETHER_BRICK_FENCE = 113;
public static final int NETHER_BRICK_STAIRS = 114;
public static final int NETHER_WART = 115;
public static final int ENCHANTMENT_TABLE = 116; // ENCHANTING_TABLE
@@ -155,12 +145,9 @@
public static final int ACTIVATOR_RAIL = 157;
public static final int DROPPER = 158;
public static final int STAINED_CLAY = 159; // STAINED_HARDENED_CLAY
public static final int STAINED_GLASS_PANE = 160;
public static final int LEAVES2 = 161;
public static final int LOG2 = 162;
public static final int ACACIA_STAIRS = 163;
public static final int DARK_OAK_STAIRS = 164;
public static final int BARRIER = 166;
public static final int IRON_TRAP_DOOR = 167;
public static final int HAY_BLOCK = 170;
public static final int CARPET = 171;
@@ -169,29 +156,12 @@
public static final int STANDING_BANNER = 176;
public static final int WALL_BANNER = 177;
public static final int DAYLIGHT_SENSOR_INVERTED = 178;
public static final int RED_SANDSTONE_STAIRS = 180;
public static final int STEP2 = 182;
public static final int SPRUCE_FENCE_GATE = 183;
public static final int BIRCH_FENCE_GATE = 184;
public static final int JUNGLE_FENCE_GATE = 185;
public static final int DARK_OAK_FENCE_GATE = 186;
public static final int ACACIA_FENCE_GATE = 187;
public static final int SPRUCE_FENCE = 188;
public static final int BIRCH_FENCE = 189;
public static final int JUNGLE_FENCE = 190;
public static final int DARK_OAK_FENCE = 191;
public static final int ACACIA_FENCE = 192;
public static final int SPRUCE_DOOR = 193;
public static final int BIRCH_DOOR = 194;
public static final int JUNGLE_DOOR = 195;
public static final int ACACIA_DOOR = 196;
public static final int DARK_OAK_DOOR = 197;
public static final int END_ROD = 198;
public static final int CHORUS_PLANT = 199;
public static final int CHORUS_FLOWER = 200;
public static final int PURPUR_STAIRS = 203;
public static final int PURPUR_SLAB = 205;
public static final int BEETROOTS = 207;
private BlockID() {
}
@@ -180,4 +180,17 @@
*/
boolean isReplacedDuringPlacement();
/**
* Get whether this block is translucent.
*
* @return true if the block is translucent
*/
boolean isTranslucent();
/**
* Gets whether the block has a container (Item container)
*
* @return If it has a container
*/
boolean hasContainer();
}
@@ -232,32 +232,6 @@ public static double centralTopLimit(BlockStateHolder block) {
return centralTopLimit(block.getBlockType().getLegacyId(), 0);
}
/**
* HashSet for isContainerBlock.
*/
private static final Set<Integer> isContainerBlock = new HashSet<>();
static {
isContainerBlock.add(BlockID.DISPENSER);
isContainerBlock.add(BlockID.FURNACE);
isContainerBlock.add(BlockID.BURNING_FURNACE);
isContainerBlock.add(BlockID.CHEST);
isContainerBlock.add(BlockID.BREWING_STAND);
isContainerBlock.add(BlockID.TRAPPED_CHEST);
isContainerBlock.add(BlockID.HOPPER);
isContainerBlock.add(BlockID.DROPPER);
//isContainerBlock.add(BlockID.ENDER_CHEST); // ender chest has no own inventory, don't add this here
}
/**
* Returns true if the block is a container block.
*
* @param id the block ID
* @return true if the block is a container
*/
public static boolean isContainerBlock(int id) {
return isContainerBlock.contains(id);
}
/**
* HashSet for isNaturalBlock.
*/
@@ -292,18 +266,6 @@ public static boolean isContainerBlock(int id) {
isNaturalTerrainBlock.add(BlockID.EMERALD_ORE);
}
/**
* Checks if the block type is naturally occurring.
*
* @param id the type ID of the block
* @return true if the block type is naturally occurring
* @deprecated Use {@link #isNaturalTerrainBlock(int, int)}
*/
@Deprecated
public static boolean isNaturalTerrainBlock(int id) {
return isNaturalTerrainBlock.contains(id);
}
/**
* Checks if the block type is naturally occurring
*
@@ -315,148 +277,6 @@ public static boolean isNaturalTerrainBlock(int id, int data) {
return isNaturalTerrainBlock.contains(-16*id-data) || isNaturalTerrainBlock.contains(id);
}
/**
* HashSet for isTranslucent.
*/
private static final Set<Integer> 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.STEP);
isTranslucent.add(BlockID.TORCH);
isTranslucent.add(BlockID.FIRE);
isTranslucent.add(BlockID.MOB_SPAWNER);
isTranslucent.add(BlockID.OAK_WOOD_STAIRS);
isTranslucent.add(BlockID.CHEST);
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);
isTranslucent.add(BlockID.LILY_PAD);
isTranslucent.add(BlockID.NETHER_BRICK_FENCE);
isTranslucent.add(BlockID.NETHER_BRICK_STAIRS);
isTranslucent.add(BlockID.NETHER_WART);
isTranslucent.add(BlockID.ENCHANTMENT_TABLE);
isTranslucent.add(BlockID.BREWING_STAND);
isTranslucent.add(BlockID.CAULDRON);
isTranslucent.add(BlockID.WOODEN_STEP);
isTranslucent.add(BlockID.COCOA_PLANT);
isTranslucent.add(BlockID.SANDSTONE_STAIRS);
isTranslucent.add(BlockID.ENDER_CHEST);
isTranslucent.add(BlockID.TRIPWIRE_HOOK);
isTranslucent.add(BlockID.TRIPWIRE);
isTranslucent.add(BlockID.SPRUCE_WOOD_STAIRS);
isTranslucent.add(BlockID.BIRCH_WOOD_STAIRS);
isTranslucent.add(BlockID.JUNGLE_WOOD_STAIRS);
isTranslucent.add(BlockID.COBBLESTONE_WALL);
isTranslucent.add(BlockID.FLOWER_POT);
isTranslucent.add(BlockID.CARROTS);
isTranslucent.add(BlockID.POTATOES);
isTranslucent.add(BlockID.WOODEN_BUTTON);
isTranslucent.add(BlockID.HEAD);
isTranslucent.add(BlockID.ANVIL);
isTranslucent.add(BlockID.TRAPPED_CHEST);
isTranslucent.add(BlockID.PRESSURE_PLATE_LIGHT);
isTranslucent.add(BlockID.PRESSURE_PLATE_HEAVY);
isTranslucent.add(BlockID.COMPARATOR_OFF);
isTranslucent.add(BlockID.COMPARATOR_ON);
isTranslucent.add(BlockID.DAYLIGHT_SENSOR);
isTranslucent.add(BlockID.HOPPER);
isTranslucent.add(BlockID.QUARTZ_STAIRS);
isTranslucent.add(BlockID.ACTIVATOR_RAIL);
isTranslucent.add(BlockID.ACACIA_STAIRS);
isTranslucent.add(BlockID.DARK_OAK_STAIRS);
isTranslucent.add(BlockID.BARRIER);
isTranslucent.add(BlockID.IRON_TRAP_DOOR);
isTranslucent.add(BlockID.CARPET);
isTranslucent.add(BlockID.LEAVES2);
isTranslucent.add(BlockID.STAINED_GLASS_PANE);
isTranslucent.add(BlockID.DOUBLE_PLANT);
isTranslucent.add(BlockID.STANDING_BANNER);
isTranslucent.add(BlockID.WALL_BANNER);
isTranslucent.add(BlockID.DAYLIGHT_SENSOR_INVERTED);
isTranslucent.add(BlockID.RED_SANDSTONE_STAIRS);
isTranslucent.add(BlockID.STEP2);
isTranslucent.add(BlockID.SPRUCE_FENCE_GATE);
isTranslucent.add(BlockID.BIRCH_FENCE_GATE);
isTranslucent.add(BlockID.JUNGLE_FENCE_GATE);
isTranslucent.add(BlockID.DARK_OAK_FENCE_GATE);
isTranslucent.add(BlockID.ACACIA_FENCE_GATE);
isTranslucent.add(BlockID.SPRUCE_FENCE);
isTranslucent.add(BlockID.BIRCH_FENCE);
isTranslucent.add(BlockID.JUNGLE_FENCE);
isTranslucent.add(BlockID.DARK_OAK_FENCE);
isTranslucent.add(BlockID.ACACIA_FENCE);
isTranslucent.add(BlockID.SPRUCE_DOOR);
isTranslucent.add(BlockID.BIRCH_DOOR);
isTranslucent.add(BlockID.JUNGLE_DOOR);
isTranslucent.add(BlockID.ACACIA_DOOR);
isTranslucent.add(BlockID.DARK_OAK_DOOR);
isTranslucent.add(BlockID.END_ROD);
isTranslucent.add(BlockID.CHORUS_PLANT);
isTranslucent.add(BlockID.CHORUS_FLOWER);
isTranslucent.add(BlockID.PURPUR_STAIRS);
isTranslucent.add(BlockID.PURPUR_SLAB);
isTranslucent.add(BlockID.BEETROOTS);
}
/**
* Checks if the block type lets light through.
*
* @param id the type ID of the block
* @return true if the block type lets light through
*/
public static boolean isTranslucent(int id) {
return isTranslucent.contains(id);
}
private static final Map<Integer, PlayerDirection> dataAttachments = new HashMap<>();
private static final Map<Integer, PlayerDirection> nonDataAttachments = new HashMap<>();
static {
@@ -21,7 +21,6 @@
import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.blocks.BaseBlock;
import com.sk89q.worldedit.blocks.type.BlockStateHolder;
import com.sk89q.worldedit.blocks.type.BlockType;
import com.sk89q.worldedit.extent.AbstractDelegateExtent;
Oops, something went wrong.

0 comments on commit 35dd54b

Please sign in to comment.