
[Question] Force chunk loading?
judicius opened this issue ยท 2 comments
On a server, in unloaded chunks, will the server continually do checks to stop spawning in the 32 chunks? Trying to track down some mem usage and tps lag.
TorchMaster explicitly does no chunk loading, but it keeps a map of torch positions once they are placed down. The size of this map should be in the region of a few hundred bytes, as long as you dont use an excessive amount of torches - but even when you use 1000+ torches in a single dimension, there should be no memory issues due to torchmaster.
Torchmaster does not access chunks for the spawn checks. I register a callback for the Entity CheckSpawn event. In this event I only check if the coordinates of the intended spawn is inside a torch volume. The torch volume is calculated from the torch positions in the map I keep in memory. I dont do any world access during the check itself. If all chunks are unloaded, Torchmaster should effectivly do nothing, since there should be no spawning attempts.
Torchmaster only accesses the world chunks for torch existance checks to check if a torch has been removed by another mod without notifying the game properly. This check is wrapped in a World#IsBlockLoaded() check to prevent loading chunks that are unloaded. I could add a configuration option to disable these checks and add a chat command to do manual checks.
This is the only code that might cause issues if the World#IsBlockLoaded check does not work as expected, but this was the recommended way to check if a chunk is loaded back when TorchMaster was created. I will investigate this issue but I dont see any issues with torchmaster - but if you have more information, keep me updated. If there is an issue with torchmaster, i want to fix it asap.
There are 2 other blocks in the mod that might access the world chunks:
- The terrain lighter accesses the world chunks to place torches while it receives a redstone signal and has torches in the inventory as well as enough fuel to run. This block should be removed if it is not used to prevent unwanted chunk loading while placing torches.
- The Feral flare lantern places lights in intervals but there is a chunk loaded check as well.