Fix current level unloading on the client.

This commit is contained in:
Acuadragon100
2026-05-03 19:38:56 +02:00
parent 30eb02f3b7
commit 297a8dc980
2 changed files with 5 additions and 6 deletions
@@ -112,11 +112,7 @@ public class ClientLevelWrapper implements IClientLevelWrapper
private void unload()
{
AbstractDhWorld world = SharedApi.getAbstractDhWorld();
if (world != null)
{
world.unloadLevel(this);
}
else
if (world == null || !world.unloadLevel(this))
{
this.onUnload();
}
@@ -132,6 +128,8 @@ public class ClientLevelWrapper implements IClientLevelWrapper
long currentTime = System.currentTimeMillis();
long timeout = 30 * 1000;
System.out.println("Current: " + LEVEL_WRAPPER_REF_BY_CLIENT_LEVEL);
ArrayList<ClientLevelWrapper> toUnload = new ArrayList<>();
synchronized(LEVEL_WRAPPER_REF_BY_CLIENT_LEVEL)
{
@@ -141,6 +139,7 @@ public class ClientLevelWrapper implements IClientLevelWrapper
if (wrapper != null
&& wrapper.level != MINECRAFT.level)
{
System.out.println("Thinking of unloading: " + wrapper + " Time: " + (currentTime - wrapper.getLastAccessTime()));
// We use the synchronized getter to prevent race conditions with markAccessed()
if (currentTime - wrapper.getLastAccessTime() > timeout)
{