Bugs and performance
This commit is contained in:
parent
73d1d0d907
commit
a627245fc3
@ -240,18 +240,18 @@ public class MinecraftLandGenerator implements Runnable {
|
|||||||
.distinct().parallel()
|
.distinct().parallel()
|
||||||
.flatMap(v -> world.availableChunks(v, dimension)
|
.flatMap(v -> world.availableChunks(v, dimension)
|
||||||
.map(w -> new Vector2i((v.x << 5) | w.x, (v.y << 5) | w.y)))
|
.map(w -> new Vector2i((v.x << 5) | w.x, (v.y << 5) | w.y)))
|
||||||
.collect(Collectors.toList()));
|
.collect(Collectors.toSet()));
|
||||||
log.debug(
|
log.debug(
|
||||||
"Removed " + (size - loadedChunks.size()) + " chunks that are already present");
|
"Removed " + (size - loadedChunks.size()) + " chunks that are already present");
|
||||||
}
|
}
|
||||||
log.info("Generating world");
|
log.info("Generating world");
|
||||||
if (loadedChunks.size() < 5000)
|
if (loadedChunks.size() < 5000)
|
||||||
log.debug("Chunks to generate: " + loadedChunks);
|
log.debug(loadedChunks.size() + " chunks to generate: " + loadedChunks);
|
||||||
else log.debug(loadedChunks.size() + " chunks to generate");
|
else log.debug(loadedChunks.size() + " chunks to generate");
|
||||||
int stepCount = (int) Math.ceil((double) loadedChunks.size() / maxLoaded);
|
int stepCount = (int) Math.ceil((double) loadedChunks.size() / maxLoaded);
|
||||||
for (int i = 0; i < stepCount; i++) {
|
for (int i = 0; i < stepCount; i++) {
|
||||||
List<Vector2i> batch = loadedChunks.subList(i * maxLoaded,
|
List<Vector2i> batch = loadedChunks.subList(i * maxLoaded,
|
||||||
Math.min((i + 1) * maxLoaded, loadedChunks.size() - 1));
|
Math.min((i + 1) * maxLoaded, loadedChunks.size()));
|
||||||
log.info("Generating batch " + (i + 1) + " / " + stepCount + " with " + batch.size()
|
log.info("Generating batch " + (i + 1) + " / " + stepCount + " with " + batch.size()
|
||||||
+ " chunks");
|
+ " chunks");
|
||||||
try {
|
try {
|
||||||
|
@ -2,6 +2,7 @@ package morlok8k.MinecraftLandGenerator;
|
|||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
|
import java.nio.IntBuffer;
|
||||||
import java.nio.channels.FileChannel;
|
import java.nio.channels.FileChannel;
|
||||||
import java.nio.file.FileAlreadyExistsException;
|
import java.nio.file.FileAlreadyExistsException;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
@ -239,7 +240,8 @@ public class World {
|
|||||||
ByteBuffer buffer = ByteBuffer.allocate(4096);
|
ByteBuffer buffer = ByteBuffer.allocate(4096);
|
||||||
channel.read(buffer);
|
channel.read(buffer);
|
||||||
buffer.flip();
|
buffer.flip();
|
||||||
return IntStream.range(0, buffer.capacity()).filter(i -> buffer.get(i) != 0)
|
IntBuffer locations = buffer.asIntBuffer();
|
||||||
|
return IntStream.range(0, locations.capacity()).filter(i -> locations.get(i) >>> 8 != 0)
|
||||||
.mapToObj(i -> new Vector2i(i & 31, i >> 5));
|
.mapToObj(i -> new Vector2i(i & 31, i >> 5));
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
log.warn("Could not open region file " + path + ", assuming it contains no chunks", e);
|
log.warn("Could not open region file " + path + ", assuming it contains no chunks", e);
|
||||||
|
Reference in New Issue
Block a user