fix(animation): clear tracked animation when an animated block is removed#74
Conversation
There was a problem hiding this comment.
Pull request overview
This PR fixes stale server-side animation state for animated block entities by clearing their AnimationTracker entry when the block is actually removed/replaced, preventing a newly placed block at the same position from inheriting an old animation.
Changes:
- Implemented
ABlockEntity.onBreak(...)to remove tracked animations forAnimatedInstanceblock entities on the server. - Added the required imports to support the new tracker cleanup.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
generalized the fix after the ait-extras moved the cleanup into a
|
Fixes #68 and #45.
Animated block entities derive their animation UUID from world + position (
AnimatedBlockEntity#getUuid), and animation state was never cleared when a block was removed - so a block placed where an animated one was broken inherited the stale animation (#68), and animations survived chunk unload/reload (#45).This clears tracked animation state for any
AnimatedInstanceblock entity via a mixin on vanillaBlockEntity#markRemoved(server-side only). Hooking the vanilla lifecycle rather thanABlockEntity.onBreakmeans it also covers downstream block entities that implementAnimatedBlockEntityon a plainBlockEntity(e.g. ait-extras'MonitorCoverBlockEntity), and becausemarkRemovedfires on chunk unload it fixes #45 too. Only syncs a removal when an animation is actually tracked, to avoid needless packets on unload.