From eac9f4d10a85ab8232ad35032ab335f24be04c9d Mon Sep 17 00:00:00 2001 From: Evenprime Date: Tue, 31 May 2011 17:49:25 +0200 Subject: [PATCH] Replaced definition of block types with a much more flexible method, that should theoretically also support future blocks --- .../bukkit/nocheat/data/MovingData.java | 100 ++++-------------- 1 file changed, 18 insertions(+), 82 deletions(-) diff --git a/src/cc/co/evenprime/bukkit/nocheat/data/MovingData.java b/src/cc/co/evenprime/bukkit/nocheat/data/MovingData.java index 844ee361..d60b2b17 100644 --- a/src/cc/co/evenprime/bukkit/nocheat/data/MovingData.java +++ b/src/cc/co/evenprime/bukkit/nocheat/data/MovingData.java @@ -2,6 +2,8 @@ package cc.co.evenprime.bukkit.nocheat.data; import java.util.logging.Level; +import net.minecraft.server.Block; + import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.entity.Player; @@ -48,93 +50,27 @@ public class MovingData { static { + // Find and define properties of all blocks for(int i = 0; i < types.length; i++) { + + // Everything is unknown at first types[i] = UNKNOWN; + + if(Block.byId[i] != null) { + if(Block.byId[i].material.isSolid()) { + // solid blocks like STONE, CAKE, TRAPDOORS + types[i] = SOLID; + } + else if(Block.byId[i].material.isLiquid()){ + // WATER, LAVA + types[i] = LIQUID; + } + } } - - types[Material.AIR.getId()] = NONSOLID; - types[Material.STONE.getId()] = SOLID; - types[Material.GRASS.getId()] = SOLID; - types[Material.DIRT.getId()] = SOLID; - types[Material.COBBLESTONE.getId()] = SOLID; - types[Material.WOOD.getId()] = SOLID; - types[Material.SAPLING.getId()] = NONSOLID; - types[Material.BEDROCK.getId()] = SOLID; - types[Material.WATER.getId()] = LIQUID; - types[Material.STATIONARY_WATER.getId()] = LIQUID; - types[Material.LAVA.getId()] = LIQUID; - types[Material.STATIONARY_LAVA.getId()] = LIQUID; - types[Material.SAND.getId()] = SOLID; - types[Material.GRAVEL.getId()] = SOLID; - types[Material.GOLD_ORE.getId()] = SOLID; - types[Material.IRON_ORE.getId()] = SOLID; - types[Material.COAL_ORE.getId()] = SOLID; - types[Material.LOG.getId()] = SOLID; - types[Material.LEAVES.getId()] = SOLID; - types[Material.SPONGE.getId()] = SOLID; - types[Material.GLASS.getId()] = SOLID; - types[Material.LAPIS_ORE.getId()] = SOLID; - types[Material.LAPIS_BLOCK.getId()] = SOLID; - types[Material.DISPENSER.getId()] = SOLID; - types[Material.SANDSTONE.getId()] = SOLID; - types[Material.NOTE_BLOCK.getId()]= SOLID; - types[Material.WOOL.getId()]= SOLID; - types[Material.YELLOW_FLOWER.getId()]= NONSOLID; - types[Material.RED_ROSE.getId()]= NONSOLID; - types[Material.BROWN_MUSHROOM.getId()]= NONSOLID; - types[Material.RED_MUSHROOM.getId()]= NONSOLID; - types[Material.GOLD_BLOCK.getId()]= SOLID; - types[Material.IRON_BLOCK.getId()]= SOLID; - types[Material.DOUBLE_STEP.getId()]= UNKNOWN; - types[Material.STEP.getId()]= UNKNOWN; - types[Material.BRICK.getId()]= SOLID; - types[Material.TNT.getId()]= SOLID; - types[Material.BOOKSHELF.getId()]= SOLID; - types[Material.MOSSY_COBBLESTONE.getId()] = SOLID; - types[Material.OBSIDIAN.getId()]= SOLID; - types[Material.TORCH.getId()]= NONSOLID; - types[Material.FIRE.getId()]= NONSOLID; - types[Material.MOB_SPAWNER.getId()]= SOLID; - types[Material.WOOD_STAIRS.getId()]= UNKNOWN; - types[Material.CHEST.getId()]= SOLID; - types[Material.REDSTONE_WIRE.getId()]= NONSOLID; - types[Material.DIAMOND_ORE.getId()]= SOLID; - types[Material.DIAMOND_BLOCK.getId()]= SOLID; - types[Material.WORKBENCH.getId()]= SOLID; - types[Material.CROPS.getId()]= NONSOLID; - types[Material.SOIL.getId()]= SOLID; - types[Material.FURNACE.getId()]= SOLID; - types[Material.BURNING_FURNACE.getId()]= SOLID; - types[Material.SIGN_POST.getId()]= NONSOLID; - types[Material.WOODEN_DOOR.getId()]= NONSOLID; + + // Special types just for me types[Material.LADDER.getId()]= LADDER; - types[Material.RAILS.getId()]= NONSOLID; - types[Material.COBBLESTONE_STAIRS.getId()]= UNKNOWN; - types[Material.WALL_SIGN.getId()]= NONSOLID; - types[Material.LEVER.getId()]= NONSOLID; - types[Material.STONE_PLATE.getId()]= UNKNOWN; - types[Material.IRON_DOOR_BLOCK.getId()]= NONSOLID; - types[Material.WOOD_PLATE.getId()]= NONSOLID; - types[Material.REDSTONE_ORE.getId()]= SOLID; - types[Material.GLOWING_REDSTONE_ORE.getId()]= SOLID; - types[Material.REDSTONE_TORCH_OFF.getId()]= NONSOLID; - types[Material.REDSTONE_TORCH_ON.getId()]= NONSOLID; - types[Material.STONE_BUTTON.getId()]= NONSOLID; - types[Material.SNOW.getId()]= UNKNOWN; - types[Material.ICE.getId()]= UNKNOWN; - types[Material.SNOW_BLOCK.getId()]= SOLID; - types[Material.CACTUS.getId()]= SOLID; - types[Material.CLAY.getId()]= SOLID; - types[Material.SUGAR_CANE_BLOCK.getId()]= NONSOLID; - types[Material.JUKEBOX.getId()]= SOLID; types[Material.FENCE.getId()]= FENCE; - types[Material.PUMPKIN.getId()]= SOLID; - types[Material.NETHERRACK.getId()]= SOLID; - types[Material.SOUL_SAND.getId()]= UNKNOWN; - types[Material.GLOWSTONE.getId()]= SOLID; - types[Material.PORTAL.getId()]= NONSOLID; - types[Material.JACK_O_LANTERN.getId()]= SOLID; - types[Material.CAKE_BLOCK.getId()]= UNKNOWN; } public static MovingData get(final Player p) {