Autogenerated Material ready to use

This commit is contained in:
jglrxavpok 2020-06-29 19:21:41 +02:00
parent c66742e3d3
commit 4902ed4c6e
9 changed files with 1106 additions and 1034 deletions

View File

@ -5,7 +5,7 @@ package net.minestom.server.instance.item;
import net.minestom.server.instance.block.Block;
import it.unimi.dsi.fastutil.shorts.Short2ObjectOpenHashMap;
public enum TmpMaterial {
public enum Material {
AIR("minecraft:air", 0, Block.AIR),
STONE("minecraft:stone", 64, Block.STONE),
GRANITE("minecraft:granite", 64, Block.GRANITE),
@ -895,11 +895,11 @@ public enum TmpMaterial {
private int maxDefaultStackSize;
private Block correspondingBlock;
TmpMaterial(String namespaceID, int maxDefaultStackSize, Block correspondingBlock) {
Material(String namespaceID, int maxDefaultStackSize, Block correspondingBlock) {
this.namespaceID = namespaceID;
this.maxDefaultStackSize = maxDefaultStackSize;
this.correspondingBlock = correspondingBlock;
TmpMaterialMap.map.put((short)ordinal(), this);
MaterialMap.map.put((short)ordinal(), this);
}
public short getId() {
@ -922,8 +922,8 @@ public enum TmpMaterial {
return correspondingBlock;
}
public static TmpMaterial fromId(short blockId) {
return TmpMaterialMap.map.getOrDefault(blockId, AIR);
public static Material fromId(short blockId) {
return MaterialMap.map.getOrDefault(blockId, AIR);
}
public boolean isHelmet() {
@ -947,7 +947,48 @@ public enum TmpMaterial {
}
public boolean isFood() {
return false; // TODO
switch (this) {
case APPLE:
case MUSHROOM_STEW:
case BREAD:
case PORKCHOP:
case COOKED_PORKCHOP:
case GOLDEN_APPLE:
case ENCHANTED_GOLDEN_APPLE:
case COD:
case SALMON:
case TROPICAL_FISH:
case PUFFERFISH:
case COOKED_COD:
case COOKED_SALMON:
case CAKE:
case COOKIE:
case MELON_SLICE:
case DRIED_KELP:
case BEEF:
case COOKED_BEEF:
case CHICKEN:
case COOKED_CHICKEN:
case ROTTEN_FLESH:
case SPIDER_EYE:
case CARROT:
case POTATO:
case BAKED_POTATO:
case POISONOUS_POTATO:
case PUMPKIN_PIE:
case RABBIT:
case COOKED_RABBIT:
case RABBIT_STEW:
case MUTTON:
case COOKED_MUTTON:
case BEETROOT:
case BEETROOT_SOUP:
case SWEET_BERRIES:
case HONEY_BOTTLE:
return true;
default:
return false;
}
}
public boolean hasState() {

View File

@ -0,0 +1,5 @@
package net.minestom.server.instance.item;
import it.unimi.dsi.fastutil.shorts.Short2ObjectOpenHashMap;
final class MaterialMap {
static final Short2ObjectOpenHashMap<Material> map = new Short2ObjectOpenHashMap<>();
}

View File

@ -1,5 +0,0 @@
package net.minestom.server.instance.item;
import it.unimi.dsi.fastutil.shorts.Short2ObjectOpenHashMap;
final class TmpMaterialMap {
static final Short2ObjectOpenHashMap<TmpMaterial> map = new Short2ObjectOpenHashMap<>();
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,5 @@
package net.minestom.server.item;
import it.unimi.dsi.fastutil.shorts.Short2ObjectOpenHashMap;
final class MaterialMap {
static final Short2ObjectOpenHashMap<Material> map = new Short2ObjectOpenHashMap<>();
}

View File

@ -82,12 +82,12 @@ public class ItemEnumGenerator extends MinestomEnumGenerator<ItemContainer> {
@Override
public String getPackageName() {
return "net.minestom.server.instance.item";
return "net.minestom.server.item";
}
@Override
public String getClassName() {
return "TmpMaterial";
return "Material";
}
@Override
@ -146,7 +146,48 @@ public class ItemEnumGenerator extends MinestomEnumGenerator<ItemContainer> {
generator.addMethod("isLeggings", "()", "boolean", "return toString().endsWith(\"LEGGINGS\");");
generator.addMethod("isBoots", "()", "boolean", "return toString().endsWith(\"BOOTS\");");
generator.addMethod("isArmor", "()", "boolean", "return isChestplate() || isHelmet() || isLeggings() || isBoots();");
generator.addMethod("isFood", "()", "boolean", "return false; // TODO");
generator.addMethod("isFood", "()", "boolean", "switch (this) {\n" +
" case APPLE:\n" +
" case MUSHROOM_STEW:\n" +
" case BREAD:\n" +
" case PORKCHOP:\n" +
" case COOKED_PORKCHOP:\n" +
" case GOLDEN_APPLE:\n" +
" case ENCHANTED_GOLDEN_APPLE:\n" +
" case COD:\n" +
" case SALMON:\n" +
" case TROPICAL_FISH:\n" +
" case PUFFERFISH:\n" +
" case COOKED_COD:\n" +
" case COOKED_SALMON:\n" +
" case CAKE:\n" +
" case COOKIE:\n" +
" case MELON_SLICE:\n" +
" case DRIED_KELP:\n" +
" case BEEF:\n" +
" case COOKED_BEEF:\n" +
" case CHICKEN:\n" +
" case COOKED_CHICKEN:\n" +
" case ROTTEN_FLESH:\n" +
" case SPIDER_EYE:\n" +
" case CARROT:\n" +
" case POTATO:\n" +
" case BAKED_POTATO:\n" +
" case POISONOUS_POTATO:\n" +
" case PUMPKIN_PIE:\n" +
" case RABBIT:\n" +
" case COOKED_RABBIT:\n" +
" case RABBIT_STEW:\n" +
" case MUTTON:\n" +
" case COOKED_MUTTON:\n" +
" case BEETROOT:\n" +
" case BEETROOT_SOUP:\n" +
" case SWEET_BERRIES:\n" +
" case HONEY_BOTTLE:\n" +
" return true;\n" +
" default:\n" +
" return false;\n" +
" }");
generator.addMethod("hasState", "()", "boolean", "switch (this) {\n" +
" case BOW:\n" +
" case TRIDENT:\n" +

View File

@ -123,7 +123,6 @@ public class MinecraftServer {
} catch (IOException e) {
LOGGER.error("An error happened during resource gathering. Minestom will attempt to load anyway, but things may not work, and crashes can happen.", e);
}
RegistryMain.registerItems();
RegistryMain.registerEntities();
RegistryMain.registerSounds();
RegistryMain.registerParticles();

View File

@ -1,998 +0,0 @@
package net.minestom.server.item;
import it.unimi.dsi.fastutil.shorts.Short2ObjectOpenHashMap;
import net.minestom.server.instance.block.Block;
public enum Material {
AIR,
STONE,
GRANITE,
POLISHED_GRANITE,
DIORITE,
POLISHED_DIORITE,
ANDESITE,
POLISHED_ANDESITE,
GRASS_BLOCK,
DIRT,
COARSE_DIRT,
PODZOL,
COBBLESTONE,
OAK_PLANKS,
SPRUCE_PLANKS,
BIRCH_PLANKS,
JUNGLE_PLANKS,
ACACIA_PLANKS,
DARK_OAK_PLANKS,
OAK_SAPLING,
SPRUCE_SAPLING,
BIRCH_SAPLING,
JUNGLE_SAPLING,
ACACIA_SAPLING,
DARK_OAK_SAPLING,
BEDROCK,
SAND,
RED_SAND,
GRAVEL,
GOLD_ORE,
IRON_ORE,
COAL_ORE,
OAK_LOG,
SPRUCE_LOG,
BIRCH_LOG,
JUNGLE_LOG,
ACACIA_LOG,
DARK_OAK_LOG,
STRIPPED_OAK_LOG,
STRIPPED_SPRUCE_LOG,
STRIPPED_BIRCH_LOG,
STRIPPED_JUNGLE_LOG,
STRIPPED_ACACIA_LOG,
STRIPPED_DARK_OAK_LOG,
STRIPPED_OAK_WOOD,
STRIPPED_SPRUCE_WOOD,
STRIPPED_BIRCH_WOOD,
STRIPPED_JUNGLE_WOOD,
STRIPPED_ACACIA_WOOD,
STRIPPED_DARK_OAK_WOOD,
OAK_WOOD,
SPRUCE_WOOD,
BIRCH_WOOD,
JUNGLE_WOOD,
ACACIA_WOOD,
DARK_OAK_WOOD,
OAK_LEAVES,
SPRUCE_LEAVES,
BIRCH_LEAVES,
JUNGLE_LEAVES,
ACACIA_LEAVES,
DARK_OAK_LEAVES,
SPONGE,
WET_SPONGE,
GLASS,
LAPIS_ORE,
LAPIS_BLOCK,
DISPENSER,
SANDSTONE,
CHISELED_SANDSTONE,
CUT_SANDSTONE,
NOTE_BLOCK,
POWERED_RAIL,
DETECTOR_RAIL,
STICKY_PISTON,
COBWEB,
GRASS,
FERN,
DEAD_BUSH,
SEAGRASS,
SEA_PICKLE,
PISTON,
WHITE_WOOL,
ORANGE_WOOL,
MAGENTA_WOOL,
LIGHT_BLUE_WOOL,
YELLOW_WOOL,
LIME_WOOL,
PINK_WOOL,
GRAY_WOOL,
LIGHT_GRAY_WOOL,
CYAN_WOOL,
PURPLE_WOOL,
BLUE_WOOL,
BROWN_WOOL,
GREEN_WOOL,
RED_WOOL,
BLACK_WOOL,
DANDELION,
POPPY,
BLUE_ORCHID,
ALLIUM,
AZURE_BLUET,
RED_TULIP,
ORANGE_TULIP,
WHITE_TULIP,
PINK_TULIP,
OXEYE_DAISY,
CORNFLOWER,
LILY_OF_THE_VALLEY,
WITHER_ROSE,
BROWN_MUSHROOM,
RED_MUSHROOM,
GOLD_BLOCK,
IRON_BLOCK,
OAK_SLAB,
SPRUCE_SLAB,
BIRCH_SLAB,
JUNGLE_SLAB,
ACACIA_SLAB,
DARK_OAK_SLAB,
STONE_SLAB,
SMOOTH_STONE_SLAB,
SANDSTONE_SLAB,
CUT_SANDSTONE_SLAB,
PETRIFIED_OAK_SLAB,
COBBLESTONE_SLAB,
BRICK_SLAB,
STONE_BRICK_SLAB,
NETHER_BRICK_SLAB,
QUARTZ_SLAB,
RED_SANDSTONE_SLAB,
CUT_RED_SANDSTONE_SLAB,
PURPUR_SLAB,
PRISMARINE_SLAB,
PRISMARINE_BRICK_SLAB,
DARK_PRISMARINE_SLAB,
SMOOTH_QUARTZ,
SMOOTH_RED_SANDSTONE,
SMOOTH_SANDSTONE,
SMOOTH_STONE,
BRICKS,
TNT,
BOOKSHELF,
MOSSY_COBBLESTONE,
OBSIDIAN,
TORCH,
END_ROD,
CHORUS_PLANT,
CHORUS_FLOWER,
PURPUR_BLOCK,
PURPUR_PILLAR,
PURPUR_STAIRS,
SPAWNER,
OAK_STAIRS,
CHEST,
DIAMOND_ORE,
DIAMOND_BLOCK,
CRAFTING_TABLE,
FARMLAND,
FURNACE,
LADDER,
RAIL,
COBBLESTONE_STAIRS,
LEVER,
STONE_PRESSURE_PLATE,
OAK_PRESSURE_PLATE,
SPRUCE_PRESSURE_PLATE,
BIRCH_PRESSURE_PLATE,
JUNGLE_PRESSURE_PLATE,
ACACIA_PRESSURE_PLATE,
DARK_OAK_PRESSURE_PLATE,
REDSTONE_ORE,
REDSTONE_TORCH,
STONE_BUTTON,
SNOW,
ICE,
SNOW_BLOCK,
CACTUS,
CLAY,
JUKEBOX,
OAK_FENCE,
SPRUCE_FENCE,
BIRCH_FENCE,
JUNGLE_FENCE,
ACACIA_FENCE,
DARK_OAK_FENCE,
PUMPKIN,
CARVED_PUMPKIN,
NETHERRACK,
SOUL_SAND,
GLOWSTONE,
JACK_O_LANTERN,
OAK_TRAPDOOR,
SPRUCE_TRAPDOOR,
BIRCH_TRAPDOOR,
JUNGLE_TRAPDOOR,
ACACIA_TRAPDOOR,
DARK_OAK_TRAPDOOR,
INFESTED_STONE,
INFESTED_COBBLESTONE,
INFESTED_STONE_BRICKS,
INFESTED_MOSSY_STONE_BRICKS,
INFESTED_CRACKED_STONE_BRICKS,
INFESTED_CHISELED_STONE_BRICKS,
STONE_BRICKS,
MOSSY_STONE_BRICKS,
CRACKED_STONE_BRICKS,
CHISELED_STONE_BRICKS,
BROWN_MUSHROOM_BLOCK,
RED_MUSHROOM_BLOCK,
MUSHROOM_STEM,
IRON_BARS,
GLASS_PANE,
MELON,
VINE,
OAK_FENCE_GATE,
SPRUCE_FENCE_GATE,
BIRCH_FENCE_GATE,
JUNGLE_FENCE_GATE,
ACACIA_FENCE_GATE,
DARK_OAK_FENCE_GATE,
BRICK_STAIRS,
STONE_BRICK_STAIRS,
MYCELIUM,
LILY_PAD,
NETHER_BRICKS,
NETHER_BRICK_FENCE,
NETHER_BRICK_STAIRS,
ENCHANTING_TABLE,
END_PORTAL_FRAME,
END_STONE,
END_STONE_BRICKS,
DRAGON_EGG,
REDSTONE_LAMP,
SANDSTONE_STAIRS,
EMERALD_ORE,
ENDER_CHEST,
TRIPWIRE_HOOK,
EMERALD_BLOCK,
SPRUCE_STAIRS,
BIRCH_STAIRS,
JUNGLE_STAIRS,
COMMAND_BLOCK,
BEACON,
COBBLESTONE_WALL,
MOSSY_COBBLESTONE_WALL,
BRICK_WALL,
PRISMARINE_WALL,
RED_SANDSTONE_WALL,
MOSSY_STONE_BRICK_WALL,
GRANITE_WALL,
STONE_BRICK_WALL,
NETHER_BRICK_WALL,
ANDESITE_WALL,
RED_NETHER_BRICK_WALL,
SANDSTONE_WALL,
END_STONE_BRICK_WALL,
DIORITE_WALL,
OAK_BUTTON,
SPRUCE_BUTTON,
BIRCH_BUTTON,
JUNGLE_BUTTON,
ACACIA_BUTTON,
DARK_OAK_BUTTON,
ANVIL,
CHIPPED_ANVIL,
DAMAGED_ANVIL,
TRAPPED_CHEST,
LIGHT_WEIGHTED_PRESSURE_PLATE,
HEAVY_WEIGHTED_PRESSURE_PLATE,
DAYLIGHT_DETECTOR,
REDSTONE_BLOCK,
NETHER_QUARTZ_ORE,
HOPPER,
CHISELED_QUARTZ_BLOCK,
QUARTZ_BLOCK,
QUARTZ_PILLAR,
QUARTZ_STAIRS,
ACTIVATOR_RAIL,
DROPPER,
WHITE_TERRACOTTA,
ORANGE_TERRACOTTA,
MAGENTA_TERRACOTTA,
LIGHT_BLUE_TERRACOTTA,
YELLOW_TERRACOTTA,
LIME_TERRACOTTA,
PINK_TERRACOTTA,
GRAY_TERRACOTTA,
LIGHT_GRAY_TERRACOTTA,
CYAN_TERRACOTTA,
PURPLE_TERRACOTTA,
BLUE_TERRACOTTA,
BROWN_TERRACOTTA,
GREEN_TERRACOTTA,
RED_TERRACOTTA,
BLACK_TERRACOTTA,
BARRIER,
IRON_TRAPDOOR,
HAY_BLOCK,
WHITE_CARPET,
ORANGE_CARPET,
MAGENTA_CARPET,
LIGHT_BLUE_CARPET,
YELLOW_CARPET,
LIME_CARPET,
PINK_CARPET,
GRAY_CARPET,
LIGHT_GRAY_CARPET,
CYAN_CARPET,
PURPLE_CARPET,
BLUE_CARPET,
BROWN_CARPET,
GREEN_CARPET,
RED_CARPET,
BLACK_CARPET,
TERRACOTTA,
COAL_BLOCK,
PACKED_ICE,
ACACIA_STAIRS,
DARK_OAK_STAIRS,
SLIME_BLOCK,
GRASS_PATH,
SUNFLOWER,
LILAC,
ROSE_BUSH,
PEONY,
TALL_GRASS,
LARGE_FERN,
WHITE_STAINED_GLASS,
ORANGE_STAINED_GLASS,
MAGENTA_STAINED_GLASS,
LIGHT_BLUE_STAINED_GLASS,
YELLOW_STAINED_GLASS,
LIME_STAINED_GLASS,
PINK_STAINED_GLASS,
GRAY_STAINED_GLASS,
LIGHT_GRAY_STAINED_GLASS,
CYAN_STAINED_GLASS,
PURPLE_STAINED_GLASS,
BLUE_STAINED_GLASS,
BROWN_STAINED_GLASS,
GREEN_STAINED_GLASS,
RED_STAINED_GLASS,
BLACK_STAINED_GLASS,
WHITE_STAINED_GLASS_PANE,
ORANGE_STAINED_GLASS_PANE,
MAGENTA_STAINED_GLASS_PANE,
LIGHT_BLUE_STAINED_GLASS_PANE,
YELLOW_STAINED_GLASS_PANE,
LIME_STAINED_GLASS_PANE,
PINK_STAINED_GLASS_PANE,
GRAY_STAINED_GLASS_PANE,
LIGHT_GRAY_STAINED_GLASS_PANE,
CYAN_STAINED_GLASS_PANE,
PURPLE_STAINED_GLASS_PANE,
BLUE_STAINED_GLASS_PANE,
BROWN_STAINED_GLASS_PANE,
GREEN_STAINED_GLASS_PANE,
RED_STAINED_GLASS_PANE,
BLACK_STAINED_GLASS_PANE,
PRISMARINE,
PRISMARINE_BRICKS,
DARK_PRISMARINE,
PRISMARINE_STAIRS,
PRISMARINE_BRICK_STAIRS,
DARK_PRISMARINE_STAIRS,
SEA_LANTERN,
RED_SANDSTONE,
CHISELED_RED_SANDSTONE,
CUT_RED_SANDSTONE,
RED_SANDSTONE_STAIRS,
REPEATING_COMMAND_BLOCK,
CHAIN_COMMAND_BLOCK,
MAGMA_BLOCK,
NETHER_WART_BLOCK,
RED_NETHER_BRICKS,
BONE_BLOCK,
STRUCTURE_VOID,
OBSERVER,
SHULKER_BOX,
WHITE_SHULKER_BOX,
ORANGE_SHULKER_BOX,
MAGENTA_SHULKER_BOX,
LIGHT_BLUE_SHULKER_BOX,
YELLOW_SHULKER_BOX,
LIME_SHULKER_BOX,
PINK_SHULKER_BOX,
GRAY_SHULKER_BOX,
LIGHT_GRAY_SHULKER_BOX,
CYAN_SHULKER_BOX,
PURPLE_SHULKER_BOX,
BLUE_SHULKER_BOX,
BROWN_SHULKER_BOX,
GREEN_SHULKER_BOX,
RED_SHULKER_BOX,
BLACK_SHULKER_BOX,
WHITE_GLAZED_TERRACOTTA,
ORANGE_GLAZED_TERRACOTTA,
MAGENTA_GLAZED_TERRACOTTA,
LIGHT_BLUE_GLAZED_TERRACOTTA,
YELLOW_GLAZED_TERRACOTTA,
LIME_GLAZED_TERRACOTTA,
PINK_GLAZED_TERRACOTTA,
GRAY_GLAZED_TERRACOTTA,
LIGHT_GRAY_GLAZED_TERRACOTTA,
CYAN_GLAZED_TERRACOTTA,
PURPLE_GLAZED_TERRACOTTA,
BLUE_GLAZED_TERRACOTTA,
BROWN_GLAZED_TERRACOTTA,
GREEN_GLAZED_TERRACOTTA,
RED_GLAZED_TERRACOTTA,
BLACK_GLAZED_TERRACOTTA,
WHITE_CONCRETE,
ORANGE_CONCRETE,
MAGENTA_CONCRETE,
LIGHT_BLUE_CONCRETE,
YELLOW_CONCRETE,
LIME_CONCRETE,
PINK_CONCRETE,
GRAY_CONCRETE,
LIGHT_GRAY_CONCRETE,
CYAN_CONCRETE,
PURPLE_CONCRETE,
BLUE_CONCRETE,
BROWN_CONCRETE,
GREEN_CONCRETE,
RED_CONCRETE,
BLACK_CONCRETE,
WHITE_CONCRETE_POWDER,
ORANGE_CONCRETE_POWDER,
MAGENTA_CONCRETE_POWDER,
LIGHT_BLUE_CONCRETE_POWDER,
YELLOW_CONCRETE_POWDER,
LIME_CONCRETE_POWDER,
PINK_CONCRETE_POWDER,
GRAY_CONCRETE_POWDER,
LIGHT_GRAY_CONCRETE_POWDER,
CYAN_CONCRETE_POWDER,
PURPLE_CONCRETE_POWDER,
BLUE_CONCRETE_POWDER,
BROWN_CONCRETE_POWDER,
GREEN_CONCRETE_POWDER,
RED_CONCRETE_POWDER,
BLACK_CONCRETE_POWDER,
TURTLE_EGG,
DEAD_TUBE_CORAL_BLOCK,
DEAD_BRAIN_CORAL_BLOCK,
DEAD_BUBBLE_CORAL_BLOCK,
DEAD_FIRE_CORAL_BLOCK,
DEAD_HORN_CORAL_BLOCK,
TUBE_CORAL_BLOCK,
BRAIN_CORAL_BLOCK,
BUBBLE_CORAL_BLOCK,
FIRE_CORAL_BLOCK,
HORN_CORAL_BLOCK,
TUBE_CORAL,
BRAIN_CORAL,
BUBBLE_CORAL,
FIRE_CORAL,
HORN_CORAL,
DEAD_BRAIN_CORAL,
DEAD_BUBBLE_CORAL,
DEAD_FIRE_CORAL,
DEAD_HORN_CORAL,
DEAD_TUBE_CORAL,
TUBE_CORAL_FAN,
BRAIN_CORAL_FAN,
BUBBLE_CORAL_FAN,
FIRE_CORAL_FAN,
HORN_CORAL_FAN,
DEAD_TUBE_CORAL_FAN,
DEAD_BRAIN_CORAL_FAN,
DEAD_BUBBLE_CORAL_FAN,
DEAD_FIRE_CORAL_FAN,
DEAD_HORN_CORAL_FAN,
BLUE_ICE,
CONDUIT,
POLISHED_GRANITE_STAIRS,
SMOOTH_RED_SANDSTONE_STAIRS,
MOSSY_STONE_BRICK_STAIRS,
POLISHED_DIORITE_STAIRS,
MOSSY_COBBLESTONE_STAIRS,
END_STONE_BRICK_STAIRS,
STONE_STAIRS,
SMOOTH_SANDSTONE_STAIRS,
SMOOTH_QUARTZ_STAIRS,
GRANITE_STAIRS,
ANDESITE_STAIRS,
RED_NETHER_BRICK_STAIRS,
POLISHED_ANDESITE_STAIRS,
DIORITE_STAIRS,
POLISHED_GRANITE_SLAB,
SMOOTH_RED_SANDSTONE_SLAB,
MOSSY_STONE_BRICK_SLAB,
POLISHED_DIORITE_SLAB,
MOSSY_COBBLESTONE_SLAB,
END_STONE_BRICK_SLAB,
SMOOTH_SANDSTONE_SLAB,
SMOOTH_QUARTZ_SLAB,
GRANITE_SLAB,
ANDESITE_SLAB,
RED_NETHER_BRICK_SLAB,
POLISHED_ANDESITE_SLAB,
DIORITE_SLAB,
SCAFFOLDING,
IRON_DOOR,
OAK_DOOR,
SPRUCE_DOOR,
BIRCH_DOOR,
JUNGLE_DOOR,
ACACIA_DOOR,
DARK_OAK_DOOR,
REPEATER,
COMPARATOR,
STRUCTURE_BLOCK,
JIGSAW,
COMPOSTER,
TURTLE_HELMET,
SCUTE,
IRON_SHOVEL,
IRON_PICKAXE,
IRON_AXE,
FLINT_AND_STEEL,
APPLE,
BOW,
ARROW,
COAL,
CHARCOAL,
DIAMOND,
IRON_INGOT,
GOLD_INGOT,
IRON_SWORD,
WOODEN_SWORD,
WOODEN_SHOVEL,
WOODEN_PICKAXE,
WOODEN_AXE,
STONE_SWORD,
STONE_SHOVEL,
STONE_PICKAXE,
STONE_AXE,
DIAMOND_SWORD,
DIAMOND_SHOVEL,
DIAMOND_PICKAXE,
DIAMOND_AXE,
STICK,
BOWL,
MUSHROOM_STEW,
GOLDEN_SWORD,
GOLDEN_SHOVEL,
GOLDEN_PICKAXE,
GOLDEN_AXE,
STRING,
FEATHER,
GUNPOWDER,
WOODEN_HOE,
STONE_HOE,
IRON_HOE,
DIAMOND_HOE,
GOLDEN_HOE,
WHEAT_SEEDS,
WHEAT,
BREAD,
LEATHER_HELMET,
LEATHER_CHESTPLATE,
LEATHER_LEGGINGS,
LEATHER_BOOTS,
CHAINMAIL_HELMET,
CHAINMAIL_CHESTPLATE,
CHAINMAIL_LEGGINGS,
CHAINMAIL_BOOTS,
IRON_HELMET,
IRON_CHESTPLATE,
IRON_LEGGINGS,
IRON_BOOTS,
DIAMOND_HELMET,
DIAMOND_CHESTPLATE,
DIAMOND_LEGGINGS,
DIAMOND_BOOTS,
GOLDEN_HELMET,
GOLDEN_CHESTPLATE,
GOLDEN_LEGGINGS,
GOLDEN_BOOTS,
FLINT,
PORKCHOP,
COOKED_PORKCHOP,
PAINTING,
GOLDEN_APPLE,
ENCHANTED_GOLDEN_APPLE,
OAK_SIGN,
SPRUCE_SIGN,
BIRCH_SIGN,
JUNGLE_SIGN,
ACACIA_SIGN,
DARK_OAK_SIGN,
BUCKET,
WATER_BUCKET,
LAVA_BUCKET,
MINECART,
SADDLE,
REDSTONE,
SNOWBALL,
OAK_BOAT,
LEATHER,
MILK_BUCKET,
PUFFERFISH_BUCKET,
SALMON_BUCKET,
COD_BUCKET,
TROPICAL_FISH_BUCKET,
BRICK,
CLAY_BALL,
SUGAR_CANE,
KELP,
DRIED_KELP_BLOCK,
BAMBOO,
PAPER,
BOOK,
SLIME_BALL,
CHEST_MINECART,
FURNACE_MINECART,
EGG,
COMPASS,
FISHING_ROD,
CLOCK,
GLOWSTONE_DUST,
COD,
SALMON,
TROPICAL_FISH,
PUFFERFISH,
COOKED_COD,
COOKED_SALMON,
INK_SAC,
RED_DYE,
GREEN_DYE,
COCOA_BEANS,
LAPIS_LAZULI,
PURPLE_DYE,
CYAN_DYE,
LIGHT_GRAY_DYE,
GRAY_DYE,
PINK_DYE,
LIME_DYE,
YELLOW_DYE,
LIGHT_BLUE_DYE,
MAGENTA_DYE,
ORANGE_DYE,
BONE_MEAL,
BLUE_DYE,
BROWN_DYE,
BLACK_DYE,
WHITE_DYE,
BONE,
SUGAR,
CAKE,
WHITE_BED,
ORANGE_BED,
MAGENTA_BED,
LIGHT_BLUE_BED,
YELLOW_BED,
LIME_BED,
PINK_BED,
GRAY_BED,
LIGHT_GRAY_BED,
CYAN_BED,
PURPLE_BED,
BLUE_BED,
BROWN_BED,
GREEN_BED,
RED_BED,
BLACK_BED,
COOKIE,
FILLED_MAP,
SHEARS,
MELON_SLICE,
DRIED_KELP,
PUMPKIN_SEEDS,
MELON_SEEDS,
BEEF,
COOKED_BEEF,
CHICKEN,
COOKED_CHICKEN,
ROTTEN_FLESH,
ENDER_PEARL,
BLAZE_ROD,
GHAST_TEAR,
GOLD_NUGGET,
NETHER_WART,
POTION,
GLASS_BOTTLE,
SPIDER_EYE,
FERMENTED_SPIDER_EYE,
BLAZE_POWDER,
MAGMA_CREAM,
BREWING_STAND,
CAULDRON,
ENDER_EYE,
GLISTERING_MELON_SLICE,
BAT_SPAWN_EGG,
BEE_SPAWN_EGG,
BLAZE_SPAWN_EGG,
CAT_SPAWN_EGG,
CAVE_SPIDER_SPAWN_EGG,
CHICKEN_SPAWN_EGG,
COD_SPAWN_EGG,
COW_SPAWN_EGG,
CREEPER_SPAWN_EGG,
DOLPHIN_SPAWN_EGG,
DONKEY_SPAWN_EGG,
DROWNED_SPAWN_EGG,
ELDER_GUARDIAN_SPAWN_EGG,
ENDERMAN_SPAWN_EGG,
ENDERMITE_SPAWN_EGG,
EVOKER_SPAWN_EGG,
FOX_SPAWN_EGG,
GHAST_SPAWN_EGG,
GUARDIAN_SPAWN_EGG,
HORSE_SPAWN_EGG,
HUSK_SPAWN_EGG,
LLAMA_SPAWN_EGG,
MAGMA_CUBE_SPAWN_EGG,
MOOSHROOM_SPAWN_EGG,
MULE_SPAWN_EGG,
OCELOT_SPAWN_EGG,
PANDA_SPAWN_EGG,
PARROT_SPAWN_EGG,
PHANTOM_SPAWN_EGG,
PIG_SPAWN_EGG,
PILLAGER_SPAWN_EGG,
POLAR_BEAR_SPAWN_EGG,
PUFFERFISH_SPAWN_EGG,
RABBIT_SPAWN_EGG,
RAVAGER_SPAWN_EGG,
SALMON_SPAWN_EGG,
SHEEP_SPAWN_EGG,
SHULKER_SPAWN_EGG,
SILVERFISH_SPAWN_EGG,
SKELETON_SPAWN_EGG,
SKELETON_HORSE_SPAWN_EGG,
SLIME_SPAWN_EGG,
SPIDER_SPAWN_EGG,
SQUID_SPAWN_EGG,
STRAY_SPAWN_EGG,
TRADER_LLAMA_SPAWN_EGG,
TROPICAL_FISH_SPAWN_EGG,
TURTLE_SPAWN_EGG,
VEX_SPAWN_EGG,
VILLAGER_SPAWN_EGG,
VINDICATOR_SPAWN_EGG,
WANDERING_TRADER_SPAWN_EGG,
WITCH_SPAWN_EGG,
WITHER_SKELETON_SPAWN_EGG,
WOLF_SPAWN_EGG,
ZOMBIE_SPAWN_EGG,
ZOMBIE_HORSE_SPAWN_EGG,
ZOMBIE_PIGMAN_SPAWN_EGG,
ZOMBIE_VILLAGER_SPAWN_EGG,
EXPERIENCE_BOTTLE,
FIRE_CHARGE,
WRITABLE_BOOK,
WRITTEN_BOOK,
EMERALD,
ITEM_FRAME,
FLOWER_POT,
CARROT,
POTATO,
BAKED_POTATO,
POISONOUS_POTATO,
MAP,
GOLDEN_CARROT,
SKELETON_SKULL,
WITHER_SKELETON_SKULL,
PLAYER_HEAD,
ZOMBIE_HEAD,
CREEPER_HEAD,
DRAGON_HEAD,
CARROT_ON_A_STICK,
NETHER_STAR,
PUMPKIN_PIE,
FIREWORK_ROCKET,
FIREWORK_STAR,
ENCHANTED_BOOK,
NETHER_BRICK,
QUARTZ,
TNT_MINECART,
HOPPER_MINECART,
PRISMARINE_SHARD,
PRISMARINE_CRYSTALS,
RABBIT,
COOKED_RABBIT,
RABBIT_STEW,
RABBIT_FOOT,
RABBIT_HIDE,
ARMOR_STAND,
IRON_HORSE_ARMOR,
GOLDEN_HORSE_ARMOR,
DIAMOND_HORSE_ARMOR,
LEATHER_HORSE_ARMOR,
LEAD,
NAME_TAG,
COMMAND_BLOCK_MINECART,
MUTTON,
COOKED_MUTTON,
WHITE_BANNER,
ORANGE_BANNER,
MAGENTA_BANNER,
LIGHT_BLUE_BANNER,
YELLOW_BANNER,
LIME_BANNER,
PINK_BANNER,
GRAY_BANNER,
LIGHT_GRAY_BANNER,
CYAN_BANNER,
PURPLE_BANNER,
BLUE_BANNER,
BROWN_BANNER,
GREEN_BANNER,
RED_BANNER,
BLACK_BANNER,
END_CRYSTAL,
CHORUS_FRUIT,
POPPED_CHORUS_FRUIT,
BEETROOT,
BEETROOT_SEEDS,
BEETROOT_SOUP,
DRAGON_BREATH,
SPLASH_POTION,
SPECTRAL_ARROW,
TIPPED_ARROW,
LINGERING_POTION,
SHIELD,
ELYTRA,
SPRUCE_BOAT,
BIRCH_BOAT,
JUNGLE_BOAT,
ACACIA_BOAT,
DARK_OAK_BOAT,
TOTEM_OF_UNDYING,
SHULKER_SHELL,
IRON_NUGGET,
KNOWLEDGE_BOOK,
DEBUG_STICK,
MUSIC_DISC_13,
MUSIC_DISC_CAT,
MUSIC_DISC_BLOCKS,
MUSIC_DISC_CHIRP,
MUSIC_DISC_FAR,
MUSIC_DISC_MALL,
MUSIC_DISC_MELLOHI,
MUSIC_DISC_STAL,
MUSIC_DISC_STRAD,
MUSIC_DISC_WARD,
MUSIC_DISC_11,
MUSIC_DISC_WAIT,
TRIDENT,
PHANTOM_MEMBRANE,
NAUTILUS_SHELL,
HEART_OF_THE_SEA,
CROSSBOW,
SUSPICIOUS_STEW,
LOOM,
FLOWER_BANNER_PATTERN,
CREEPER_BANNER_PATTERN,
SKULL_BANNER_PATTERN,
MOJANG_BANNER_PATTERN,
GLOBE_BANNER_PATTERN,
BARREL,
SMOKER,
BLAST_FURNACE,
CARTOGRAPHY_TABLE,
FLETCHING_TABLE,
GRINDSTONE,
LECTERN,
SMITHING_TABLE,
STONECUTTER,
BELL,
LANTERN,
SWEET_BERRIES,
CAMPFIRE,
HONEYCOMB,
BEE_NEST,
BEEHIVE,
HONEY_BOTTLE,
HONEY_BLOCK,
HONEYCOMB_BLOCK;
private static Short2ObjectOpenHashMap<Material> idToMaterial = new Short2ObjectOpenHashMap<>();
private short materialId;
private Block block;
public static Material fromId(short id) {
return idToMaterial.get(id);
}
public void setIdentifier(short materialId, Block block) {
this.materialId = materialId;
this.block = block;
idToMaterial.put(materialId, this);
}
public boolean isBlock() {
return block != null && this != AIR;
}
public Block getBlock() {
return block;
}
public boolean isHelmet() {
return toString().endsWith("HELMET");
}
public boolean isChestplate() {
return toString().endsWith("CHESTPLATE");
}
public boolean isLeggings() {
return toString().endsWith("LEGGINGS");
}
public boolean isBoots() {
return toString().endsWith("BOOTS");
}
public boolean isArmor() {
return isHelmet() || isChestplate() ||
isLeggings() || isBoots();
}
public boolean isFood() {
switch (this) {
case APPLE:
case MUSHROOM_STEW:
case BREAD:
case PORKCHOP:
case COOKED_PORKCHOP:
case GOLDEN_APPLE:
case ENCHANTED_GOLDEN_APPLE:
case COD:
case SALMON:
case TROPICAL_FISH:
case PUFFERFISH:
case COOKED_COD:
case COOKED_SALMON:
case CAKE:
case COOKIE:
case MELON_SLICE:
case DRIED_KELP:
case BEEF:
case COOKED_BEEF:
case CHICKEN:
case COOKED_CHICKEN:
case ROTTEN_FLESH:
case SPIDER_EYE:
case CARROT:
case POTATO:
case BAKED_POTATO:
case POISONOUS_POTATO:
case PUMPKIN_PIE:
case RABBIT:
case COOKED_RABBIT:
case RABBIT_STEW:
case MUTTON:
case COOKED_MUTTON:
case BEETROOT:
case BEETROOT_SOUP:
case SWEET_BERRIES:
case HONEY_BOTTLE:
return true;
default:
return false;
}
}
public boolean hasState() {
switch (this) {
case BOW:
case TRIDENT:
case CROSSBOW:
case SHIELD:
return true;
}
return isFood();
}
public short getId() {
return materialId;
}
}

View File

@ -49,27 +49,6 @@ public class RegistryMain {
writePotionsClass(potions);
}
public static void registerItems() {
List<RegistryItem> items = parseItems(ITEMS_PATH);
for (RegistryItem registryItem : items) {
Material material = Material.valueOf(registryItem.name);
try {
Block block = Block.valueOf(registryItem.name);
material.setIdentifier(registryItem.itemId, block);
} catch (IllegalArgumentException e) {
switch (material) {
case REDSTONE:
material.setIdentifier(registryItem.itemId, Block.REDSTONE_WIRE);
break;
default:
material.setIdentifier(registryItem.itemId, null);
break;
}
}
}
}
public static void registerEntities() {
List<RegistryEntityType> registryEntityTypes = parseEntities(ENTITIES_PATH);