public override void Decorate(Chunk chunk, Position pos, OverworldNoise noise) { if (pos.Y == 61) // rivers at sea level { chunk.SetBlock(new Position(pos.X, 61, pos.Z), Registry.GetBlock(Material.FrostedIce)); // TODO: this is mega broken } }
public override void Decorate(Chunk chunk, Position pos, OverworldNoise noise) { int worldX = (chunk.X << 4) + (int)pos.X; int worldZ = (chunk.Z << 4) + (int)pos.Z; var sand = Registry.GetBlock(Materials.SnowBlock); var sandstone = Registry.GetBlock(Materials.PackedIce); var deadbush = Registry.GetBlock(Materials.Snow); var cactus = Registry.GetBlock(Materials.FrostedIce); for (int y = 0; y > -4; y--) { chunk.SetBlock(pos + (0, y, 0), sand); } for (int y = -4; y > -7; y--) { chunk.SetBlock(pos + (0, y, 0), sandstone); } var bushNoise = noise.Decoration(worldX * 0.1, 0, worldZ * 0.1); if (bushNoise > 0 && bushNoise < 0.05) // 5% chance for bush { chunk.SetBlock(pos + (0, 1, 0), deadbush); } var cactusNoise = noise.Decoration(worldX * 0.1, 1, worldZ * 0.1); if (cactusNoise > 0 && cactusNoise < 0.01) // 1% chance for cactus { chunk.SetBlock(pos + (0, 1, 0), cactus); } }
public override void Decorate(Chunk chunk, Vector pos, OverworldNoise noise) { int worldX = (chunk.X << 4) + pos.X; int worldZ = (chunk.Z << 4) + pos.Z; var sand = Registry.GetBlock(Material.Sand); var sandstone = Registry.GetBlock(Material.Sandstone); var deadbush = Registry.GetBlock(Material.DeadBush); var cactus = Registry.GetBlock(Material.Cactus); for (int y = 0; y > -4; y--) { chunk.SetBlock(pos + (0, y, 0), sand); } for (int y = -4; y > -7; y--) { chunk.SetBlock(pos + (0, y, 0), sandstone); } var bushNoise = noise.Decoration(worldX * 0.1, 0, worldZ * 0.1); if (bushNoise > 0 && bushNoise < 0.05) // 5% chance for bush { chunk.SetBlock(pos + (0, 1, 0), deadbush); } var cactusNoise = noise.Decoration(worldX * 0.1, 1, worldZ * 0.1); if (cactusNoise > 0 && cactusNoise < 0.01) // 1% chance for cactus { chunk.SetBlock(pos + (0, 1, 0), cactus); chunk.SetBlock(pos + (0, 2, 0), cactus); chunk.SetBlock(pos + (0, 3, 0), cactus); } }
public override void Decorate(Chunk chunk, Position pos, OverworldNoise noise) { if (pos.Y < 65) { chunk.SetBlock(pos, Registry.GetBlock(Materials.Gravel)); } }
public static void Decorate(Chunk chunk, double[,] terrainHeightMap, OverworldNoise noise) { for (int x = 0; x < 16; x++) { for (int z = 0; z < 16; z++) { var b = ChunkBiome.GetBiome((chunk.X << 4) + x, (chunk.Z << 4) + z, noise); IDecorator decorator = DecoratorFactory.GetDecorator(b); var blockPos = new Vector(x, (int)terrainHeightMap[x, z], z); decorator.Decorate(chunk, blockPos, noise); } } }
public override void Decorate(Chunk chunk, Position pos, OverworldNoise noise) { int worldX = (chunk.X << 4) + (int)pos.X; int worldZ = (chunk.Z << 4) + (int)pos.Z; var sand = Registry.GetBlock(Materials.RedSand); var deadbush = Registry.GetBlock(Materials.DeadBush); var cactus = Registry.GetBlock(Materials.Cactus); chunk.SetBlock(pos, sand); for (int y = -1; y > -15; y--) { var a = (pos.Y + y) % 15; if (a == 15) { chunk.SetBlock(pos + (0, y, 0), Registry.GetBlock(Materials.BrownTerracotta)); } else if (a == 14) { chunk.SetBlock(pos + (0, y, 0), Registry.GetBlock(Materials.WhiteTerracotta)); } else if (a == 13) { chunk.SetBlock(pos + (0, y, 0), Registry.GetBlock(Materials.GrayTerracotta)); } else if (a >= 11) { chunk.SetBlock(pos + (0, y, 0), Registry.GetBlock(Materials.YellowTerracotta)); } else if (a == 8 || a == 9) { chunk.SetBlock(pos + (0, y, 0), Registry.GetBlock(Materials.RedTerracotta)); } else if (a == 6) { chunk.SetBlock(pos + (0, y, 0), Registry.GetBlock(Materials.OrangeTerracotta)); } else if (a == 3) { chunk.SetBlock(pos + (0, y, 0), Registry.GetBlock(Materials.YellowTerracotta)); } else { chunk.SetBlock(pos + (0, y, 0), Registry.GetBlock(Materials.Terracotta)); } } var bushNoise = noise.Decoration(worldX * 0.1, 0, worldZ * 0.1); if (bushNoise > 0 && bushNoise < 0.01) // 1% chance for bush { chunk.SetBlock(pos + (0, 1, 0), deadbush); } var cactusNoise = noise.Decoration(worldX * 0.1, 1, worldZ * 0.1); if (cactusNoise > 0 && cactusNoise < 0.005) // 0.5% chance for cactus { chunk.SetBlock(pos + (0, 1, 0), cactus); chunk.SetBlock(pos + (0, 2, 0), cactus); chunk.SetBlock(pos + (0, 3, 0), cactus); } }
public OverworldGenerator(string seed) : base("overworld") { var seedHash = BitConverter.ToInt32(MD5.Create().ComputeHash(Encoding.UTF8.GetBytes(seed))); noiseGen = new OverworldNoise(seedHash); }
public override void Decorate(Chunk chunk, Position pos, OverworldNoise noise) { int worldX = (chunk.X << 4) + pos.X; int worldZ = (chunk.Z << 4) + pos.Z; // Flowers var grassNoise = noise.Decoration(worldX * 0.1, 8, worldZ * 0.1); if (grassNoise > 0 && grassNoise < 0.5) // 50% chance for grass { chunk.SetBlock(pos + (0, 1, 0), Registry.GetBlock(Material.Grass)); } var poppyNoise = noise.Decoration(worldX * 0.03, 9, worldZ * 0.03); // 0.03 makes more groupings if (poppyNoise > 1) { chunk.SetBlock(pos + (0, 1, 0), Registry.GetBlock(Material.Poppy)); } var dandyNoise = noise.Decoration(worldX * 0.03, 10, worldZ * 0.03); // 0.03 makes more groupings if (dandyNoise > 1) { chunk.SetBlock(pos + (0, 1, 0), Registry.GetBlock(Material.Dandelion)); } var cornFlowerNoise = noise.Decoration(worldX * 0.03, 11, worldZ * 0.03); // 0.03 makes more groupings if (cornFlowerNoise > 1) { chunk.SetBlock(pos + (0, 1, 0), Registry.GetBlock(Material.Cornflower)); } var azureNoise = noise.Decoration(worldX * 0.03, 12, worldZ * 0.03); // 0.03 makes more groupings if (azureNoise > 1) { chunk.SetBlock(pos + (0, 1, 0), Registry.GetBlock(Material.AzureBluet)); } #region Trees // Abandon hope all ye who enter here var oakLeaves = Registry.GetBlock(Material.OakLeaves); var treeNoise = noise.Decoration(worldX * 0.1, 13, worldZ * 0.1); var treeHeight = TreeHeight(treeNoise); if (treeHeight > 0) { //Leaves for (int y = treeHeight + 1; y > treeHeight - 2; y--) { for (int x = pos.X - 2; x <= pos.X + 2; x++) { for (int z = pos.Z - 2; z <= pos.Z + 2; z++) { var loc = new Position(x, y + pos.Y, z).ChunkClamp(); // Skip the top edges. if (y == treeHeight + 1) { if (x != pos.X - 2 && x != pos.X + 2 && z != pos.Z - 2 && z != pos.Z + 2) { chunk.SetBlock(loc, oakLeaves); } } else { chunk.SetBlock(loc, oakLeaves); } } } } for (int y = 1; y <= treeHeight; y++) { chunk.SetBlock(pos + (0, y, 0), new Block(74)); } } // If on the edge of the chunk, check if neighboring chunks need leaves. if (pos.X == 0) { // Check out to 2 blocks into the neighboring chunk's noisemap and see if there's a tree center (top log) var neighborTree1 = TreeHeight(noise.Decoration((worldX - 1) * 0.1, 13, worldZ * 0.1)); var neighborTree2 = TreeHeight(noise.Decoration((worldX - 2) * 0.1, 13, worldZ * 0.1)); var rowsToDraw = neighborTree1 > 0 ? 2 : neighborTree2 > 0 ? 1 : 0; var treeY = Math.Max(neighborTree1, neighborTree2) + (int)noise.Terrain(worldX - 1, worldZ); for (int x = 0; x < rowsToDraw; x++) { for (int z = pos.Z - 2; z <= pos.Z + 2; z++) { for (int y = treeY + 1; y > treeY - 2; y--) { var loc = new Position(x, y, z).ChunkClamp(); // Skip the top edges. if (y == treeY + 1) { if (x != rowsToDraw - 1 && z != pos.Z - 2 && z != pos.Z + 2) { chunk.SetBlock(loc, oakLeaves); } } else { chunk.SetBlock(loc, oakLeaves); } } } } } else if (pos.X == 15) { // Check out to 2 blocks into the neighboring chunk's noisemap and see if there's a tree center (top log) var neighborTree1 = TreeHeight(noise.Decoration((worldX + 1) * 0.1, 13, worldZ * 0.1)); var neighborTree2 = TreeHeight(noise.Decoration((worldX + 2) * 0.1, 13, worldZ * 0.1)); var rowsToDraw = neighborTree1 > 0 ? 2 : neighborTree2 > 0 ? 1 : 0; var treeY = Math.Max(neighborTree1, neighborTree2) + (int)noise.Terrain(worldX + 1, worldZ); for (int x = 15; x > 15 - rowsToDraw; x--) { for (int z = pos.Z - 2; z <= pos.Z + 2; z++) { for (int y = treeY + 1; y > treeY - 2; y--) { var loc = new Position(x, y, z).ChunkClamp(); // Skip the top edges. if (y == treeY + 1) { if (x != 16 - rowsToDraw && z != pos.Z - 2 && z != pos.Z + 2) { chunk.SetBlock(loc, oakLeaves); } } else { chunk.SetBlock(loc, oakLeaves); } } } } } if (pos.Z == 0) { // Check out to 2 blocks into the neighboring chunk's noisemap and see if there's a tree center (top log) var neighborTree1 = TreeHeight(noise.Decoration(worldX * 0.1, 13, (worldZ - 1) * 0.1)); var neighborTree2 = TreeHeight(noise.Decoration(worldX * 0.1, 13, (worldZ - 2) * 0.1)); var rowsToDraw = neighborTree1 > 0 ? 2 : neighborTree2 > 0 ? 1 : 0; var treeY = Math.Max(neighborTree1, neighborTree2) + (int)noise.Terrain(worldX, worldZ - 1); for (int z = 0; z < rowsToDraw; z++) { for (int x = pos.X - 2; x <= pos.X + 2; x++) { for (int y = treeY + 1; y > treeY - 2; y--) { var loc = new Position(x, y, z).ChunkClamp(); // Skip the top edges. if (y == treeY + 1) { if (x != pos.X - 2 && x != pos.X + 2 && z != rowsToDraw - 1) { chunk.SetBlock(loc, oakLeaves); } } else { chunk.SetBlock(loc, oakLeaves); } } } } } else if (pos.Z == 15) { // Check out to 2 blocks into the neighboring chunk's noisemap and see if there's a tree center (top log) var neighborTree1 = TreeHeight(noise.Decoration(worldX * 0.1, 13, (worldZ + 1) * 0.1)); var neighborTree2 = TreeHeight(noise.Decoration(worldX * 0.1, 13, (worldZ + 2) * 0.1)); var rowsToDraw = neighborTree1 > 0 ? 2 : neighborTree2 > 0 ? 1 : 0; var treeY = Math.Max(neighborTree1, neighborTree2) + (int)noise.Terrain(worldX, worldZ + 1); for (int z = 15; z > 15 - rowsToDraw; z--) { for (int x = pos.X - 2; x <= pos.X + 2; x++) { for (int y = treeY + 1; y > treeY - 2; y--) { var loc = new Position(x, y, z).ChunkClamp(); // Skip the top edges. if (y == treeY + 1) { if (x != pos.X - 2 && x != pos.X + 2 && z != 16 - rowsToDraw) { chunk.SetBlock(loc, oakLeaves); } } else { chunk.SetBlock(loc, oakLeaves); } } } } } #endregion }
public override void Decorate(Chunk chunk, Position pos, OverworldNoise noise) { int worldX = (chunk.X << 4) + (int)pos.X; int worldZ = (chunk.Z << 4) + (int)pos.Z; var sand = Registry.GetBlock(Materials.SnowBlock); var sandstone = Registry.GetBlock(Materials.PackedIce); var deadbush = Registry.GetBlock(Materials.Snow); var cactus = Registry.GetBlock(Materials.FrostedIce); for (int y = 0; y > -4; y--) { chunk.SetBlock(pos + (0, y, 0), sand); } for (int y = -4; y > -7; y--) { chunk.SetBlock(pos + (0, y, 0), sandstone); } var bushNoise = noise.Decoration(worldX * 0.1, 0, worldZ * 0.1); if (bushNoise > 0 && bushNoise < 0.05) // 5% chance for bush { chunk.SetBlock(pos + (0, 1, 0), deadbush); } var cactusNoise = noise.Decoration(worldX * 0.1, 1, worldZ * 0.1); if (cactusNoise > 0 && cactusNoise < 0.01) // 1% chance for cactus { chunk.SetBlock(pos + (0, 1, 0), cactus); } #region Trees // Abandon hope all ye who enter here var oakLeaves = Registry.GetBlock(Materials.OakLeaves); var treeNoise = noise.Decoration(worldX * 0.1, 13, worldZ * 0.1); var treeHeight = TreeHeight(treeNoise); if (treeHeight > 0) { //Leaves for (int y = treeHeight + 1; y > treeHeight - 2; y--) { for (double x = pos.X - 2; x <= pos.X + 2; x++) { for (double z = pos.Z - 2; z <= pos.Z + 2; z++) { var loc = new Position(x, y + pos.Y, z).ChunkClamp(); // Skip the top edges. if (y == treeHeight + 1) { if (x != pos.X - 2 && x != pos.X + 2 && z != pos.Z - 2 && z != pos.Z + 2) { chunk.SetBlock(loc, oakLeaves); } } else { chunk.SetBlock(loc, oakLeaves); } } } } for (int y = 1; y <= treeHeight; y++) { chunk.SetBlock(pos + (0, y, 0), new Block("oak_log", 74, Materials.OakLog)); } } // If on the edge of the chunk, check if neighboring chunks need leaves. if (pos.X == 0) { // Check out to 2 blocks into the neighboring chunk's noisemap and see if there's a tree center (top log) var neighborTree1 = TreeHeight(noise.Decoration((worldX - 1) * 0.1, 13, worldZ * 0.1)); var neighborTree2 = TreeHeight(noise.Decoration((worldX - 2) * 0.1, 13, worldZ * 0.1)); var rowsToDraw = neighborTree1 > 0 ? 2 : neighborTree2 > 0 ? 1 : 0; var treeY = Math.Max(neighborTree1, neighborTree2) + (int)noise.Terrain(worldX - 1, worldZ); for (int x = 0; x < rowsToDraw; x++) { for (double z = pos.Z - 2; z <= pos.Z + 2; z++) { for (int y = treeY + 1; y > treeY - 2; y--) { var loc = new Position(x, y, z).ChunkClamp(); // Skip the top edges. if (y == treeY + 1) { if (x != rowsToDraw - 1 && z != pos.Z - 2 && z != pos.Z + 2) { chunk.SetBlock(loc, oakLeaves); } } else { chunk.SetBlock(loc, oakLeaves); } } } } } else if (pos.X == 15) { // Check out to 2 blocks into the neighboring chunk's noisemap and see if there's a tree center (top log) var neighborTree1 = TreeHeight(noise.Decoration((worldX + 1) * 0.1, 13, worldZ * 0.1)); var neighborTree2 = TreeHeight(noise.Decoration((worldX + 2) * 0.1, 13, worldZ * 0.1)); var rowsToDraw = neighborTree1 > 0 ? 2 : neighborTree2 > 0 ? 1 : 0; var treeY = Math.Max(neighborTree1, neighborTree2) + (int)noise.Terrain(worldX + 1, worldZ); for (int x = 15; x > 15 - rowsToDraw; x--) { for (double z = pos.Z - 2; z <= pos.Z + 2; z++) { for (int y = treeY + 1; y > treeY - 2; y--) { var loc = new Position(x, y, z).ChunkClamp(); // Skip the top edges. if (y == treeY + 1) { if (x != 16 - rowsToDraw && z != pos.Z - 2 && z != pos.Z + 2) { chunk.SetBlock(loc, oakLeaves); } } else { chunk.SetBlock(loc, oakLeaves); } } } } } if (pos.Z == 0) { // Check out to 2 blocks into the neighboring chunk's noisemap and see if there's a tree center (top log) var neighborTree1 = TreeHeight(noise.Decoration(worldX * 0.1, 13, (worldZ - 1) * 0.1)); var neighborTree2 = TreeHeight(noise.Decoration(worldX * 0.1, 13, (worldZ - 2) * 0.1)); var rowsToDraw = neighborTree1 > 0 ? 2 : neighborTree2 > 0 ? 1 : 0; var treeY = Math.Max(neighborTree1, neighborTree2) + (int)noise.Terrain(worldX, worldZ - 1); for (int z = 0; z < rowsToDraw; z++) { for (double x = pos.X - 2; x <= pos.X + 2; x++) { for (int y = treeY + 1; y > treeY - 2; y--) { var loc = new Position(x, y, z).ChunkClamp(); // Skip the top edges. if (y == treeY + 1) { if (x != pos.X - 2 && x != pos.X + 2 && z != rowsToDraw - 1) { chunk.SetBlock(loc, oakLeaves); } } else { chunk.SetBlock(loc, oakLeaves); } } } } } else if (pos.Z == 15) { // Check out to 2 blocks into the neighboring chunk's noisemap and see if there's a tree center (top log) var neighborTree1 = TreeHeight(noise.Decoration(worldX * 0.1, 13, (worldZ + 1) * 0.1)); var neighborTree2 = TreeHeight(noise.Decoration(worldX * 0.1, 13, (worldZ + 2) * 0.1)); var rowsToDraw = neighborTree1 > 0 ? 2 : neighborTree2 > 0 ? 1 : 0; var treeY = Math.Max(neighborTree1, neighborTree2) + (int)noise.Terrain(worldX, worldZ + 1); for (int z = 15; z > 15 - rowsToDraw; z--) { for (double x = pos.X - 2; x <= pos.X + 2; x++) { for (int y = treeY + 1; y > treeY - 2; y--) { var loc = new Position(x, y, z).ChunkClamp(); // Skip the top edges. if (y == treeY + 1) { if (x != pos.X - 2 && x != pos.X + 2 && z != 16 - rowsToDraw) { chunk.SetBlock(loc, oakLeaves); } } else { chunk.SetBlock(loc, oakLeaves); } } } } } #endregion }
public override void Decorate(Chunk chunk, Position pos, OverworldNoise noise) { }
public abstract void Decorate(Chunk chunk, Vector position, OverworldNoise noise);
public override void Decorate(Chunk chunk, Vector pos, OverworldNoise noise) { }
public abstract void Decorate(Chunk chunk, Position pos, OverworldNoise noise);