public void RunGenerator(MCUtils.World world, int x, int y, int z) { if (world.GetBlock(x, y, z) != "minecraft:grass_block") { return; } foreach (var k in mainStructures.Keys) { if (rand.NextDouble() < mainStructures[k] && BuildStructure(k, world, x, y + 1, z)) { return; } } foreach (var k in decorStructures.Keys) { if (rand.NextDouble() < decorStructures[k] && BuildSingleBlock(k, world, x, y + 1, z)) { return; } } }
private bool PlaceTree(MCUtils.World world, int x, int y, int z) { var b = world.GetBlock(x, y - 1, z); if (b == null || !CanGrowPlant(b)) { return(false); } int bareTrunkHeight = random.Next(1, 4); int w = treeRadius; if (!world.IsAir(x, y + 1, z)) { return(false); } //if(IsObstructed(region, x, y+1, z, x, y+bareTrunkHeight, z) || IsObstructed(region, x-w, y+bareTrunkHeight, z-w, x+w, y+bareTrunkHeight+treeTopHeight, z+w)) return false; world.SetBlock(x, y - 1, z, "minecraft:dirt"); for (int i = 0; i <= bareTrunkHeight; i++) { world.SetBlock(x, y + i, z, "minecraft:oak_log"); } for (int ly = 0; ly < treeTopHeight; ly++) { for (int lz = 0; lz < 2 * treeRadius + 1; lz++) { for (int lx = 0; lx < 2 * treeRadius + 1; lx++) { int palette = blueprintOakTreeTop[ly, lz, lx]; if (palette > 0) { string block = palette == 1 ? "minecraft:oak_log" : "minecraft:oak_leaves"; world.SetBlock(x + lx - treeRadius, y + ly + bareTrunkHeight + 1, z + lz - treeRadius, block); } } } } return(true); }