Skip to content

Commit

Permalink
Fixed chunk loading bug.
Browse files Browse the repository at this point in the history
  • Loading branch information
tastybento committed Dec 26, 2017
1 parent 9705fed commit eb715af
Showing 1 changed file with 10 additions and 13 deletions.
23 changes: 10 additions & 13 deletions src/bskyblock/addin/level/ChunkScanner.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public class ChunkScanner {
private final Set<ChunkSnapshot> finalChunk;
private final Results result;
private final Optional<User> asker;


public ChunkScanner(Level plugin, Island island) {
this.plugin = plugin;
Expand All @@ -49,7 +49,7 @@ public ChunkScanner(Level plugin, Island island) {
result = new Results();
runAsyncCount(island);
}

/**
* Calculates the level of an island
* @param plugin
Expand Down Expand Up @@ -177,7 +177,7 @@ public void run() {
@Override
public void run() {
// Run any modifications

// All done.
if (asker.isPresent()) {
// Tell the asker the result
Expand Down Expand Up @@ -212,7 +212,7 @@ private void sendConsoleReport(Optional<User> asker) {
while (it.hasNext()) {
Entry<MaterialData> en = it.next();
MaterialData type = en.getElement();

int value = 0;
if (Settings.blockValues.containsKey(type)) {
// Specific
Expand Down Expand Up @@ -309,14 +309,11 @@ private Set<ChunkSnapshot> getIslandChunks(Island island) {
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 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)) {
Chunk chunk = world.getChunkAt((int)((double)x/16), (int)((double)z/16));
chunkSnapshot.add(chunk.getChunkSnapshot());
}
} else {
// chunk is loaded
chunkSnapshot.add(world.getBlockAt(x, 0, z).getChunk().getChunkSnapshot());
}
world.loadChunk((int)((double)x/16), (int)((double)z/16), false);
}
// chunk is loaded
chunkSnapshot.add(world.getBlockAt(x, 0, z).getChunk().getChunkSnapshot());

if (DEBUG)
plugin.getLogger().info("DEBUG: getting chunk at " + x + ", " + z);
}
Expand All @@ -325,7 +322,7 @@ private Set<ChunkSnapshot> getIslandChunks(Island island) {
plugin.getLogger().info("DEBUG: size of chunk snapshot = " + chunkSnapshot.size());
return chunkSnapshot;
}

/**
* Results class
* @author ben
Expand Down

0 comments on commit eb715af

Please sign in to comment.