Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package org.bukkit;
- import java.util.HashMap;
- public abstract class BlockType {
- private static BlockType[] byId = new BlockType[256];
- private static HashMap<String, Integer> nameToId = new HashMap<String, Integer>();
- public enum Default {
- STONE(1),
- GRASS(2),
- DIRT(3),
- COBBLESTONE(4),
- WOOD(5),
- SAPLING(6),
- BEDROCK(7),
- WATER(8),
- STATIONARY_WATER(9),
- LAVA(10),
- STATIONARY_LAVA(11),
- SAND(12),
- GRAVEL(13),
- GOLD_ORE(14),
- IRON_ORE(15),
- COAL_ORE(16),
- LOG(17),
- LEAVES(18),
- SPONGE(19),
- GLASS(20),
- LAPIS_ORE(21),
- LAPIS_BLOCK(22),
- DISPENSER(23),
- SANDSTONE(24),
- NOTE_BLOCK(25),
- WOOL(35),
- YELLOW_FLOWER(37),
- RED_ROSE(38),
- BROWN_MUSHROOM(39),
- RED_MUSHROOM(40),
- GOLD_BLOCK(41),
- IRON_BLOCK(42),
- DOUBLE_STEP(43),
- STEP(44),
- BRICK(45),
- TNT(46),
- BOOKSHELF(47),
- MOSSY_COBBLESTONE(48),
- OBSIDIAN(49),
- TORCH(50),
- FIRE(51),
- MOB_SPAWNER(52),
- WOOD_STAIRS(53),
- CHEST(54),
- REDSTONE_WIRE(55),
- DIAMOND_ORE(56),
- DIAMOND_BLOCK(57),
- WORKBENCH(58),
- CROPS(59),
- SOIL(60),
- FURNACE(61),
- BURNING_FURNACE(62),
- SIGN_POST(63),
- WOODEN_DOOR(64),
- LADDER(65),
- RAILS(66),
- COBBLESTONE_STAIRS(67),
- WALL_SIGN(68),
- LEVER(69),
- STONE_PLATE(70),
- IRON_DOOR_BLOCK(71),
- WOOD_PLATE(72),
- REDSTONE_ORE(73),
- GLOWING_REDSTONE_ORE(74),
- REDSTONE_TORCH_OFF(75),
- REDSTONE_TORCH_ON(76),
- STONE_BUTTON(77),
- SNOW(78),
- ICE(79),
- SNOW_BLOCK(80),
- CACTUS(81),
- CLAY(82),
- SUGAR_CANE_BLOCK(83),
- JUKEBOX(84),
- FENCE(85),
- PUMPKIN(86),
- NETHERRACK(87),
- SOUL_SAND(88),
- GLOWSTONE(89),
- PORTAL(90),
- JACK_O_LANTERN(91),
- CAKE_BLOCK(92),
- DIODE_BLOCK_OFF(93),
- DIODE_BLOCK_ON(94),
- LOCKED_CHEST(95);
- private int id;
- Default(int id) {
- this.id = id;
- }
- public int getId() {
- return this.id;
- }
- }
- protected int id;
- protected String name;
- protected BlockType(int id, String name) {
- this.id = id;
- this.name = name;
- }
- // Register types/aliases
- public static final void registerType(BlockType type) {
- byId.put(type.getId(), type);
- nameToId.put(type.getName(), type.getId());
- }
- public static final void registerAlias(int id, String... names) {
- for (String name: names) {
- nameToId.put(name, id);
- }
- }
- // Getters
- public static BlockType get(int id) {
- return byId[id];
- }
- public static BlockType get(String name) {
- return get(nameToId.get(name));
- }
- public static BlockType get(Default type) {
- return get(type.getId());
- }
- // Generic accessors
- public String getName() {
- return this.name;
- }
- public int getId() {
- return this.id;
- }
- // To Be implemented
- public abstract String getInternalName();
- public abstract float getFrictionFactor();
- public abstract int getDurability();
- public abstract int getStrength();
- public abstract int getTextureId(int face);
- public abstract Material getMaterial();
- public abstract ItemType[] getDrops(); // perhaps ItemStack
- }
Add Comment
Please, Sign In to add comment