use of org.pepsoft.worldpainter.World2 in project WorldPainter by Captain-Chaos.
the class Timings method main.
public static void main(String[] args) throws IOException, ProgressReceiver.OperationCancelled, ClassNotFoundException {
Random random = new SecureRandom();
// final Configuration defaultConfig = new Configuration();
final World2 world;
try (ObjectInputStream in = new ObjectInputStream(new GZIPInputStream(new FileInputStream(args[0])))) {
world = (World2) in.readObject();
}
long totalDuration = 0;
for (int i = 0; i < 5; i++) {
// final World2 world = WorldFactory.createDefaultWorld(defaultConfig, random.nextLong());
world.getDimension(0).getTileFactory().setSeed(random.nextLong());
if (world.getPlatform() == null) {
if (world.getMaxHeight() == Constants.DEFAULT_MAX_HEIGHT_2) {
world.setPlatform(DefaultPlugin.JAVA_ANVIL);
} else {
world.setPlatform(DefaultPlugin.JAVA_MCREGION);
}
}
final JavaWorldExporter exporter = new JavaWorldExporter(world);
System.out.println("Starting export of world " + world.getName() + " " + i + " (seed: " + world.getDimension(0).getSeed() + ")");
File baseDir = new File(System.getProperty("user.dir"));
String name = world.getName() + ' ' + i;
File worldDir = new File(baseDir, FileUtils.sanitiseName(name));
if (worldDir.isDirectory()) {
FileUtils.deleteDir(worldDir);
}
long start = System.currentTimeMillis();
exporter.export(baseDir, name, null, null);
long duration = System.currentTimeMillis() - start;
System.out.println("Exporting world took " + (duration / 1000f) + " s");
totalDuration += duration;
}
System.out.println("Average duration: " + (totalDuration / 5000f) + " s");
}
use of org.pepsoft.worldpainter.World2 in project WorldPainter by Captain-Chaos.
the class IntegrityChecker method main.
public static void main(String[] args) throws IOException, ClassNotFoundException {
System.out.println("Loading " + args[0]);
World2 world;
try (ObjectInputStream in = new ObjectInputStream(new GZIPInputStream(new FileInputStream(args[0])))) {
world = (World2) in.readObject();
}
for (Dimension dimension : world.getDimensions()) {
float maxHeight = (dimension.getMaxHeight() - 1) + 0.5f;
System.out.println("Checking integrity of " + dimension.getName() + " dimension");
for (Tile tile : dimension.getTiles()) {
boolean tileReported = false;
for (int x = 0; x < Constants.TILE_SIZE; x++) {
for (int y = 0; y < Constants.TILE_SIZE; y++) {
float height = tile.getHeight(x, y);
if (height < -0.5f) {
if (!tileReported) {
System.out.println("Tile " + tile.getX() + "," + tile.getY());
tileReported = true;
}
System.out.println("Height " + height + " < -0.5 @ " + x + "," + y);
} else if (height > maxHeight) {
if (!tileReported) {
System.out.println("Tile " + tile.getX() + "," + tile.getY());
tileReported = true;
}
System.out.println("Height " + height + " > " + maxHeight + " @ " + x + "," + y);
}
}
}
}
}
}
use of org.pepsoft.worldpainter.World2 in project WorldPainter by Captain-Chaos.
the class ResetLava method main.
public static void main(String[] args) throws IOException, ClassNotFoundException {
System.out.println("Loading world " + args[0]);
File worldFile = new File(args[0]);
int waterLevel = Integer.parseInt(args[1]);
World2 world;
try (ObjectInputStream in = new ObjectInputStream(new GZIPInputStream(new FileInputStream(worldFile)))) {
world = (World2) in.readObject();
}
System.out.println("World loaded");
Dimension dim0 = world.getDimension(0);
for (Tile tile : dim0.getTiles()) {
for (int x = 0; x < TILE_SIZE; x++) {
for (int y = 0; y < TILE_SIZE; y++) {
// if ((tile.getWaterLevel(x, y) > (tile.getIntHeight(x, y))) && tile.getBitLayerValue(FloodWithLava.INSTANCE, x, y)) {
tile.setBitLayerValue(FloodWithLava.INSTANCE, x, y, false);
tile.setWaterLevel(x, y, waterLevel);
// }
}
}
System.out.print('.');
}
System.out.println();
System.out.println("Saving world " + args[0]);
try (ObjectOutputStream out = new ObjectOutputStream(new GZIPOutputStream(new FileOutputStream(worldFile)))) {
out.writeObject(world);
}
System.out.println("World saved");
}
use of org.pepsoft.worldpainter.World2 in project WorldPainter by Captain-Chaos.
the class RepairHeightMap method main.
public static final void main(String[] args) throws IOException, ClassNotFoundException {
System.out.println("Scanning world " + args[0]);
World2 world;
try (ObjectInputStream in = new ObjectInputStream(new GZIPInputStream(new FileInputStream(args[0])))) {
world = (World2) in.readObject();
}
boolean repairsPerformed = false;
for (Dimension dimension : world.getDimensions()) {
repairsPerformed |= repairDimension(dimension);
}
if (repairsPerformed) {
System.out.println("Repairs performed. Writing world out to " + args[0] + ".repaired");
try (ObjectOutputStream out = new ObjectOutputStream(new GZIPOutputStream(new FileOutputStream(args[0] + ".repaired")))) {
out.writeObject(world);
}
} else {
System.out.println("No repairs performed.");
}
}
use of org.pepsoft.worldpainter.World2 in project WorldPainter by Captain-Chaos.
the class PruneTiles method main.
public static void main(String[] args) throws IOException, ClassNotFoundException {
File worldFile = new File(args[0]);
int maxTileDistance = Integer.parseInt(args[1]);
World2 world;
try (ObjectInputStream in = new ObjectInputStream(new GZIPInputStream(new FileInputStream(worldFile)))) {
world = (World2) in.readObject();
}
for (Dimension dimension : world.getDimensions()) {
for (Tile tile : dimension.getTiles()) {
int dx = Math.abs(tile.getX()), dy = Math.abs(tile.getY());
if ((dx > maxTileDistance) || (dy > maxTileDistance)) {
// It's an outlier. Remove it
System.out.println("Removing tile at " + tile.getX() + ", " + tile.getY());
dimension.removeTile(tile);
}
}
}
try (ObjectOutputStream out = new ObjectOutputStream(new GZIPOutputStream(new FileOutputStream(worldFile)))) {
out.writeObject(world);
}
}
Aggregations