diff --git a/generated_world/src/main/java/mc/world/generated_world/generator/SeedBasedWorldGenerator.java b/generated_world/src/main/java/mc/world/generated_world/generator/SeedBasedWorldGenerator.java index 8253165..3f272b0 100644 --- a/generated_world/src/main/java/mc/world/generated_world/generator/SeedBasedWorldGenerator.java +++ b/generated_world/src/main/java/mc/world/generated_world/generator/SeedBasedWorldGenerator.java @@ -6,9 +6,6 @@ import mc.core.block.BlockFactory; import mc.core.block.BlockType; import mc.core.world.*; import mc.world.generated_world.region.RegionImpl; -import mc.world.generated_world.serialization.ChunkSerializer; -import mc.world.generated_world.serialization.RegionReaderWriter; -import mc.world.generated_world.serialization.WorldReaderWriter; import mc.world.generated_world.world.CubicWorld; import mc.world.generated_world.world.Temperature; import mc.world.generated_world.world.Wetness; @@ -16,6 +13,7 @@ import mc.world.generated_world.world.Wetness; import javax.imageio.ImageIO; import java.awt.image.BufferedImage; import java.io.File; +import java.io.IOException; import java.util.UUID; import static mc.world.generated_world.WorldConstants.*; @@ -26,24 +24,26 @@ public class SeedBasedWorldGenerator implements WorldGenerator { public static void main(String[] args) throws Exception{ WorldGenerator worldGenerator = new SeedBasedWorldGenerator(); World world = new CubicWorld(UUID.fromString("00000000-0000-0000-C000-000000000046"), 2626949); - Region region = worldGenerator.generateRegion(0, 0, world); + /*Region region = worldGenerator.generateRegion(0, 0, world); region.save(new ChunkSerializer(), new RegionReaderWriter(new File("worlds", world.getWorldId().toString()))); - new WorldReaderWriter(new File("worlds")).writeWorldInfo(world); - /*worldGenerator.generateRegion(1, 0, world); - worldGenerator.generateRegion(-1, 0, world); - worldGenerator.generateRegion(0, 1, world); - worldGenerator.generateRegion(0, -1, world); - worldGenerator.generateRegion(-1, -1, world); - worldGenerator.generateRegion(1, -1, world); - worldGenerator.generateRegion(-1, 1, world); - worldGenerator.generateRegion(1, 1, world); + new WorldReaderWriter(new File("worlds")).writeWorldInfo(world);*/ + + createBigImage(worldGenerator, world); + } + + private static void createBigImage (WorldGenerator worldGenerator, World world) throws IOException { BufferedImage image = new BufferedImage(3 * 256, 3 * 256, BufferedImage.TYPE_INT_RGB); - BufferedImage currentImage; - int shiftX; - int shiftY; - currentImage = ImageIO.read(new File("out/0.0", "biomeMap.png")); - shiftX = 1; - shiftY = 1; + for (int x = 0; x <= 2; x ++) { + for (int z = 0; z <= 2; z ++) { + worldGenerator.generateRegion(x - 1, z - 1, world); + addToBigImage(x, z, image); + } + } + ImageIO.write(image, "png", new File("out", "merged.png")); + } + + private static void addToBigImage (int shiftX, int shiftY, BufferedImage image) throws IOException{ + BufferedImage currentImage = ImageIO.read(new File("out/" + (shiftX - 1) + "." + (shiftY - 1), "biomeMap.png")); for (int x = 0; x < 256; x ++){ for (int y = 0; y < 256; y ++){ int tx = 256 * shiftX + x; @@ -51,87 +51,6 @@ public class SeedBasedWorldGenerator implements WorldGenerator { image.setRGB(tx, ty, currentImage.getRGB(x, y)); } } - currentImage = ImageIO.read(new File("out/0.1", "biomeMap.png")); - shiftX = 1; - shiftY = 2; - for (int x = 0; x < 256; x ++){ - for (int y = 0; y < 256; y ++){ - int tx = 256 * shiftX + x; - int ty = 256 * shiftY + y; - image.setRGB(tx, ty, currentImage.getRGB(x, y)); - } - } - currentImage = ImageIO.read(new File("out/1.0", "biomeMap.png")); - shiftX = 2; - shiftY = 1; - for (int x = 0; x < 256; x ++){ - for (int y = 0; y < 256; y ++){ - int tx = 256 * shiftX + x; - int ty = 256 * shiftY + y; - image.setRGB(tx, ty, currentImage.getRGB(x, y)); - } - } - currentImage = ImageIO.read(new File("out/-1.0", "biomeMap.png")); - shiftX = 0; - shiftY = 1; - for (int x = 0; x < 256; x ++){ - for (int y = 0; y < 256; y ++){ - int tx = 256 * shiftX + x; - int ty = 256 * shiftY + y; - image.setRGB(tx, ty, currentImage.getRGB(x, y)); - } - } - currentImage = ImageIO.read(new File("out/0.-1", "biomeMap.png")); - shiftX = 1; - shiftY = 0; - for (int x = 0; x < 256; x ++){ - for (int y = 0; y < 256; y ++){ - int tx = 256 * shiftX + x; - int ty = 256 * shiftY + y; - image.setRGB(tx, ty, currentImage.getRGB(x, y)); - } - } - currentImage = ImageIO.read(new File("out/-1.-1", "biomeMap.png")); - shiftX = 0; - shiftY = 0; - for (int x = 0; x < 256; x ++){ - for (int y = 0; y < 256; y ++){ - int tx = 256 * shiftX + x; - int ty = 256 * shiftY + y; - image.setRGB(tx, ty, currentImage.getRGB(x, y)); - } - } - currentImage = ImageIO.read(new File("out/1.-1", "biomeMap.png")); - shiftX = 2; - shiftY = 0; - for (int x = 0; x < 256; x ++){ - for (int y = 0; y < 256; y ++){ - int tx = 256 * shiftX + x; - int ty = 256 * shiftY + y; - image.setRGB(tx, ty, currentImage.getRGB(x, y)); - } - } - currentImage = ImageIO.read(new File("out/1.1", "biomeMap.png")); - shiftX = 2; - shiftY = 2; - for (int x = 0; x < 256; x ++){ - for (int y = 0; y < 256; y ++){ - int tx = 256 * shiftX + x; - int ty = 256 * shiftY + y; - image.setRGB(tx, ty, currentImage.getRGB(x, y)); - } - } - currentImage = ImageIO.read(new File("out/-1.1", "biomeMap.png")); - shiftX = 0; - shiftY = 2; - for (int x = 0; x < 256; x ++){ - for (int y = 0; y < 256; y ++){ - int tx = 256 * shiftX + x; - int ty = 256 * shiftY + y; - image.setRGB(tx, ty, currentImage.getRGB(x, y)); - } - } - ImageIO.write(image, "png", new File("out", "merged.png"));*/ } @Override