internal void Decorate(Chunk chunk) { Random rnd = new Random(chunk.Position.X * 12345 ^ chunk.Position.Y * 23456 ^ chunk.Position.Z * 34657); PositionBlock chunkCorner; chunk.Position.GetMinCornerBlock(out chunkCorner); ChunkPointer pointer = ChunkPointer.Create(chunkCorner.X, chunkCorner.Y, chunkCorner.Z); tree.Pointer = pointer; bush.Pointer = pointer; house.Pointer = pointer; for (int x = chunkCorner.X; x < chunkCorner.X + 16; x++) { for (int z = chunkCorner.Z; z < chunkCorner.Z + 16; z++) { for (int y = Chunk.MaxSizeY - 1; y >= 0; y--) { // find top block if (pointer.GetBlock(x, y, z) == BlockRepository.Stone.Id) { pointer.SetBlock(x, y, z, BlockRepository.DirtWithGrass.Id); double propability = rnd.NextDouble(); if (propability < 0.02) { tree.Plant(x, y + 1, z, rnd.Next(4, 10)); } else if (propability < 0.04) { bush.Plant(x, y + 1, z, rnd.Next(1, 3)); } else if (propability < 0.041) { house.Build(x, y + 1, z, rnd.Next(1, 8)); } break; } } } } }
private void BuildRoof(int x, int y, int z) { for (int dx = 0; dx < 8; dx++) { for (int dz = 0; dz < 8; dz++) { if ((dx + dz) % 2 == 0) { continue; } if (dx == 0 || dz == 0 || dx == 7 || dz == 7) { Pointer.SetBlock(x + dx, y, z + dz, BlockRepository.CobbleStone.Id); } } } }