Hazmatik Posted April 13, 2018 Posted April 13, 2018 (edited) I have 10 different ores that can be smelted into 10 different ingots and I am using metadata variants for the ore blocks and also for the ingots. I set up smelting recipes and the recipes are working just fine the ores all smelt into the correct ingots, however if I shift + click the resulting ingot out of a furnace it turns into a copper ingot which is the ingot with a metadata value of 0. I'm not sure if it's something I'm missing in my ItemIngot class or something to do with the SmeltingRecipes class. ItemIngot class: package hazmatik.sonictech.items; import hazmatik.sonictech.SonicTech; import hazmatik.sonictech.init.ItemInit; import hazmatik.sonictech.util.interfaces.IHasModel; import hazmatik.sonictech.util.interfaces.IMetaName; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.IStringSerializable; import net.minecraft.util.NonNullList; public class ItemIngot extends Item implements IHasModel, IMetaName { private String name; public ItemIngot(String name) { setUnlocalizedName(name); setRegistryName(name); setCreativeTab(SonicTech.sonictechtab); this.name = name; ItemInit.ITEMS.add(this); } @Override public void getSubItems(CreativeTabs tab, NonNullList<ItemStack> items) { for(int i = 0; i < Type.METADATA_LOOKUP.length; i++) { items.add(new ItemStack(this, 1, i)); } } @Override public String getSpecialName(ItemStack stack) { return Type.values()[stack.getItemDamage()].getName(); } @Override public String getUnlocalizedName(ItemStack stack) { return super.getUnlocalizedName() + "_" + this.getSpecialName(stack); } @Override public void registerModels() { for(int i = 0; i < Type.METADATA_LOOKUP.length; i++) { SonicTech.proxy.registerVariantRenderer(this, i, "ingot_" + Type.values()[i].getName(), "inventory"); } } public enum Type implements IStringSerializable { COPPER(0, "copper"), ALUMINIUM(1, "aluminium"), ZINC(2, "zinc"), TIN(3, "tin"), ANTIMONY(4, "antimony"), MOLYBDENUM(5, "molybdenum"), LEAD(6, "lead"), SILVER(7, "silver"), CHROMIUM(8, "chromium"), MAGNESIUM(9, "magnesium"); private static final Type[] METADATA_LOOKUP = new Type[values().length]; private final int metadata; private final String name; Type(int metadata, String name) { this.metadata=metadata; this.name=name; } public int getMetadata() { return this.metadata; } @Override public String getName() { return this.name; } public static Type byMetadata(int metadata) { if(metadata < 0 || metadata >= METADATA_LOOKUP.length) { metadata = 0; } return METADATA_LOOKUP[metadata]; } static { for(Type type: values()) { METADATA_LOOKUP[type.getMetadata()] = type; } } } } and my SmeltingRecipes class: public class SmeltingRecipes { public static void init() { GameRegistry.addSmelting(new ItemStack(BlockInit.ORE, 1, 0), new ItemStack(ItemInit.INGOT, 1, 0), 0.7f); GameRegistry.addSmelting(new ItemStack(BlockInit.ORE, 1, 1), new ItemStack(ItemInit.INGOT, 1, 1), 0.7f); GameRegistry.addSmelting(new ItemStack(BlockInit.ORE, 1, 2), new ItemStack(ItemInit.INGOT, 1, 2), 0.7f); GameRegistry.addSmelting(new ItemStack(BlockInit.ORE, 1, 3), new ItemStack(ItemInit.INGOT, 1, 3), 0.7f); GameRegistry.addSmelting(new ItemStack(BlockInit.ORE, 1, 4), new ItemStack(ItemInit.INGOT, 1, 4), 0.7f); GameRegistry.addSmelting(new ItemStack(BlockInit.ORE, 1, 5), new ItemStack(ItemInit.INGOT, 1, 5), 0.7f); GameRegistry.addSmelting(new ItemStack(BlockInit.ORE, 1, 6), new ItemStack(ItemInit.INGOT, 1, 6), 0.7f); GameRegistry.addSmelting(new ItemStack(BlockInit.ORE, 1, 7), new ItemStack(ItemInit.INGOT, 1, 7), 0.7f); GameRegistry.addSmelting(new ItemStack(BlockInit.ORE, 1, 8), new ItemStack(ItemInit.INGOT, 1, 8), 0.7f); GameRegistry.addSmelting(new ItemStack(BlockInit.ORE, 1, 9), new ItemStack(ItemInit.INGOT, 1, 9), 0.7f); } } If anyone needs to see more of my code my github repo for the project is here: https://github.com/Hazmatik/SonicTech EDIT: I don't think this is particularly related to smelting cause I just noticed any shift+click moving of the ingots even between hotbar and inventory if there is already a stack of an ingot type it will change to whichever type is there. Edited April 13, 2018 by Hazmatik Changed title to relate better to issue Quote
Draco18s Posted April 13, 2018 Posted April 13, 2018 Your Item class is broken. You need to call Item::setHasSubtypes(true) https://github.com/Draco18s/ReasonableRealism/blob/1.12.1/src/main/java/com/draco18s/ores/item/ItemDustSmall.java#L23 Quote Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.