diff --git a/Anvil-API.md b/Anvil-API.md index 18c11e2..0e574ec 100644 --- a/Anvil-API.md +++ b/Anvil-API.md @@ -11,6 +11,40 @@ MCAWorld world = new MCAWorld(worldName, root, hasSky); MCAQueue queue = world.getQueue(); // Do stuff here with the FaweQueue ``` +# Generating MCA files +See [HeightMapMCAGenerator](https://github.com/boy0001/FastAsyncWorldedit/blob/master/core/src/main/java/com/boydti/fawe/jnbt/anvil/HeightMapMCAGenerator.java) +```Java +File dir = new File("TestWorld/region"); +// Create a new generator from a heightmap +// Note: If you don't want to use an image, use the other constructor +BufferedImage heightMap = ImageIO.read(new URL("https://i.imgur.com/plFXYiI.png")); +// Our new generator +HeightMapMCAGenerator gen = new HeightMapMCAGenerator(heightMap, dir); +// Add some cliffs +BufferedImage cliffHeightMap = ImageIO.read(new URL("https://i.imgur.com/wx5oiA7.png")); +boolean onlyWhite = false; // Only use the white parts of the heightmap +gen.setColumn(cliffHeightMap, new BaseBlock(BlockID.STONE), onlyWhite); +// Add some tallgrass +gen.setOverlay(new BlockMask(gen, new BaseBlock(BlockID.GRASS)), new BaseBlock(BlockID.LONG_GRASS)); +// Add some caves +gen.addCaves(); +// Add some ores +gen.addDefaultOres(new BlockMask(gen, new BaseBlock(BlockID.STONE))); +// Add some trees +World world = WorldEdit.getInstance().getServer().getWorlds().get(0); +WorldData worldData = world.getWorldData(); +File treeFolder = new File("trees"); +ClipboardHolder[] trees = ClipboardFormat.SCHEMATIC.loadAllFromDirectory(treeFolder, worldData); +Mask flat = new AngleMask(gen, 0, 0); // Only flat terrain +boolean randomRotate = true; +gen.addSchems(flat, worldData, trees, 50, randomRotate); +// You can also get/set specific blocks +// Note: Individual block changes are slower than the methods above +gen.setBlock(0, 255, 0, new BaseBlock(BlockID.SPONGE)); // Set a specific block +System.out.println(gen.getLazyBlock(0, 255, 0)); // Get a specific block +// Done, let's generate the world! +gen.generate(); +``` # Using with an EditSession ```Java String worldName = "world";