internal override void Generate(Chunk chunk) { this.chunk = chunk; PositionBlock pos; chunk.Position.GetGlobalPositionBlock(out pos, 0, 0, 0); noise3D = GetScaledNoise(pos, 0.04f); PositionBlock pos2 = pos; pos2.Y = 0; noise2D = GetScaledNoise(pos2, 0.01f); for (int x = 0; x < 16; x++) { for (int z = 0; z < 16; z++) { for (int y = 0; y < 16; y++) { float height = pos.Y + y; if (height == 0) { chunk.SetLocalBlock(x, y, z, BlockRepository.BedRock.Id); } else if (height <= 60) { chunk.SetLocalBlock(x, y, z, BlockRepository.Stone.Id); } else if (height <= 80) { float limit = CalcOffset(height, 60, 80) * 2f - 1f; Magic(height, x, y, z, BlockRepository.Stone.Id, limit); } } } } }
internal override void Generate(Chunk chunk) { if (disableRecursivecalls) return; disableRecursivecalls = true; PositionBlock positionBlock; for (int x = 0; x < 16; x++) { for (int z = 0; z < 16; z++) { for (int y = 0; y < 16; y++) { chunk.Position.GetGlobalPositionBlock(out positionBlock, x, y, z); int globalY = positionBlock.Y; if (globalY < 32) { chunk.SetLocalBlock(x, y, z, BlockRepository.Stone.Id); continue; } else if (globalY < 64) { chunk.SetLocalBlock(x, y, z, BlockRepository.Dirt.Id); continue; } if (globalY == 64) { chunk.SetLocalBlock(x, y, z, BlockRepository.DirtWithGrass.Id); continue; } } } } disableRecursivecalls = false; }
internal override void Generate(Chunk chunk) { if (disableRecursivecalls) return; disableRecursivecalls = true; PositionBlock positionBlock; for (int x = 0; x < 16; x++) { for (int z = 0; z < 16; z++) { for (int y = 0; y < 16; y++) { chunk.Position.GetGlobalPositionBlock(out positionBlock, x, y, z); int globalY = positionBlock.Y; if (globalY < 32) { chunk.SetLocalBlock(x, y, z, BlockRepository.Stone.Id); continue; } else if (globalY < 64) { chunk.SetLocalBlock(x, y, z, BlockRepository.Dirt.Id); continue; } if (globalY == 64) { if (chunk.Position.X == 1 && chunk.Position.Z == -1 && globalY == 64) { //chunk.SafeSetLocalBlock(x, y, z, BlockRepository.Water.Id); } else chunk.SetLocalBlock(x, y, z, BlockRepository.DirtWithGrass.Id); continue; } // hit me with some artifacts for collision detection: if (chunk.Position.X == -2 && chunk.Position.Z == -2 && globalY == 65) { if (x % 4 + z % 4 == 0) { chunk.SafeSetLocalBlock(x, y, z, BlockRepository.Sand.Id); } } else if (chunk.Position.X == -1 && chunk.Position.Z == -2 && globalY == 65) { chunk.SafeSetLocalBlock(x, y, z, BlockRepository.TallGrass.Id); } else if (chunk.Position.X == -3 && chunk.Position.Z == -3 && globalY < 16-x - z + 65) { chunk.SafeSetLocalBlock(x, y, z, globalY == 16-x - z + 64 ? BlockRepository.DirtWithGrass.Id : BlockRepository.Dirt.Id); } else if (chunk.Position.X == -1 && chunk.Position.Z == -1 && globalY < 16 - x - z + 65) { chunk.SafeSetLocalBlock(15 - x, y, 15 - z, globalY == 16 - x - z + 64 ? BlockRepository.CobbleStone.Id : BlockRepository.Stone.Id); } else if (chunk.Position.X == -2 && chunk.Position.Z == -3 && globalY > 64 && globalY < 68) { if (x % 2 + z % 2 == 0) { chunk.SafeSetLocalBlock(x, y, z, BlockRepository.Wood.Id); } } } } } disableRecursivecalls = false; }