LibBlockAttributes icon indicating copy to clipboard operation
LibBlockAttributes copied to clipboard

java.lang.IllegalStateException: The ItemStack that is stored has been changed! Made the game crash once and don't know how to reproduce it

Open natanfudge opened this issue 5 years ago • 5 comments

This happened when creating a new instance of a block entity that is an inventory provider. https://hasteb.in/woxupaqa.yaml

natanfudge avatar Aug 12 '19 20:08 natanfudge

spatialcrafting.hologram.HologramBlock.activate(HologramBlock.kt:104)

However when I look at the source:

100 | hologramEntity.insertItem(player.getStackInHand(hand)) // is it crashing here?
101 | if (!player.isCreative) player.getStackInHand(hand).count--
102 |  logDebug {
103 |   "Inserted item into hologram. New Content: " + hologramEntity.getItem()
104 |  } // When it ways it's crashing here?
105 | }

Do you know what version of the source this crash report was generated with?

Also, in the title you said it crashed once - has this happened multiple times, or are you just not sure how to make it happen again? (Or are there any other reproduction steps needed to make this happen?)

AlexIIL avatar Aug 12 '19 21:08 AlexIIL

Do you know what version of the source this crash report was generated with?

it had not been pushed yet. I will push it tomorrow.

Also, in the title you said it crashed once - has this happened multiple times, or are you just not sure how to make it happen again? (Or are there any other reproduction steps needed to make this happen?)

The error occured exactly once, during a common operation, seemingly for no reason. It occured when a HologramBlockEntity which is an inventory provider was created as part of a multiblock in my mod.

natanfudge avatar Aug 12 '19 22:08 natanfudge

Looking at the stack trace it seems that maybe I had accidentally inserted an item as the hologram was created (which still shouldn’t crash). What does the error you throw here mean about the situation?

natanfudge avatar Aug 12 '19 22:08 natanfudge

The first stack trace is the exception that was actually thrown (and crashed the game).

The second stack trace was the first call stack that marked that item stack instance to be "unmodifiable".

(This basically tracks item stack instances to determine if one has been added to an inventory, and then changed without telling the inventory that it should be changed).

AlexIIL avatar Aug 12 '19 22:08 AlexIIL

https://github.com/natanfudge/SpatialCrafting/blob/1160b964dc5b22d70fa13357d62280222d849a00/src/main/kotlin/spatialcrafting/hologram/HologramBlock.kt#L101

Should be right there, the lines moved a bit.

natanfudge avatar Aug 13 '19 08:08 natanfudge