Posted March 6, 20196 yr 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 March 7, 20196 yr by xerca
March 7, 20196 yr 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 .
March 7, 20196 yr 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.