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 a smelting recipe that needs to copy its input's NBT data to its output. I tried to use a custom IRecipe for that like I did for similar crafting recipes, but the smelting code in TileEntityFurnace does not respect getCraftingResult() at all. It only uses getRecipeOutput() as such (which is normally for display purposes)

ItemStack itemstack = this.furnaceItemStacks.get(0);
ItemStack itemstack1 = recipe.getRecipeOutput();
ItemStack itemstack2 = this.furnaceItemStacks.get(2);
if (itemstack2.isEmpty()) {
   this.furnaceItemStacks.set(2, itemstack1.copy());
} else if (itemstack2.getItem() == itemstack1.getItem()) {
   itemstack2.grow(itemstack1.getCount());
}

So I cannot set the NBT data of the output ItemStack.

 

I also tried using a PlayerEvent.ItemSmeltedEvent, however that event does not give me any handle to the input, it only has the output. So I cannot read the input's NBT in this way.

 

Is there another way to do what I am trying to achieve other than creating infinite JSONs or editing the vanilla furnace code?

Edited by xerca

  • Author
2 hours ago, diesieben07 said:

One very hacky way would be to "remember" the furnace inside the IRecipe#matches version and use that to return the proper item in getRecipeOutput.

You would have to reset this at some point though. Some experimenting is probably needed.

Unfortunately I don't have any way of knowing which furnace is calling getRecipeOutput, so this would probably only work if there is just one active furnace in the whole world at a time :(.

  • Author

Thank you, you're right, it calls matches continously a few lines before getting the output. Assuming the main game code runs in a single thread, hopefully there will be no race conditions. I got away with just remembering the required NBT value of the itemstack. It seems to work for now, although it is one of the more bizarre workarounds I did. I hope forge adds a way to do this normally in the future.

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.