TerraFirmaCraft

TerraFirmaCraft

2M Downloads

Item vanishes after completing smiting minigame successfully

Dan-Gecko opened this issue ยท 8 comments

commented

Describe the bug
Ingots made from Black Bronze poured in fired ceramic molds from the crucible vanish upon completion of the smiting mini game in a black bronze anvil successfully instead of giving the expected item. Happens to anything using the smiting mini game to complete. Also double ingots as input vanish and give no result after completing the smiting mini game.

To Reproduce
Attention to detail is important!

  1. have an ingot/double ingot of Black Bronze at temperature (work or weld)
  2. put ingot in anvil and select a plan in a black bronze anvil
  3. complete the smiting mini game successfully.

the ingot/double ingot will vanish and the output slot will be empty.

Meta Info
TFC Version: TerraFirmaCraft-MC1.12.2-1.0.9.137
other mods where

  1. theoneprobe-1.12-1.4.28
  2. NotEnoughItems-1.12.2-2.4.3.245-universal
  3. jei_1.12.2-4.15.0.291
  4. journeymap-1.12.2-5.7.1
  5. CodeChickenLib-1.12.2-3.2.3.358-universal
commented

Can you confirm this doesn't happen in 136?

commented

In 136 with another save file it works as intended. Though with Bith-Bronze - not Black Bronze. Anything else was the same (i.e. mod versions).

commented

Do you have the full log? I was just able to reproduce this and am curious where it may be going wrong.

commented

Not sure what a 'full' log is. I have a "latest.log" with 727 KB and a "debug.log" with 3.07 MB in size. Both are attached.
latest.log
debug.log

commented

also there are several "*.log.gz"-files with a date as a file name.

commented

That's exactly what I was looking for. This is an issue:

Caused by: java.lang.NullPointerException
	at net.dries007.tfc.objects.te.TEAnvilTFC.addStep(TEAnvilTFC.java:267) ~[TEAnvilTFC.class:?]
	at net.dries007.tfc.objects.container.ContainerAnvilTFC.onButtonPress(ContainerAnvilTFC.java:52) ~[ContainerAnvilTFC.class:?]
	at net.dries007.tfc.network.PacketGuiButton$Handler.lambda$onMessage$0(PacketGuiButton.java:79) ~[PacketGuiButton$Handler.class:?]
	at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) ~[?:1.8.0_231]
	at java.util.concurrent.FutureTask.run(Unknown Source) ~[?:1.8.0_231]
	at net.minecraft.util.Util.func_181617_a(SourceFile:46) ~[h.class:?]
commented

I'm glad you where able to identify it. May I provide any further information to help the progress of fixing this bug?

commented

The issue:
f9d309b added a setAndUpdateSlots which is called (indirectly), through here:

inventory.setStackInSlot(SLOT_INPUT_1, ItemStack.EMPTY);

which sets the recipe to null, resulting in the seen NPE.

The fix:

  • Adding the additional setAndUpdateSlots call was necessary, as it really should've been there, except the rest of our inventory handling was designed around it not being there.
  • Ultimately what needs to change (and I'm not sure if there are other places which will be affected by this change) is that the anvil needs to defensively code around the fact that when modifying the inventory the recipe will update, even during partial transactions. This means something like
AnvilRecipe currentRecipe = cachedRecipe;
if (currentRecipe != null) {
  inventory.whatever(); // modifies cachedRecipe!
  // use currentRecipe here

and there may be other places where this, or similar issues arise, and will need to be solved in much the same way.

Edit: seems like both fire pits and querns will be affected by this change, none others that I or Moo saw.