`UnloadableBlockEntity.onChunkUnload` is never called
Kneelawk opened this issue ยท 5 comments
The Issue
This issue was actually encountered in conjunction with LMP. In my multipart part, I was watching for LMP's CHUNK_UNLOAD
event and found that it never gets called. Then I used my debugger to verify that MultipartBlockEntity.onChunkUnload
is never called.
This means that BlockEntities implementing UnloadableBlockEntity
likely never have their onChunkUnload
method called.
Demonstration Repo
This bug is demonstrated in the repo at: https://github.com/Kneelawk/LBA-Test/tree/unloadable-block-entity-issue (in the unloadable-block-entity-issue
branch).
When running, the LBATestBlockEntity
should print # onChunkUnload
to the console when onChunkUnload
is called but this is never printed to the console. Only markRemoved
and cancelRemoval
methods are called.
Versions
- LBA-Test
1.0.0
(Used for this demonstration) - LibBlockAttributes
0.10.2
Full Mod List
- fabric
0.53.0+1.18.2
- fabric-api-base
0.4.4+d7c144a860
- fabric-api-lookup-api-v1
1.6.0+2373a54560
- fabric-biome-api-v1
8.0.4+7b0f312660
- fabric-blockrenderlayer-v1
1.1.12+3ac43d9560
- fabric-command-api-v1
1.1.9+d7c144a860
- fabric-commands-v0
0.2.8+b4f4f6cd60
- fabric-containers-v0
0.1.21+d7c144a860
- fabric-content-registries-v0
3.0.4+d82b939260
- fabric-convention-tags-v1
1.0.1+474e4f7960
- fabric-crash-report-info-v1
0.2.0+a6b0947860
- fabric-data-generation-api-v1
2.0.9+e19de87d60
- fabric-dimensions-v1
2.1.17+2540745460
- fabric-entity-events-v1
1.4.8+d7c144a860
- fabric-events-interaction-v0
0.4.19+d7c144a860
- fabric-events-lifecycle-v0
0.2.15+d7c144a860
- fabric-game-rule-api-v1
1.0.13+d7c144a860
- fabric-gametest-api-v1
1.0.17+91b7aa6660
- fabric-item-api-v1
1.5.0+85719ab760
- fabric-item-groups-v0
0.3.12+91896a4960
- fabric-key-binding-api-v1
1.0.12+54e5b2ec60
- fabric-keybindings-v0
0.2.10+b4f4f6cd60
- fabric-lifecycle-events-v1
2.0.3+2d83e92c60
- fabric-loot-tables-v1
1.0.11+d7c144a860
- fabric-mining-level-api-v1
2.1.1+81ea5b3c60
- fabric-models-v0
0.3.6+d7c144a860
- fabric-networking-api-v1
1.0.21+d882b91560
- fabric-networking-v0
0.3.8+b4f4f6cd60
- fabric-object-builder-api-v1
2.1.1+032c981d60
- fabric-particles-v1
0.2.12+526dc1ac60
- fabric-registry-sync-v0
0.9.8+0d9ab37260
- fabric-renderer-api-v1
0.4.13+d882b91560
- fabric-renderer-indigo
0.5.0+7faf0d8860
- fabric-renderer-registries-v1
3.2.11+b4f4f6cd60
- fabric-rendering-data-attachment-v1
0.3.7+d7c144a860
- fabric-rendering-fluids-v1
2.0.2+54e5b2ec60
- fabric-rendering-v0
1.1.13+b4f4f6cd60
- fabric-rendering-v1
1.10.7+54e5b2ec60
- fabric-resource-conditions-api-v1
2.0.3+91b7aa6660
- fabric-resource-loader-v0
0.5.0+2afceb2960
- fabric-screen-api-v1
1.0.10+d882b91560
- fabric-screen-handler-api-v1
1.2.0+1f6558e860
- fabric-textures-v0
1.0.12+3ac43d9560
- fabric-transfer-api-v1
1.6.1+f4563ac860
- fabric-transitive-access-wideners-v1
1.0.0+bd8a4a1860
- fabricloader
0.14.6
- java
17
- lba-test
1.0.0
- libblockattributes_core
0.10.2
- minecraft
1.18.2
Potential Solution
One potential solution that could also help decrease the number of mixins would be to use FAPI's ServerChunkEvents.CHUNK_UNLOAD
and ClientChunkEvents.CHUNK_UNLOAD
events instead of mixing into ServerWorld
and ClientWorld
directly.
However, WorldChunk
s don't seem to contain any BlockEntities on the client-side when they're unloaded. So using ClientChunkEvents.CHUNK_UNLOAD
might not be any better than the existing mixin.
What version of LBA / minecraft are you using? This event definitely fires correctly in my buildcraft 1.18.2 dev environment, but it's possible that I've fixed something in that version of LBA but not the public one.
I appear to be using LBA version 0.10.2
. Let me know if there are other things I can test to see what's going on.
I tried implementing UnloadableBlockEntity
on one of my BlockEntities and found that onChunkUnload
was never called when the world was closed or when my BlockEntity went out of range.
Ok, I have tested this in a much simpler dev environment and am still running into this issue. Here is the repository I am using to demonstrate this issue: https://github.com/Kneelawk/LBA-Test/tree/unloadable-block-entity-issue (note the unloadable-block-entity-issue
branch).
When running, the LBATestBlockEntity
should print # onChunkUnload
to the console when onChunkUnload
is called but this is never printed to the console.
I turns out this was caused by LBA-core's mixins not applying.
One thing to note though is that the client-side onChunkUnload
seems to only be called if the client unloads the chunk but does not leave the game. This however does not seem like too big of an issue. If it becomes a problem, a new issue can be opened.