mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2025-07-01 15:37:24 +00:00
Add no save option
This commit is contained in:
parent
d31679e6be
commit
8a028b193a
@ -36,6 +36,9 @@ public final class TerraCLI implements Callable<Integer> {
|
|||||||
@Option(names = { "--min-height"}, description = "Minimum height of the world.")
|
@Option(names = { "--min-height"}, description = "Minimum height of the world.")
|
||||||
private int minHeight = -64;
|
private int minHeight = -64;
|
||||||
|
|
||||||
|
@Option(names = { "--no-save"}, description = "Don't save the world to disk.")
|
||||||
|
private boolean noSave = false;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Integer call() {
|
public Integer call() {
|
||||||
Logger LOGGER = LoggerFactory.getLogger(TerraCLI.class);
|
Logger LOGGER = LoggerFactory.getLogger(TerraCLI.class);
|
||||||
@ -46,22 +49,24 @@ public final class TerraCLI implements Callable<Integer> {
|
|||||||
|
|
||||||
ConfigPack generate = platform.getConfigRegistry().getByID(pack).orElseThrow();
|
ConfigPack generate = platform.getConfigRegistry().getByID(pack).orElseThrow();
|
||||||
|
|
||||||
CLIWorld world = new CLIWorld(size, seed, maxHeight, minHeight, generate);
|
CLIWorld world = new CLIWorld(size, seed, maxHeight, minHeight, generate, noSave);
|
||||||
|
|
||||||
world.generate();
|
world.generate();
|
||||||
|
|
||||||
world.serialize().parallel().forEach(mcaFile -> {
|
if(!noSave) {
|
||||||
Vector2Int pos = mcaFile.getLeft();
|
world.serialize().parallel().forEach(mcaFile -> {
|
||||||
String name = MCAUtil.createNameFromRegionLocation(pos.getX(), pos.getZ());
|
Vector2Int pos = mcaFile.getLeft();
|
||||||
LOGGER.info("Writing region ({}, {}) to {}", pos.getX(), pos.getZ(), name);
|
String name = MCAUtil.createNameFromRegionLocation(pos.getX(), pos.getZ());
|
||||||
|
LOGGER.info("Writing region ({}, {}) to {}", pos.getX(), pos.getZ(), name);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
MCAUtil.write(mcaFile.getRight(), name);
|
MCAUtil.write(mcaFile.getRight(), name);
|
||||||
} catch(IOException e) {
|
} catch(IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
LOGGER.info("Wrote region to file.");
|
LOGGER.info("Wrote region to file.");
|
||||||
});
|
});
|
||||||
|
}
|
||||||
LOGGER.info("Done.");
|
LOGGER.info("Done.");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -43,6 +43,7 @@ public class CLIWorld implements ServerWorld, NBTSerializable<Stream<Pair<Vector
|
|||||||
private final ChunkGenerator chunkGenerator;
|
private final ChunkGenerator chunkGenerator;
|
||||||
private final BiomeProvider biomeProvider;
|
private final BiomeProvider biomeProvider;
|
||||||
private final ConfigPack pack;
|
private final ConfigPack pack;
|
||||||
|
private final boolean noSave;
|
||||||
private final AtomicInteger amount = new AtomicInteger(0);
|
private final AtomicInteger amount = new AtomicInteger(0);
|
||||||
|
|
||||||
private final ExecutorService executor = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors() - 1);
|
private final ExecutorService executor = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors() - 1);
|
||||||
@ -51,7 +52,7 @@ public class CLIWorld implements ServerWorld, NBTSerializable<Stream<Pair<Vector
|
|||||||
long seed,
|
long seed,
|
||||||
int maxHeight,
|
int maxHeight,
|
||||||
int minHeight,
|
int minHeight,
|
||||||
ConfigPack pack) {
|
ConfigPack pack, boolean noSave) {
|
||||||
this.size = size;
|
this.size = size;
|
||||||
this.maxHeight = maxHeight;
|
this.maxHeight = maxHeight;
|
||||||
this.minHeight = minHeight;
|
this.minHeight = minHeight;
|
||||||
@ -59,6 +60,7 @@ public class CLIWorld implements ServerWorld, NBTSerializable<Stream<Pair<Vector
|
|||||||
this.chunkGenerator = pack.getGeneratorProvider().newInstance(pack);
|
this.chunkGenerator = pack.getGeneratorProvider().newInstance(pack);
|
||||||
this.biomeProvider = pack.getBiomeProvider();
|
this.biomeProvider = pack.getBiomeProvider();
|
||||||
this.pack = pack;
|
this.pack = pack;
|
||||||
|
this.noSave = noSave;
|
||||||
|
|
||||||
|
|
||||||
size += 1;
|
size += 1;
|
||||||
@ -84,7 +86,13 @@ public class CLIWorld implements ServerWorld, NBTSerializable<Stream<Pair<Vector
|
|||||||
futures.add(executor.submit(() -> {
|
futures.add(executor.submit(() -> {
|
||||||
try {
|
try {
|
||||||
int num = amount.getAndIncrement();
|
int num = amount.getAndIncrement();
|
||||||
CLIChunk chunk = getChunkAt(finalX, finalZ);
|
CLIChunk chunk;
|
||||||
|
if (!noSave) {
|
||||||
|
chunk = getChunkAt(finalX, finalZ);
|
||||||
|
} else {
|
||||||
|
chunk = new CLIChunk(Math.floorMod(finalX, 32), Math.floorMod(finalZ, 32), this);
|
||||||
|
}
|
||||||
|
|
||||||
BiomeProvider cachingBiomeProvider = pack.getBiomeProvider();
|
BiomeProvider cachingBiomeProvider = pack.getBiomeProvider();
|
||||||
chunkGenerator.generateChunkData(chunk, this, cachingBiomeProvider, finalX, finalZ);
|
chunkGenerator.generateChunkData(chunk, this, cachingBiomeProvider, finalX, finalZ);
|
||||||
CLIProtoWorld protoWorld = new CLIProtoWorld(this, cachingBiomeProvider, finalX, finalZ);
|
CLIProtoWorld protoWorld = new CLIProtoWorld(this, cachingBiomeProvider, finalX, finalZ);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user