Remove string switches for BlockType

This commit is contained in:
Jesse Boyd
2019-04-06 03:34:11 +11:00
parent d49c5ebe74
commit 0afae082c2
12 changed files with 293 additions and 244 deletions

View File

@ -36,30 +36,30 @@ public class BlockTypeUtil {
public static double centralBottomLimit(BlockStateHolder block) {
checkNotNull(block);
BlockType type = block.getBlockType();
switch (type.getResource().toUpperCase()) {
case "CREEPER_WALL_HEAD":
case "DRAGON_WALL_HEAD":
case "PLAYER_WALL_HEAD":
case "ZOMBIE_WALL_HEAD": return 0.25;
case "ACACIA_SLAB":
case "BIRCH_SLAB":
case "BRICK_SLAB":
case "COBBLESTONE_SLAB":
case "DARK_OAK_SLAB":
case "DARK_PRISMARINE_SLAB":
case "JUNGLE_SLAB":
case "NETHER_BRICK_SLAB":
case "OAK_SLAB":
case "PETRIFIED_OAK_SLAB":
case "PRISMARINE_BRICK_SLAB":
case "PRISMARINE_SLAB":
case "PURPUR_SLAB":
case "QUARTZ_SLAB":
case "RED_SANDSTONE_SLAB":
case "SANDSTONE_SLAB":
case "SPRUCE_SLAB":
case "STONE_BRICK_SLAB":
case "STONE_SLAB": {
switch (type.getInternalId()) {
case BlockID.CREEPER_WALL_HEAD:
case BlockID.DRAGON_WALL_HEAD:
case BlockID.PLAYER_WALL_HEAD:
case BlockID.ZOMBIE_WALL_HEAD: return 0.25;
case BlockID.ACACIA_SLAB:
case BlockID.BIRCH_SLAB:
case BlockID.BRICK_SLAB:
case BlockID.COBBLESTONE_SLAB:
case BlockID.DARK_OAK_SLAB:
case BlockID.DARK_PRISMARINE_SLAB:
case BlockID.JUNGLE_SLAB:
case BlockID.NETHER_BRICK_SLAB:
case BlockID.OAK_SLAB:
case BlockID.PETRIFIED_OAK_SLAB:
case BlockID.PRISMARINE_BRICK_SLAB:
case BlockID.PRISMARINE_SLAB:
case BlockID.PURPUR_SLAB:
case BlockID.QUARTZ_SLAB:
case BlockID.RED_SANDSTONE_SLAB:
case BlockID.SANDSTONE_SLAB:
case BlockID.SPRUCE_SLAB:
case BlockID.STONE_BRICK_SLAB:
case BlockID.STONE_SLAB: {
String state = (String) block.getState(PropertyKey.TYPE);
if (state == null) return 0;
switch (state) {
@ -70,13 +70,13 @@ public class BlockTypeUtil {
return 0.5;
}
}
case "ACACIA_TRAPDOOR":
case "BIRCH_TRAPDOOR":
case "DARK_OAK_TRAPDOOR":
case "IRON_TRAPDOOR":
case "JUNGLE_TRAPDOOR":
case "OAK_TRAPDOOR":
case "SPRUCE_TRAPDOOR":
case BlockID.ACACIA_TRAPDOOR:
case BlockID.BIRCH_TRAPDOOR:
case BlockID.DARK_OAK_TRAPDOOR:
case BlockID.IRON_TRAPDOOR:
case BlockID.JUNGLE_TRAPDOOR:
case BlockID.OAK_TRAPDOOR:
case BlockID.SPRUCE_TRAPDOOR:
if (block.getState(PropertyKey.OPEN) == Boolean.TRUE) {
return 1;
} else if ("bottom".equals(block.getState(PropertyKey.HALF))) {
@ -84,12 +84,12 @@ public class BlockTypeUtil {
} else {
return 0;
}
case "ACACIA_FENCE_GATE":
case "BIRCH_FENCE_GATE":
case "DARK_OAK_FENCE_GATE":
case "JUNGLE_FENCE_GATE":
case "OAK_FENCE_GATE":
case "SPRUCE_FENCE_GATE": return block.getState(PropertyKey.OPEN) == Boolean.TRUE ? 1 : 0;
case BlockID.ACACIA_FENCE_GATE:
case BlockID.BIRCH_FENCE_GATE:
case BlockID.DARK_OAK_FENCE_GATE:
case BlockID.JUNGLE_FENCE_GATE:
case BlockID.OAK_FENCE_GATE:
case BlockID.SPRUCE_FENCE_GATE: return block.getState(PropertyKey.OPEN) == Boolean.TRUE ? 1 : 0;
default:
if (type.getMaterial().isMovementBlocker()) return 0;
return 1;
@ -105,64 +105,64 @@ public class BlockTypeUtil {
public static double centralTopLimit(BlockStateHolder block) {
checkNotNull(block);
BlockType type = block.getBlockType();
switch (type.getResource().toUpperCase()) {
case "BLACK_BED":
case "BLUE_BED":
case "BROWN_BED":
case "CYAN_BED":
case "GRAY_BED":
case "GREEN_BED":
case "LIGHT_BLUE_BED":
case "LIGHT_GRAY_BED":
case "LIME_BED":
case "MAGENTA_BED":
case "ORANGE_BED":
case "PINK_BED":
case "PURPLE_BED":
case "RED_BED":
case "WHITE_BED":
case "YELLOW_BED": return 0.5625;
case "BREWING_STAND": return 0.875;
case "CAKE": return (block.getState(PropertyKey.BITES) == (Integer) 6) ? 0 : 0.4375;
case "CAULDRON": return 0.3125;
case "COCOA": return 0.750;
case "ENCHANTING_TABLE": return 0.75;
case "END_PORTAL_FRAME": return block.getState(PropertyKey.EYE) == Boolean.TRUE ? 1 : 0.8125;
case "CREEPER_HEAD":
case "DRAGON_HEAD":
case "PISTON_HEAD":
case "PLAYER_HEAD":
case "ZOMBIE_HEAD": return 0.5;
case "CREEPER_WALL_HEAD":
case "DRAGON_WALL_HEAD":
case "PLAYER_WALL_HEAD":
case "ZOMBIE_WALL_HEAD": return 0.75;
case "ACACIA_FENCE":
case "BIRCH_FENCE":
case "DARK_OAK_FENCE":
case "JUNGLE_FENCE":
case "NETHER_BRICK_FENCE":
case "OAK_FENCE":
case "SPRUCE_FENCE": return 1.5;
case "ACACIA_SLAB":
case "BIRCH_SLAB":
case "BRICK_SLAB":
case "COBBLESTONE_SLAB":
case "DARK_OAK_SLAB":
case "DARK_PRISMARINE_SLAB":
case "JUNGLE_SLAB":
case "NETHER_BRICK_SLAB":
case "OAK_SLAB":
case "PETRIFIED_OAK_SLAB":
case "PRISMARINE_BRICK_SLAB":
case "PRISMARINE_SLAB":
case "PURPUR_SLAB":
case "QUARTZ_SLAB":
case "RED_SANDSTONE_SLAB":
case "SANDSTONE_SLAB":
case "SPRUCE_SLAB":
case "STONE_BRICK_SLAB":
case "STONE_SLAB": {
switch (type.getInternalId()) {
case BlockID.BLACK_BED:
case BlockID.BLUE_BED:
case BlockID.BROWN_BED:
case BlockID.CYAN_BED:
case BlockID.GRAY_BED:
case BlockID.GREEN_BED:
case BlockID.LIGHT_BLUE_BED:
case BlockID.LIGHT_GRAY_BED:
case BlockID.LIME_BED:
case BlockID.MAGENTA_BED:
case BlockID.ORANGE_BED:
case BlockID.PINK_BED:
case BlockID.PURPLE_BED:
case BlockID.RED_BED:
case BlockID.WHITE_BED:
case BlockID.YELLOW_BED: return 0.5625;
case BlockID.BREWING_STAND: return 0.875;
case BlockID.CAKE: return (block.getState(PropertyKey.BITES) == (Integer) 6) ? 0 : 0.4375;
case BlockID.CAULDRON: return 0.3125;
case BlockID.COCOA: return 0.750;
case BlockID.ENCHANTING_TABLE: return 0.75;
case BlockID.END_PORTAL_FRAME: return block.getState(PropertyKey.EYE) == Boolean.TRUE ? 1 : 0.8125;
case BlockID.CREEPER_HEAD:
case BlockID.DRAGON_HEAD:
case BlockID.PISTON_HEAD:
case BlockID.PLAYER_HEAD:
case BlockID.ZOMBIE_HEAD: return 0.5;
case BlockID.CREEPER_WALL_HEAD:
case BlockID.DRAGON_WALL_HEAD:
case BlockID.PLAYER_WALL_HEAD:
case BlockID.ZOMBIE_WALL_HEAD: return 0.75;
case BlockID.ACACIA_FENCE:
case BlockID.BIRCH_FENCE:
case BlockID.DARK_OAK_FENCE:
case BlockID.JUNGLE_FENCE:
case BlockID.NETHER_BRICK_FENCE:
case BlockID.OAK_FENCE:
case BlockID.SPRUCE_FENCE: return 1.5;
case BlockID.ACACIA_SLAB:
case BlockID.BIRCH_SLAB:
case BlockID.BRICK_SLAB:
case BlockID.COBBLESTONE_SLAB:
case BlockID.DARK_OAK_SLAB:
case BlockID.DARK_PRISMARINE_SLAB:
case BlockID.JUNGLE_SLAB:
case BlockID.NETHER_BRICK_SLAB:
case BlockID.OAK_SLAB:
case BlockID.PETRIFIED_OAK_SLAB:
case BlockID.PRISMARINE_BRICK_SLAB:
case BlockID.PRISMARINE_SLAB:
case BlockID.PURPUR_SLAB:
case BlockID.QUARTZ_SLAB:
case BlockID.RED_SANDSTONE_SLAB:
case BlockID.SANDSTONE_SLAB:
case BlockID.SPRUCE_SLAB:
case BlockID.STONE_BRICK_SLAB:
case BlockID.STONE_SLAB: {
String state = (String) block.getState(PropertyKey.TYPE);
if (state == null) return 0.5;
switch (state) {
@ -173,22 +173,22 @@ public class BlockTypeUtil {
return 1;
}
}
case "LILY_PAD": return 0.015625;
case "REPEATER": return 0.125;
case "SOUL_SAND": return 0.875;
case "COBBLESTONE_WALL":
case "MOSSY_COBBLESTONE_WALL": return 1.5;
case "FLOWER_POT": return 0.375;
case "COMPARATOR": return 0.125;
case "DAYLIGHT_DETECTOR": return 0.375;
case "HOPPER": return 0.625;
case "ACACIA_TRAPDOOR":
case "BIRCH_TRAPDOOR":
case "DARK_OAK_TRAPDOOR":
case "IRON_TRAPDOOR":
case "JUNGLE_TRAPDOOR":
case "OAK_TRAPDOOR":
case "SPRUCE_TRAPDOOR":
case BlockID.LILY_PAD: return 0.015625;
case BlockID.REPEATER: return 0.125;
case BlockID.SOUL_SAND: return 0.875;
case BlockID.COBBLESTONE_WALL:
case BlockID.MOSSY_COBBLESTONE_WALL: return 1.5;
case BlockID.FLOWER_POT: return 0.375;
case BlockID.COMPARATOR: return 0.125;
case BlockID.DAYLIGHT_DETECTOR: return 0.375;
case BlockID.HOPPER: return 0.625;
case BlockID.ACACIA_TRAPDOOR:
case BlockID.BIRCH_TRAPDOOR:
case BlockID.DARK_OAK_TRAPDOOR:
case BlockID.IRON_TRAPDOOR:
case BlockID.JUNGLE_TRAPDOOR:
case BlockID.OAK_TRAPDOOR:
case BlockID.SPRUCE_TRAPDOOR:
if (block.getState(PropertyKey.OPEN) == Boolean.TRUE) {
return 0;
} else if ("top".equals(block.getState(PropertyKey.HALF))) {
@ -196,12 +196,12 @@ public class BlockTypeUtil {
} else {
return 0.1875;
}
case "ACACIA_FENCE_GATE":
case "BIRCH_FENCE_GATE":
case "DARK_OAK_FENCE_GATE":
case "JUNGLE_FENCE_GATE":
case "OAK_FENCE_GATE":
case "SPRUCE_FENCE_GATE": return block.getState(PropertyKey.OPEN) == Boolean.TRUE ? 0 : 1.5;
case BlockID.ACACIA_FENCE_GATE:
case BlockID.BIRCH_FENCE_GATE:
case BlockID.DARK_OAK_FENCE_GATE:
case BlockID.JUNGLE_FENCE_GATE:
case BlockID.OAK_FENCE_GATE:
case BlockID.SPRUCE_FENCE_GATE: return block.getState(PropertyKey.OPEN) == Boolean.TRUE ? 0 : 1.5;
default:
if (type.hasProperty(PropertyKey.LAYERS)) {
return PropertyGroup.LEVEL.get(block) * 0.0625;