diff --git a/src/main/java/net/minecraft/server/ChunkProviderServer.java b/src/main/java/net/minecraft/server/ChunkProviderServer.java index ace09490d0..3de2e480a4 100644 --- a/src/main/java/net/minecraft/server/ChunkProviderServer.java +++ b/src/main/java/net/minecraft/server/ChunkProviderServer.java @@ -23,7 +23,7 @@ public class ChunkProviderServer implements IChunkProvider { public Chunk emptyChunk; public IChunkProvider chunkProvider; // CraftBukkit private IChunkLoader e; - public boolean forceChunkLoad = false; // true -> false + public boolean forceChunkLoad = true; public LongHashtable chunks = new LongHashtable(); public List chunkList = new ArrayList(); public WorldServer world; @@ -37,7 +37,7 @@ public class ChunkProviderServer implements IChunkProvider { } public boolean isChunkLoaded(int i, int j) { - return this.chunks.containsKey(i, j); // CraftBukkit + return !this.unloadQueue.containsKey(i, j) && this.chunks.containsKey(i, j); // CraftBukkit } public void queueUnload(int i, int j) { diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java index 830ed87277..d552df0fb8 100644 --- a/src/main/java/net/minecraft/server/World.java +++ b/src/main/java/net/minecraft/server/World.java @@ -1053,7 +1053,12 @@ public abstract class World implements IBlockAccess { for (i = 0; i < this.j.size(); ++i) { entity = (Entity) this.j.get(i); - // CraftBukkit start - fixed an NPE + // CraftBukkit start - fixed an NPE, don't process entities in chunks queued for unload + ChunkProviderServer chunkProviderServer = ((WorldServer) entity.world).chunkProviderServer; + if (chunkProviderServer.unloadQueue.containsKey(MathHelper.floor(entity.locX) >> 4, MathHelper.floor(entity.locZ) >> 4)) { + continue; + } + if (entity == null) { continue; } @@ -1092,6 +1097,14 @@ public abstract class World implements IBlockAccess { for (i = 0; i < this.entityList.size(); ++i) { entity = (Entity) this.entityList.get(i); + + // CraftBukkit start - don't tick entities in chunks queued for unload + ChunkProviderServer chunkProviderServer = ((WorldServer) entity.world).chunkProviderServer; + if (chunkProviderServer.unloadQueue.containsKey(MathHelper.floor(entity.locX) >> 4, MathHelper.floor(entity.locZ) >> 4)) { + continue; + } + // CraftBukkit end + if (entity.vehicle != null) { if (!entity.vehicle.dead && entity.vehicle.passenger == entity) { continue; @@ -1129,6 +1142,13 @@ public abstract class World implements IBlockAccess { while (iterator.hasNext()) { TileEntity tileentity = (TileEntity) iterator.next(); + // CraftBukkit start - don't tick entities in chunks queued for unload + ChunkProviderServer chunkProviderServer = ((WorldServer) tileentity.world).chunkProviderServer; + if (chunkProviderServer.unloadQueue.containsKey(tileentity.x >> 4, tileentity.z >> 4)) { + continue; + } + // CraftBukkit end + if (!tileentity.p() && tileentity.m() && this.isLoaded(tileentity.x, tileentity.y, tileentity.z)) { tileentity.g(); } @@ -1791,6 +1811,13 @@ public abstract class World implements IBlockAccess { for (int l = -b0; l <= b0; ++l) { for (int i1 = -b0; i1 <= b0; ++i1) { + // CraftBukkit start - don't tick chunks queued for unload + ChunkProviderServer chunkProviderServer = ((WorldServer) entityhuman.world).chunkProviderServer; + if (chunkProviderServer.unloadQueue.containsKey(l + j, i1 + k)) { + continue; + } + // CraftBukkit end + this.chunkTickList.add(org.bukkit.craftbukkit.util.LongHash.toLong(l + j, i1 + k)); // CraftBukkit } }