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

I have an item that takes damage when you use it to craft things.

The problem is when I put 2 of them in a crafting table (like in vanilla how you can combine them for more durability), this happens:

rcrsZlL.gif

I can just keep crafting them.

 

Here is the item class:

http://pastebin.com/p3EYBhU8

  • Author

Well, yes of course you can. You specified for them to have a container item...

Is there a way to make it so it does take damage but does not do the thing I described?

I changed so it doesn't have a container item, but it doesn't take damage,. It takes the whole item.

  • Author

Ok, please describe exactly what you want to happen, I am having difficulty understanding what you want.

 

 

The hammer is used in crafting. It takes durability when you use it while crafting. That works.

If you take 2 tools in vanilla and put the together, they both combine.

If you take 2 hammers and put them together, they just keep making more.

This is what I mean: https://gyazo.com/9f72ca4eac19b6480703d6334948fbff

It just lets me make more.

I was wondering how do I not make it repairable like that?

  • Author

I see. So you want it to have a container item in one recipe but not in the other. You will have to make a custom IRecipe then and override getRemainingItems in there. The easiest would be to extend ShapedOreRecipe and just override that one method.

 

I override getRemainingItems, but what do I put in there?

I have:

	@Override
public ItemStack[] getRemainingItems(InventoryCrafting p_179532_1_) {
	return null;
}

I'm still kinda new to programming so please excuse me.

  • Author

Look at the default implementation (e.g. ForgeHooks.defaultRecipeGetRemainingItems) and modify it for your needs.

I found it. But I never worked with inventory things before.

    public static ItemStack[] defaultRecipeGetRemainingItems(InventoryCrafting inv)
    {
        ItemStack[] ret = new ItemStack[inv.getSizeInventory()];
        for (int i = 0; i < ret.length; i++)
        {
            ret[i] = getContainerItem(inv.getStackInSlot(i));
        }
        return ret;
    }

 

That is what I found.

The only part I don't understand is what do I need to change?

  • Author

Do you understand what the code does? Then explain it to me in your own words. Do not just read out line by line the code. Explain the function of the code itself.

I guess I don't know that much of java.

I understand some of it.

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.