private void GenerateHeightMap(IChunkColumn chunk) { BlockCoordinates coords; var map = new byte[16, 16]; for (byte x = 0; x < 16; x++) { for (byte z = 0; z < 16; z++) { for (byte y = (byte)(chunk.GetHeight(x, z) + 2); y > 0; y--) { if (y >= 255) { continue; } coords.X = x; coords.Y = y - 1; coords.Z = z; var provider = chunk.GetBlockState(coords.X, coords.Y, coords.Z).Block; if (!provider.Renderable) { continue; } if (provider == null || provider.LightOpacity != 0) { map[x, z] = y; break; } } } } HeightMaps[new ChunkCoordinates(chunk.X, chunk.Z)] = map; }
private void InitiateChunk(IChunkColumn chunkColumn, ChunkCoordinates chunkCoordinates) { var chunkCoords = new BlockCoordinates(chunkCoordinates.X * 16, 0, chunkCoordinates.Z * 16); for (int x = 0; x < 16; x++) { for (int z = 0; z < 16; z++) { for (int y = 255; y > 0; y--) { var blockState = chunkColumn.GetBlockState(x, y, z); if (blockState.Block is Block b) { b.BlockPlaced(World, blockState, chunkCoords + new BlockCoordinates(x, y, z)); } } } } }