package me.km.blocks; import me.km.items.ModItems; import net.minecraft.block.material.MapColor; import net.minecraft.init.Items; import net.minecraft.item.Item; import net.minecraft.util.IStringSerializable; public enum EnumMetals implements IStringSerializable { COPPER(0, "copper", MapColor.BROWN, ModItems.copperIngot), TIN(1, "tin", MapColor.SILVER, ModItems.tinIngot), BRONZE(2, "bronze", MapColor.YELLOW, ModItems.bronzeIngot), GOLD(3, "gold", MapColor.GOLD, Items.GOLD_INGOT), IRON(4, "iron", MapColor.IRON, Items.IRON_INGOT), SILVER(5, "silver", MapColor.SILVER, ModItems.silverIngot); private static final EnumMetals[] META_LOOKUP = new EnumMetals[values().length]; private final int meta; private final String name; private final MapColor mapColor; private Item item; private EnumMetals(int meta, String name, MapColor mapColor, Item item) { this.meta = meta; this.name = name; this.mapColor = mapColor; this.item = item; } public Item getMetalIngot() { return item; } // items become null somehow public static void fixMetalIngots() { COPPER.item = ModItems.copperIngot; TIN.item = ModItems.tinIngot; BRONZE.item = ModItems.bronzeIngot; SILVER.item = ModItems.silverIngot; } public int getMetadata() { return this.meta; } public MapColor getMapColor() { return this.mapColor; } @Override public String toString() { return this.name; } public static EnumMetals byMetadata(int meta) { if (meta < 0 || meta >= META_LOOKUP.length) { meta = 0; } return META_LOOKUP[meta]; } @Override public String getName() { return this.name; } public String getUnlocalizedName() { return this.name; } static { for(EnumMetals metal : values()) { META_LOOKUP[metal.getMetadata()] = metal; } } }