-
Type:
Bug
-
Resolution: Fixed
-
Priority:
Minor
-
None
-
Affects Version/s: None
-
None
IChunkProvider has two methods for retrieving chunks, getLoadedChunkAt and getChunkAt. In vanilla, both methods will set the unloaded flag (the name of the flag in regular MCP, it doesn't appear to to be named in CraftBukkit's config) on the Chunk to false if the chunk was found in the map of loaded chunks. This flag is used as a mechanism to 'rescue' chunks from being unloaded when they were queued for unloading when they were still in use.
In CraftBukkit, it changes the behaviour of getChunkAt does not flip this flag to false but getLoadedChunkAt does. This results in chunks which are still in use to be unloaded completely for a brief amount of time and then reloaded. This inconsistency breaks many farms which rely on vanilla chunk loaders (such as Gnembon's Permaloader) to remain loaded.
The fix for this is a simple one. In Chunk getChunkAt(int i, int j, Runnable runnable, boolean generate) instead of calling getChunkIfLoaded at the beginning of the method, call getLoadedChunkAt. The only difference between these two methods is the setting of this unloaded flag to false. All other usages of getChunkIfLoaded are correct and should be left as is.
It seems that Spigot doesn't modify this behaviour, so fixing it in CraftBukkit should fix both.