SuperMartijn642 / SuperMartijn642sCoreLib

14 stars 4 forks source link

[Bug] 1.18 does not use `BlockEntity.save()` like it used to.. #3

Closed EwyBoy closed 2 years ago

EwyBoy commented 2 years ago

Version Info

https://github.com/SuperMartijn642/SuperMartijn642sCoreLib/blob/56d1c373f2b351438133e74880226b55b26564c7/src/main/java/com/supermartijn642/core/block/BaseTileEntity.java#L63-L70

Description of the Bug See #3 Tanks do not retain fluid after saving world

SuperMartijn642 commented 2 years ago

Using BlockEntity#saveAdditional instead of BlockEntity#save seems to do the trick for me. That also appears to be the way vanilla BlockEntity's save their data.

Apart from that, just be sure to call BlockEntity#setChanged. If it's not called, the world thinks the chunk hasn't changed and thus it isn't "rewritten" to disk. This would match your explanation as placing another block would cause the chunk to be saved again, thus the first tank would be saved when the second tank is placed and the second tank does not get saved.

EwyBoy commented 2 years ago

Thank you I will give this a try.

EwyBoy commented 2 years ago

That seems to do the trick. Thank you! Closing this now.