SuperMartijn642 / ChunkLoaders

15 stars 11 forks source link

[Bug] Create contraptions being able to be move chunkloaders #105

Closed studkid closed 9 months ago

studkid commented 9 months ago

Version Info

Are you using OptiFine?: no

Description of the Bug Create is allowed to move chunkloaders via contraptions. This causes a major issue of allowing chunks to stay loaded regardless of the existence of the chunkloader block and will only fix itself if a chunkloaders to placed on the same tile the original was placed.

Adding the tag create:non_movable if Create is found to be loaded would fix this issue.

Steps to Reproduce

  1. Attach a chunkloader to any moving contraption via super glue
  2. Active the contraption to move it to a different location
  3. Remove the chunkloader
  4. The chunks in the original radius are still available to be loaded

Screenshots

https://github.com/SuperMartijn642/ChunkLoaders/assets/9309016/95b9cbc1-5ec5-426b-885c-05846ef54014

https://github.com/SuperMartijn642/ChunkLoaders/assets/9309016/ab5266a4-f46a-4bb1-8fda-a2b9edefdff3

SuperMartijn642 commented 9 months ago

Seems Create doesn't notify blocks that they are being removed to avoid things like chests dropping their contents. However, this also means the chunk loaders are not notified and thus the chunk loading manager thingy thinks they are still there.

There is a method for block entities called setRemoved which Create does call, however that method also just gets called whenever a chunk is unloaded. I now added a workaround which queues a task for 1 tick later whenever setRemoved is called. The task then checks if the area is still loaded and if so, if the chunk loader block is still there. If not, it will notify the chunk loading manager of it.

The change is available in Chunk Loaders version 1.0.8, so moving Chunk Loaders should now work fine. I have not blacklisted the chunk loaders in the create:non_movable tag as I don't think that's necessary. Thank you for reporting the issue!