Add isSolid() to Material. Adds BUKKIT-3131

A 'solid' material indicates that it is a block and cannot be passed
through.

By: Wesley Wolfe <weswolf@aol.com>
This commit is contained in:
Bukkit/Spigot 2012-12-09 15:13:25 -06:00
parent 4cc9a1bec4
commit d50460fb2d

View File

@ -538,4 +538,122 @@ public enum Material {
public boolean isRecord() {
return id >= GOLD_RECORD.id && id <= RECORD_12.id;
}
/**
* Check if the material is a block and solid (cannot be passed through by a player)
*
* @return True if this material is a block and solid
*/
public boolean isSolid() {
if (!isBlock() || id == 0) {
return false;
}
switch (this) {
case STONE:
case GRASS:
case DIRT:
case COBBLESTONE:
case WOOD:
case BEDROCK:
case SAND:
case GRAVEL:
case GOLD_ORE:
case IRON_ORE:
case COAL_ORE:
case LOG:
case LEAVES:
case SPONGE:
case GLASS:
case LAPIS_ORE:
case LAPIS_BLOCK:
case DISPENSER:
case SANDSTONE:
case NOTE_BLOCK:
case BED_BLOCK:
case PISTON_STICKY_BASE:
case PISTON_BASE:
case PISTON_EXTENSION:
case WOOL:
case PISTON_MOVING_PIECE:
case GOLD_BLOCK:
case IRON_BLOCK:
case DOUBLE_STEP:
case STEP:
case BRICK:
case TNT:
case BOOKSHELF:
case MOSSY_COBBLESTONE:
case OBSIDIAN:
case MOB_SPAWNER:
case WOOD_STAIRS:
case CHEST:
case DIAMOND_ORE:
case DIAMOND_BLOCK:
case WORKBENCH:
case SOIL:
case FURNACE:
case BURNING_FURNACE:
case SIGN_POST:
case WOODEN_DOOR:
case COBBLESTONE_STAIRS:
case WALL_SIGN:
case STONE_PLATE:
case IRON_DOOR_BLOCK:
case WOOD_PLATE:
case REDSTONE_ORE:
case GLOWING_REDSTONE_ORE:
case ICE:
case SNOW_BLOCK:
case CACTUS:
case CLAY:
case JUKEBOX:
case FENCE:
case PUMPKIN:
case NETHERRACK:
case SOUL_SAND:
case GLOWSTONE:
case JACK_O_LANTERN:
case CAKE_BLOCK:
case LOCKED_CHEST:
case TRAP_DOOR:
case MONSTER_EGGS:
case SMOOTH_BRICK:
case HUGE_MUSHROOM_1:
case HUGE_MUSHROOM_2:
case IRON_FENCE:
case THIN_GLASS:
case MELON_BLOCK:
case FENCE_GATE:
case BRICK_STAIRS:
case SMOOTH_STAIRS:
case MYCEL:
case NETHER_BRICK:
case NETHER_FENCE:
case NETHER_BRICK_STAIRS:
case ENCHANTMENT_TABLE:
case BREWING_STAND:
case CAULDRON:
case ENDER_PORTAL_FRAME:
case ENDER_STONE:
case DRAGON_EGG:
case REDSTONE_LAMP_OFF:
case REDSTONE_LAMP_ON:
case WOOD_DOUBLE_STEP:
case WOOD_STEP:
case SANDSTONE_STAIRS:
case EMERALD_ORE:
case ENDER_CHEST:
case EMERALD_BLOCK:
case SPRUCE_WOOD_STAIRS:
case BIRCH_WOOD_STAIRS:
case JUNGLE_WOOD_STAIRS:
case COMMAND:
case BEACON:
case COBBLE_WALL:
case ANVIL:
return true;
default:
return false;
}
}
}