diff --git a/client/src/client/world/WorldClient.java b/client/src/client/world/WorldClient.java index ec6d762..28d3f18 100755 --- a/client/src/client/world/WorldClient.java +++ b/client/src/client/world/WorldClient.java @@ -47,8 +47,8 @@ public class WorldClient extends AWorldClient private final Set previousActive = Sets.newHashSet(); private final LongHashMap chunkMapping = new LongHashMap(); private final List chunkListing = Lists.newArrayList(); - private final Set emptyChunkListing = Sets.newHashSet(); - private final Set nextEmptyChunkListing = Sets.newHashSet(); + private final Set emptyChunkListing = Sets.newHashSet(); + private final Set nextEmptyChunkListing = Sets.newHashSet(); private final Chunk emptyChunk = new EmptyChunk(this); // public final Profiler profiler; protected int lastLightning; @@ -70,23 +70,24 @@ public class WorldClient extends AWorldClient for(int x = cx - range; x <= cx + range; x++) { for(int z = cz - range; z <= cz + range; z++) { long id = LongHashMap.packInt(x, z); - ChunkPos pos = new ChunkPos(x, z); if(this.chunkMapping.getValueByKey(id) != null) { - if(this.emptyChunkListing.contains(pos)) { - this.emptyChunkListing.remove(pos); - this.nextEmptyChunkListing.add(pos); + if(this.emptyChunkListing.contains(id)) { + this.emptyChunkListing.remove(id); + this.nextEmptyChunkListing.add(id); } continue; } this.chunkMapping.add(id, this.emptyChunk); - this.emptyChunkListing.remove(pos); - this.nextEmptyChunkListing.add(pos); + this.emptyChunkListing.remove(id); + this.nextEmptyChunkListing.add(id); this.markBlockRangeForRenderUpdate(x << 4, 0, z << 4, (x << 4) + 15, 512, (z << 4) + 15); } } - for(ChunkPos pos : this.emptyChunkListing) { - this.chunkMapping.remove(LongHashMap.packInt(pos.x, pos.z)); - this.markBlockRangeForRenderUpdate(pos.x << 4, 0, pos.z << 4, (pos.x << 4) + 15, 512, (pos.z << 4) + 15); + for(Long id : this.emptyChunkListing) { + this.chunkMapping.remove(id); + int x = LongHashMap.getX(id); + int z = LongHashMap.getZ(id); + this.markBlockRangeForRenderUpdate(x << 4, 0, z << 4, (x << 4) + 15, 512, (z << 4) + 15); } this.emptyChunkListing.clear(); this.emptyChunkListing.addAll(this.nextEmptyChunkListing); @@ -178,7 +179,7 @@ public class WorldClient extends AWorldClient chunk.onChunkUnload(); this.chunkMapping.remove(id); this.chunkListing.remove(chunk); - this.emptyChunkListing.remove(new ChunkPos(x, z)); + this.emptyChunkListing.remove(id); } if (!load) diff --git a/common/src/common/util/LongHashMap.java b/common/src/common/util/LongHashMap.java index 89aba64..65faf9b 100755 --- a/common/src/common/util/LongHashMap.java +++ b/common/src/common/util/LongHashMap.java @@ -13,6 +13,14 @@ public class LongHashMap return (long)x & 4294967295L | ((long)z & 4294967295L) << 32; } + public static int getX(long v) { + return (int)(v & 4294967295L); + } + + public static int getZ(long v) { + return (int)(v >> 32); + } + public LongHashMap() { this.mask = this.hashArray.length - 1;