From 7242f21a32c29be9b42240f92e4d29249732229f Mon Sep 17 00:00:00 2001 From: Raphfrk Date: Fri, 11 Mar 2011 19:39:09 +0000 Subject: [PATCH] This should fix the chunk ghosting bug --- src/main/java/org/bukkit/craftbukkit/CraftChunk.java | 8 ++++++-- src/main/java/org/bukkit/craftbukkit/CraftWorld.java | 2 ++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/bukkit/craftbukkit/CraftChunk.java b/src/main/java/org/bukkit/craftbukkit/CraftChunk.java index e013923f8e..9c19a218a6 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftChunk.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftChunk.java @@ -36,12 +36,16 @@ public class CraftChunk implements Chunk { public net.minecraft.server.Chunk getHandle() { net.minecraft.server.Chunk c = weakChunk.get(); if (c == null) { - weakChunk = new WeakReference(worldServer.c(x,z)); - c = weakChunk.get(); + c = worldServer.c(x,z); + weakChunk = new WeakReference(c); } return c; } + void breakLink() { + weakChunk.clear(); + } + public int getX() { return x; } diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java index 2dda576593..2fab5cdca2 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java @@ -45,6 +45,7 @@ public class CraftWorld implements World { } public void preserveChunk( CraftChunk chunk ) { + chunk.breakLink(); unloadedChunks.put( (chunk.getX() << 16) + chunk.getZ(), chunk ); } @@ -141,6 +142,7 @@ public class CraftWorld implements World { provider.a(chunk); } + preserveChunk((CraftChunk)chunk.bukkitChunk); provider.a.remove(x, z); provider.e.remove(x, z); provider.f.remove(chunk);