Posted February 24, 201510 yr I'm trying to make a grinder where you put a grinder and one ore and it returns 2 dust. It works to some extent but when i put a whole stack in, it takes the whole stack and only returns 2 dust. Here's my code: Recipe: GameRegistry.addRecipe(new ItemStack (CopperDust, 2), new Object [] { "GO ", " ", " ", 'G', (new ItemStack(AlchemyMain.Grinder, 1, Short.MAX_VALUE)), 'O', AlchemyMain.CopperOre }); Crafting Handler: public class AlchemyCraftingHandler implements ICraftingHandler { @Override public void onCrafting(EntityPlayer player, ItemStack item, IInventory craftMatrix) { for(int i = 0 ; i < craftMatrix.getSizeInventory(); i++) { if(craftMatrix.getStackInSlot(i) != null) { ItemStack j = craftMatrix.getStackInSlotOnClosing(i); if(j.getItem() != null && j.getItem() == AlchemyMain.Grinder) { ItemStack k = new ItemStack(AlchemyMain.Grinder, 2, (j.getItemDamage() + 1)); if(k.getItemDamage() >= k.getMaxDamage()) { k.stackSize--; } craftMatrix.setInventorySlotContents(i, k); } } } } @Override public void onSmelting(EntityPlayer player, ItemStack item) { } } Grinder Class: public class ItemGrinder extends Item { private ItemStack emptyItem = null; public ItemGrinder(int par1, EnumToolMaterial toolGrinder) { super(par1); maxStackSize = 1; this.setMaxDamage(1000); this.setCreativeTab(AlchemyMain.TabAlchemy); } public void registerIcons(IconRegister iconRegister) { itemIcon = iconRegister.registerIcon("alchemy:Grinder"); } } If you need anything else ill post it. Thanks
February 24, 201510 yr Ah, pls use spoiler and code tags. I will have a look at it as soon as I am back at my pc. Ok: You loop through the crafting matrix to find your grinder. Good You get your grinder. Good You set the damage and place it in the correct slot. Good But you never check how many items are crafted. You have to check the output stack size and than add it to the damage from j. Here could be your advertisement!
February 24, 201510 yr Author Ok, that works alright now, but is there a way to leave the grinder in the crafting table and not having it go back to my inventory? btw i used diesieben07's method so i got rid of my crafting handler
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.