
Bug: Entity tracking state is incorrectly updated on chunk status upgrades
Owen1212055 opened this issue ยท 1 comments
Minecraft Version
1.21.4
Moonrise Version
Mod Loader
Both (NeoForge and Fabric)
Logs and Crash Reports
N/A
Additional Context
This was initially reported on Paper, but is replicatable on Fabric with Moonrise installed as well.
When chunk statuses are upgraded, entity tracking methods are incorrectly called multiple times.
This occurs when spawning into a chunk with an Allay already existing:
(Paper logs- what I had easily availiable)
https://pastes.dev/jAhalfZrJE
tracking start -> tracking end -> tracking start
(Vanilla)
https://pastes.dev/nf7zpAdu0r
tracking start
Paper Issue: PaperMC/Paper#11751
This behavior causes small breaks, for example, DynamicGameEventListener
does not expect tracking start to be called in this nature.
Vanilla stores the lastSection
for which dynamic game event listeners were registered into. When the entity is first spawned, it registers the listeners, but when it's (incorrectly) untracked it unregisters them. However, when the entity is retracked lastSection
is already set, so game event listeners do not get re-registered when the entity is added.
A "bandaid" fix is to set lastSection
= null on DynamicGameEventListener#remove. But again, this is fundamentally a behavior change.
See the conversation starting here for context
Basically there are two topics here:
- There are cases where chunks are redundantly loaded, unloaded, and reloaded, #22 aims to change this
- The actual issue at hand seems to be that in vanilla allays do not expect the same instance to ever be untracked and retracked. It expects the allay to save to disk and be reloaded as a new instance before retracking. Something in the Moonrise chunk system is causing entity instances to be reused in a way vanilla doesn't expect when chunks are demoted and re-promoted.