You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I suggest the patch needs to be updated to move the ChunkEvent.Unload to be aftersave() probably near the level.unload() in the actual src
Description of issue:
What is the correct lifecycle for Chunks?
Right now it's ChunkEvent.Load -> ChunkDataEvent.Load -> ChunkEvent.Unload -> ChunkDataEvent.Save
I use these events to keep a Map of loaded Levels and a Map of all Chunks loaded, and save data that mapped data via these ChunkData Events. Having this mapped relationship makes it crucial for some functionality - This is similar to CodeChickenLib's Legacy WorldExtension and ChunkExtensionhere
I believe the lifecycle should be ChunkEvent.Load -> ChunkDataEvent.Load -> ChunkDataEvent.Save -> ChunkEvent.Unload
and here's why:
In this scenario, when a chunk is unloaded, I effectively remove the ChunkExtension from the map. With the current lifecycle, that will be done before the Save event is fired and thus data that should be saved in the ChunkExtension isn't.
It's not like I can just remove the ChunkEvent.Unload functionality on my end, because that would cause major memory leaks.
The text was updated successfully, but these errors were encountered:
@Technici4n should this then be closed if Data Attachments are better for this use case?
Though looking at MC's code, they do call the save method before the unload method
Was there a specific reason the unload is put before save instead of right after the save call? Since after would be closer to where vanilla does the actual unload call?
Minecraft Version: 1.20.1
Forge Version: 47.1.76
Steps to Reproduce:
NeoForge/patches/minecraft/net/minecraft/server/level/ChunkMap.java.patch
Line 15 in 0974ecc
I suggest the patch needs to be updated to move the
ChunkEvent.Unload
to be aftersave()
probably near thelevel.unload()
in the actual srcDescription of issue:
What is the correct lifecycle for Chunks?
Right now it's
ChunkEvent.Load
->ChunkDataEvent.Load
->ChunkEvent.Unload
->ChunkDataEvent.Save
I use these events to keep a Map of loaded
Levels
and a Map of allChunks
loaded, and save data that mapped data via theseChunkData
Events. Having this mapped relationship makes it crucial for some functionality - This is similar to CodeChickenLib's LegacyWorldExtension
andChunkExtension
hereI believe the lifecycle should be
ChunkEvent.Load
->ChunkDataEvent.Load
->ChunkDataEvent.Save
->ChunkEvent.Unload
and here's why:
In this scenario, when a chunk is unloaded, I effectively remove the
ChunkExtension
from the map. With the current lifecycle, that will be done before the Save event is fired and thus data that should be saved in theChunkExtension
isn't.It's not like I can just remove the
ChunkEvent.Unload
functionality on my end, because that would cause major memory leaks.The text was updated successfully, but these errors were encountered: