Posted July 12, 201510 yr I'm working on my first mod, and I'm trying to make it so that when you craft item A with item B, you get item C, but you also get item A back, such as the bucket back from the milk bucket in the cake recipe. I'm using the this.setContainerItem, but it doesn't work. This is the code from my item A, Gemcutter's Knife, class: package thegoldcrayon.thegoldcrayonsgemstonesmod; import net.minecraft.item.Item; public class ItemGemcuttersKnife extends Item { public ItemGemcuttersKnife(){ this.setFull3D(); this.setMaxStackSize(1); this.setContainerItem(TheGoldCrayonsGemstonesMod.itemGemcuttersKnife); } } I can't seem to figure this out. Any help? "War doesn't determine who is right. Only who is left." -Bertrand Russell
July 12, 201510 yr You need to set the container item for the OTHER item, so if you craft A + B = C and B is consumed, then you need to set C's container item to A. You don't set A's container item to A, nor C's to C, which it looks like you are doing with your knife. Also, if you want to force the container item to remain in the crafting grid rather than getting added to the player's inventory, you can override Item#doesContainerItemLeaveCraftingGrid to return false (in item C). http://i.imgur.com/NdrFdld.png[/img]
July 12, 201510 yr Author I put the .setContainerItem(A) in C's class, but that didn't do anything. How would I set up the #doesContainerItemLeaveCraftingGrid? "War doesn't determine who is right. Only who is left." -Bertrand Russell
July 12, 201510 yr I put the .setContainerItem(A) in C's class, but that didn't do anything. How would I set up the #doesContainerItemLeaveCraftingGrid? Override it in your Item class and return false. If you don't know what that means, Google it. C.setContainerItem(A) should have worked - are both A and C your items (i.e. not vanilla)? If so, then it's possible that you didn't initialize A before C, in which case when you initialize C the container item is simply set to null: public static Item A, B, C; // these are all null right now @EventHandler public void preInit(FMLPreInitializationEvent event) { C = new ItemC(); // C is initialized first, but right now A is still null!!! uh oh! A = new ItemA(); // now A is initialized, but it's too late - C has already been initialized with a null container item B = new ItemB(); } Obviously, switching the order of initialization should fix your problem. http://i.imgur.com/NdrFdld.png[/img]
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.