diff options
author | Travis Watkins <amaranth@ubuntu.com> | 2014-06-16 18:52:30 -0500 |
---|---|---|
committer | Travis Watkins <amaranth@ubuntu.com> | 2014-06-21 21:03:00 -0500 |
commit | ea126f98adfb3a54c1b0defb262ff583127b52b3 (patch) | |
tree | 887e170c1be990ddc3841130d3ef3fe3c095e973 /src/main/java/net/minecraft/server | |
parent | e6a2feda2080071d63b4643c2924d4a9ce089300 (diff) | |
download | craftbukkit-ea126f98adfb3a54c1b0defb262ff583127b52b3.tar craftbukkit-ea126f98adfb3a54c1b0defb262ff583127b52b3.tar.gz craftbukkit-ea126f98adfb3a54c1b0defb262ff583127b52b3.tar.lz craftbukkit-ea126f98adfb3a54c1b0defb262ff583127b52b3.tar.xz craftbukkit-ea126f98adfb3a54c1b0defb262ff583127b52b3.zip |
Don't check unload queue before ticking things anymore.
In commits 71a238ee and c8591397 we added checks while ticking to ensure
we never ticked anything in a chunk meant to be unloaded. We did this to
prevent these chunks being removed from the unload queue and leaked.
However, this causes a ridiculously large number of lookups on the queue
for a somewhat rare occurance. We also now have the chunk GC which will
take care of these leaked chunks when they do happen. With this in mind
we now remove these checks which removes almost all uses of the
LongHashSet backing the unload queue.
Diffstat (limited to 'src/main/java/net/minecraft/server')
-rw-r--r-- | src/main/java/net/minecraft/server/World.java | 40 |
1 files changed, 11 insertions, 29 deletions
diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java index bbf61a39..af7069cb 100644 --- a/src/main/java/net/minecraft/server/World.java +++ b/src/main/java/net/minecraft/server/World.java @@ -250,8 +250,7 @@ public abstract class World implements IBlockAccess { for (int k1 = i; k1 <= l; ++k1) { for (int l1 = k; l1 <= j1; ++l1) { - // CraftBukkit - check unload queue too so we don't leak a chunk - if (!this.isChunkLoaded(k1, l1) || ((WorldServer) this).chunkProviderServer.unloadQueue.contains(k1, l1)) { + if (!this.isChunkLoaded(k1, l1)) { return false; } } @@ -1211,15 +1210,10 @@ public abstract class World implements IBlockAccess { for (i = 0; i < this.i.size(); ++i) { entity = (Entity) this.i.get(i); - // CraftBukkit start - Fixed an NPE, don't process entities in chunks queued for unload + // CraftBukkit start - Fixed an NPE if (entity == null) { continue; } - - ChunkProviderServer chunkProviderServer = ((WorldServer) this).chunkProviderServer; - if (chunkProviderServer.unloadQueue.contains(MathHelper.floor(entity.locX) >> 4, MathHelper.floor(entity.locZ) >> 4)) { - continue; - } // CraftBukkit end try { @@ -1267,14 +1261,6 @@ public abstract class World implements IBlockAccess { // CraftBukkit start - Use field for loop variable for (this.tickPosition = 0; this.tickPosition < this.entityList.size(); ++this.tickPosition) { entity = (Entity) this.entityList.get(this.tickPosition); - - // Don't tick entities in chunks queued for unload - ChunkProviderServer chunkProviderServer = ((WorldServer) this).chunkProviderServer; - if (chunkProviderServer.unloadQueue.contains(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; @@ -1314,16 +1300,17 @@ public abstract class World implements IBlockAccess { this.methodProfiler.c("blockEntities"); this.M = true; + // CraftBukkit start - From below, clean up tile entities before ticking them + if (!this.b.isEmpty()) { + this.tileEntityList.removeAll(this.b); + this.b.clear(); + } + // CraftBukkit end + Iterator iterator = this.tileEntityList.iterator(); while (iterator.hasNext()) { TileEntity tileentity = (TileEntity) iterator.next(); - // CraftBukkit start - Don't tick entities in chunks queued for unload - ChunkProviderServer chunkProviderServer = ((WorldServer) this).chunkProviderServer; - if (chunkProviderServer.unloadQueue.contains(tileentity.x >> 4, tileentity.z >> 4)) { - continue; - } - // CraftBukkit end if (!tileentity.r() && tileentity.o() && this.isLoaded(tileentity.x, tileentity.y, tileentity.z)) { try { @@ -1349,10 +1336,12 @@ public abstract class World implements IBlockAccess { } this.M = false; + /* CraftBukkit start - Moved up if (!this.b.isEmpty()) { this.tileEntityList.removeAll(this.b); this.b.clear(); } + */ // CraftBukkit end this.methodProfiler.c("pendingBlockEntities"); if (!this.a.isEmpty()) { @@ -1996,13 +1985,6 @@ public abstract class World implements IBlockAccess { for (int i1 = -l; i1 <= l; ++i1) { for (int j1 = -l; j1 <= l; ++j1) { - // CraftBukkit start - Don't tick chunks queued for unload - ChunkProviderServer chunkProviderServer = ((WorldServer) entityhuman.world).chunkProviderServer; - if (chunkProviderServer.unloadQueue.contains(i1 + j, j1 + k)) { - continue; - } - // CraftBukkit end - this.chunkTickList.add(org.bukkit.craftbukkit.util.LongHash.toLong(i1 + j, j1 + k)); // CraftBukkit } } |