Closed electron93 closed 4 years ago
Thanks for highlighting the issue. I will test your PR tomorrow and merge if it's ok. 🙂
Thanks @Yeregorix 😸 !
I wrote a tool to diagnose such things.
But even after these changes, some chunks still remain loaded. Maybe these are my local problems that are not related to Mirage.
Your PR makes NetworkChunk#areNeighborsLoaded
avoid to mark chunks as active and it fixes most cases where chunks are prevented to be unloaded. However, now that I'm aware of this problem I see many methods that are also affected but not optimised yet. WorldStorage/View#isExposed
, WorldView#getBlock
, WorldStorage/View#isChunkLoaded
, and many more. I also need to decide whether WorldStorage#getChunkStorage
and WorldView#getChunkView
should mark a chunk as active or not.
There are also few small problems with your changes:
NetworkWorld#isChunkLoaded
no longer returns false
when InternalChunk#isViewAvailable
returns false
.InternalWorld#isChunkLoaded
now returns false
when the chunk is going to be unloaded (unloadQueued == true
). However the chunk is loaded so it should returns true
. The approach is good but I'm closing this PR because the problem is way larger than I thought and I would like to handle it myself if you don't mind.
I finally handled things slightly differently in commit e079275. The fix now also affects the API's isChunkLoaded
. I let other methods unchanged for now because I think it's good to mark chunk active even when only reading information. That's what vanilla does and that will be necessary if someday I implement async obfuscation. It would be a pain to have neighbor chunks unloading in the middle of the process.
Don't reset Chunk.unloadQueued to false
net.minecraft.world.chunk.ChunkProviderServer.getLoadedChunk(int x, int z)
```java @Nullable public Chunk getLoadedChunk(int x, int z) { long i = ChunkPos.asLong(x, z); Chunk chunk = (Chunk)this.loadedChunks.get(i); if (chunk != null) { chunk.unloadQueued = false; } return chunk; } ```Visualization of loaded chunks with Dynmap (screenshots)
![2020-06-21_00-32-40](https://user-images.githubusercontent.com/1076914/85212288-0a551c80-b35a-11ea-9ed9-c1ab4df60b34.png) ![2020-06-21_00-31-58](https://user-images.githubusercontent.com/1076914/85212290-0e813a00-b35a-11ea-8c7c-8383f0a7b0fe.png) ![2020-06-21_00-32-14](https://user-images.githubusercontent.com/1076914/85212291-1345ee00-b35a-11ea-8111-6b5b7a45fd0c.png) ![2020-06-21_00-32-26](https://user-images.githubusercontent.com/1076914/85212292-16d97500-b35a-11ea-8892-69ce0f78593a.png)Without Mirage, chunks were correctly unloaded. This PR makes this possible with Mirage installed. Maybe not 100%, but clearly better than it was.