Skip to content

Commit

Permalink
More optimizations
Browse files Browse the repository at this point in the history
  • Loading branch information
dries007 committed May 16, 2020
1 parent 959f80d commit cbd6ab9
Showing 1 changed file with 4 additions and 11 deletions.
15 changes: 4 additions & 11 deletions src/main/java/net/dries007/tfc/seedmaker/util/WorldGen.java
Expand Up @@ -25,13 +25,11 @@ public class WorldGen implements Runnable

private final int radius;
private final int chunkSize;
private final int expectedChunkCount;

public WorldGen(String seedString, int radius, int chunkSize, EnumSet<Layers> layers)
{
this.chunkSize = chunkSize;
this.radius = (radius / chunkSize) * chunkSize;
this.expectedChunkCount = radius * radius * 4 / (chunkSize * chunkSize);
this.seedString = seedString == null ? "" : seedString;
this.seed = parseSeed(this.seedString);
this.layers = layers;
Expand Down Expand Up @@ -102,10 +100,7 @@ public void row(int y)
}

// Write to image
for (ImageLineInt line : lines)
{
writer.writeRow(line);
}
for (ImageLineInt line : lines) writer.writeRow(line);
}
}

Expand All @@ -119,15 +114,13 @@ public void run()

List<LayerGen> maps = layers.stream().map(LayerGen::new).collect(Collectors.toList());

int chunkCount = 0;
// Per chunk of Y lines (Not the same as a Minecraft chunk!)
for (int y = -radius; y < radius; y += chunkSize)
for (int y = -radius, row = 1, rows = 2*radius/chunkSize; y < radius; y += chunkSize, row ++)
{
final int finalY = y;
maps.forEach((e) -> e.row(finalY));
maps.parallelStream().forEach((e) -> e.row(finalY));

chunkCount += chunkSize;
System.out.println("Seed " + seed + " Chunk " + chunkCount + " / " + expectedChunkCount);
System.out.println("Seed " + seed + " Done row " + row + " / " + rows);
}
// Close
maps.forEach(LayerGen::close);
Expand Down

0 comments on commit cbd6ab9

Please sign in to comment.