Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

Sorry if I seem repetitive, but I can't figure this thing out. I'm making a hammer item that, when crafted with an iron ingot, makes three chains to be used in chainmail armor. However, I want the hammer to not be destroyed during the crafting, instead taking damage. I've looked through TFC's code and can't figure it out, and I've rummaged through Forge itself and couldn't find anything. Some help would be appreciative, thanks.

You have to use an ICraftingHandler to do some funny things with item cloning with one less damage.

So, what would happen if I did push that shiny red button over there? ... Really? ... Can I try it? ... Damn.

  • Author

I know that much, but I can't figure out how. The switch from 1.2.5 to 1.3.2 is killing mine, and every other amateur modder's brains.  :-X

I'll go fetch the code I used to make an object like the one you're attempting to make. It's really quite simple.

Like atrain said, you need a Crafting Handler class, and you need to register it in your main mod class with

GameRegistry.registerCraftingHandler(new Your Crafting Handler());

 

and then inside the crafting handler, which implements ICraftingHandler, your onCrafting method should look a little something like this.

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() == Your Hammer Item)
    		{
    			ItemStack k = new ItemStack(Your Hammer Item, 2, (j.getItemDamage() + 1));
    			inv.setInventorySlotContents(i, k);
    		}
    	}  
	}
}

 

Basically what this does, is run a check every time something is crafted. It looks in every slot and if it finds Your Hammer Item, it replaces that stack with a new stack of 2 of your hammer item, one of which is used up in the crafting. It also adds one damage to the item.

 

Happy Modding :)

  • 1 year later...

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.