TerraFirmaCraft

TerraFirmaCraft

2M Downloads

NBT issues with filling molds.

Claycorp opened this issue ยท 3 comments

commented
  1. What did you expect to happen?
    Forge to give an item that is the same as the pit kiln item.
  2. What actually happened instead (i.e. what was the bug)
    Pitkiln Item: tfc:ceramics/fired/mold/ingot.withTag({heat: 1404.7 as float, FluidName: "gold", ticks: 10101 as long, Amount: 100})
    Forge Item: tfc:ceramics/fired/mold/ingot
    F3+H also shows the pitkiln item with 4 NBT tags while the forge one has none.

To Reproduce

  1. Melt a metal in a pitkiln and fill a ingot mold.
  2. Melt a metal in a forge and fill an ingot mold.
  3. Compare.

Meta Info

  • TFC Version: 0.23.7.74
commented

The current unmold recipes should be adapted to use this ingredient, which will split the recipes out by metal type.

That would fix another issue too: JEI not showing unmold recipes' output for every metal, so this fix would be awesome

commented

After some inspection, NBT is not meant to appear on the stack. The problem is here:

stack.setTagCompound(((IMoldHandler) capFluidHandler).serializeNBT());

Those two lines need to be removed.

However, that will highlight another issue, which is that stack NBT can't be used to differentiate molds (i.e. for craft tweaker recipes). I think the best solution would be to create a custom ingredient type: IngredientFluidHeatStack.It would need to be capable of specifying and checking for a heat capability (min / max temp, or molten), and a fluid capability (fluid name, min / max amount. The current unmold recipes should be adapted to use this ingredient, which will split the recipes out by metal type.

commented

So after doing some research, I'm not as convinced about the proposed solution. There's two options: Using capability NBT only, or duplicating the NBT on the stack (ItemStack#setTagInfo):

  • Cap NBT is saved separately, automatically by forge. It is not synced (we have our own handlers for that, which work everywhere except in creative, which there's no possible way to sync). It can't be used through craft tweaker, as it's separate from stack NBT.
  • Stack NBT needs to be saved manually. It is synced (any changes are detected by vanilla.) It can be used with standard NBT sensitive recipes.

I'd like to have a consistent approach to dealing with cap NBT (and whether or not to save it to stack NBT). As of currently, the vast majority of food / heat / forging / etc. capability data is saved only to cap nbt. The above example is the exception that I have found. So changing to stack NBT would require tracking down a number of cases that need to have item stack references held on to, and save checks added.

Finally, there are some situations we already use stack NBT: saving barrel inventory to a stack, item handler items (i.e. vessels) copy to NBT to avoid the aforementioned sync issues. (Further reading: MinecraftForge/MinecraftForge#3283 and related issues / PRs