Fixed chunk loading bug.

This commit is contained in:
Tastybento 2017-12-26 08:55:40 -08:00
parent 9705fedd04
commit eb715afcda

View File

@ -38,7 +38,7 @@ public class ChunkScanner {
private final Set<ChunkSnapshot> finalChunk; private final Set<ChunkSnapshot> finalChunk;
private final Results result; private final Results result;
private final Optional<User> asker; private final Optional<User> asker;
public ChunkScanner(Level plugin, Island island) { public ChunkScanner(Level plugin, Island island) {
this.plugin = plugin; this.plugin = plugin;
@ -49,7 +49,7 @@ public class ChunkScanner {
result = new Results(); result = new Results();
runAsyncCount(island); runAsyncCount(island);
} }
/** /**
* Calculates the level of an island * Calculates the level of an island
* @param plugin * @param plugin
@ -177,7 +177,7 @@ public class ChunkScanner {
@Override @Override
public void run() { public void run() {
// Run any modifications // Run any modifications
// All done. // All done.
if (asker.isPresent()) { if (asker.isPresent()) {
// Tell the asker the result // Tell the asker the result
@ -212,7 +212,7 @@ public class ChunkScanner {
while (it.hasNext()) { while (it.hasNext()) {
Entry<MaterialData> en = it.next(); Entry<MaterialData> en = it.next();
MaterialData type = en.getElement(); MaterialData type = en.getElement();
int value = 0; int value = 0;
if (Settings.blockValues.containsKey(type)) { if (Settings.blockValues.containsKey(type)) {
// Specific // Specific
@ -309,14 +309,11 @@ public class ChunkScanner {
for (int z = island.getMinProtectedZ(); z < (island.getMinProtectedZ() + (island.getProtectionRange() * 2) + 16); z += 16) { for (int z = island.getMinProtectedZ(); z < (island.getMinProtectedZ() + (island.getProtectionRange() * 2) + 16); z += 16) {
if (!world.isChunkLoaded((int)((double)x/16), (int)((double)z/16))) { if (!world.isChunkLoaded((int)((double)x/16), (int)((double)z/16))) {
// If the chunk isn't already generated, load it but don't try and generate it // If the chunk isn't already generated, load it but don't try and generate it
if (world.loadChunk((int)((double)x/16), (int)((double)z/16), false)) { world.loadChunk((int)((double)x/16), (int)((double)z/16), false);
Chunk chunk = world.getChunkAt((int)((double)x/16), (int)((double)z/16)); }
chunkSnapshot.add(chunk.getChunkSnapshot()); // chunk is loaded
} chunkSnapshot.add(world.getBlockAt(x, 0, z).getChunk().getChunkSnapshot());
} else {
// chunk is loaded
chunkSnapshot.add(world.getBlockAt(x, 0, z).getChunk().getChunkSnapshot());
}
if (DEBUG) if (DEBUG)
plugin.getLogger().info("DEBUG: getting chunk at " + x + ", " + z); plugin.getLogger().info("DEBUG: getting chunk at " + x + ", " + z);
} }
@ -325,7 +322,7 @@ public class ChunkScanner {
plugin.getLogger().info("DEBUG: size of chunk snapshot = " + chunkSnapshot.size()); plugin.getLogger().info("DEBUG: size of chunk snapshot = " + chunkSnapshot.size());
return chunkSnapshot; return chunkSnapshot;
} }
/** /**
* Results class * Results class
* @author ben * @author ben