age-series / ElectricalAge

Electrical Age (ELN) is a Minecraft Mod offering the ability to perform large-scale in-game electrical simulations.
Other
65 stars 30 forks source link

Fuel burner in heat furnace disappear after world load. #272

Closed MrBigss closed 1 year ago

MrBigss commented 1 year ago

The fuel burner that get inserted in the fuel heat furnace seem to disappear when a world is saved, Minecraft is closed, restarted, and then the world is reloaded. At least in single player. Did not test/confirm with a server.

To reproduce:
Put down a fuel heat furnace, put a small fuel burner in the furnace, save world and quit.
Exit Minecraft. Reload Minecraft, reload the world. The fuel burner inside the fuel heat furnace disappears.

Version tested : ElectricalAge-jrddunbr-1.20.0.jar
Other mods : [Lots]
Tested without other mods : No

I don't think it's a cross mod problem, I think it's more related to the burner data somehow not being saved to disk/inventory not saved, but if needed I could test an instance with just Forge and Electrical Age.

MrBigss commented 1 year ago

Wild guesses:

Is it because in the functions writeToNBT and readFromNBT it doesn't process the inventory? :
(Not sure how this works at all.)

https://github.com/age-series/ElectricalAge/blob/b0731907fa9676288b8565d67395beca8c62c727/src/main/java/mods/eln/transparentnode/FuelHeatFurnace.kt#L223-L232

Is it because the newContainer is not declared the same as within other classes? :

FuelHeatFurnace: https://github.com/age-series/ElectricalAge/blob/b0731907fa9676288b8565d67395beca8c62c727/src/main/java/mods/eln/transparentnode/FuelHeatFurnace.kt#L266

Others: https://github.com/age-series/ElectricalAge/blob/b0731907fa9676288b8565d67395beca8c62c727/src/main/java/mods/eln/transparentnode/Fabricator.kt#L110-L112 https://github.com/age-series/ElectricalAge/blob/b0731907fa9676288b8565d67395beca8c62c727/src/main/java/mods/eln/transparentnode/VariableDcDc.kt#L282-L284

jrddunbr commented 1 year ago

Is it because the newContainer is not declared the same as within other classes?

No, this is just a Kotlin feature where the return line can be condensed.

Is it because in the functions writeToNBT and readFromNBT it doesn't process the inventory?

Entirely possible. That particular line of code might not be in charge of setting the inventory though; it's a child implementation that does call the parent serializers as well which means that it may be processed in code above. Worth comparing to other machines with an inventory, or see if that inventory variable is referenced anywhere else in an IDE.

jrddunbr commented 1 year ago

That was it. When the file was Kotlinized, the kotlinization utility didn't subclass the inventory variable properly and to prevent name shadowing, changed it to inventory_.