Jump to content

Having a item that will get damaged when used in crafting


rex41043

Recommended Posts

try using some of the code that I already made,

put

GameRegistry.registerCraftingHandler(new NewCraftingHandler());

into your base class PreInit Method

 

Then, you will need to have something check all your inv slots:

public class NewCraftingHandler implements ICraftingHandler {

public NewCraftingHandler() {
}
@Override
public void onCrafting(EntityPlayer player, ItemStack item, IInventory inv) 
{
	for(int i=0; i < inv.getSizeInventory(); i++)
	{
		if(inv.getStackInSlot(i) != null)
		{
			ItemStack j = inv.getStackInSlot(i);
			if(j.getItem() != null && j.getItem() == TestMod.item)
			{
				ItemStack k = new ItemStack(TestMod.item, 2, (j.getItemDamage() + 1));//makes 2 items, 1 that is used and 1 that is damaged
					inv.setInventorySlotContents(i, k);//i is slot, k is Item
				}
			}
		}
	}
}

@Override
public void onSmelting(EntityPlayer player, ItemStack item) {

}

}

then press ctrl + Shift + O, and that will import all needed things

Hope this helps!

 

The Korecraft Mod

Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.