Пример #1
0
        private static int GetHigestSurrounding(int x, int z, ChunkColumn chunk, IBlockAccess level)
        {
            int h = chunk.GetHeight(x, z);

            if (h == 255)
            {
                return(h);
            }

            if (x == 0 || x == 15 || z == 0 || z == 15)
            {
                var coords = new BlockCoordinates(x + (chunk.x * 16), h, z + (chunk.z * 16));

                //h = Math.Max(h, level.GetHeight(coords + BlockCoordinates.Up));
                h = Math.Max(h, level.GetHeight(coords + BlockCoordinates.West));
                h = Math.Max(h, level.GetHeight(coords + BlockCoordinates.East));
                h = Math.Max(h, level.GetHeight(coords + BlockCoordinates.North));
                h = Math.Max(h, level.GetHeight(coords + BlockCoordinates.South));
                if (h > 255)
                {
                    h = 255;
                }
                if (h < 0)
                {
                    h = 0;
                }
                return(h);
            }

            //if (z < 15) h = Math.Max(h, chunk.GetHeight(x, z + 1));
            //if (z > 0) h = Math.Max(h, chunk.GetHeight(x, z - 1));
            //if (x < 15) h = Math.Max(h, chunk.GetHeight(x + 1, z));
            //if (x < 15 && z > 0) h = Math.Max(h, chunk.GetHeight(x + 1, z - 1));
            //if (x < 15 && z < 15) h = Math.Max(h, chunk.GetHeight(x + 1, z + 1));
            //if (x > 0) h = Math.Max(h, chunk.GetHeight(x - 1, z));
            //if (x > 0 && z > 0) h = Math.Max(h, chunk.GetHeight(x - 1, z - 1));
            //if (x > 0 && z < 15) h = Math.Max(h, chunk.GetHeight(x - 1, z + 1));

            h = Math.Max(h, chunk.GetHeight(x, z + 1));
            h = Math.Max(h, chunk.GetHeight(x, z - 1));
            h = Math.Max(h, chunk.GetHeight(x + 1, z));
            //h = Math.Max(h, chunk.GetHeight(x + 1, z - 1));
            //h = Math.Max(h, chunk.GetHeight(x + 1, z + 1));
            h = Math.Max(h, chunk.GetHeight(x - 1, z));
            //h = Math.Max(h, chunk.GetHeight(x - 1, z - 1));
            //h = Math.Max(h, chunk.GetHeight(x - 1, z + 1));

            return(h);
        }
Пример #2
0
        public static int GetHeight(BlockCoordinates blockCoordinates, ChunkColumn chunk)
        {
            if (chunk == null)
            {
                return(256);
            }

            return(chunk.GetHeight(blockCoordinates.X & 0x0f, blockCoordinates.Z & 0x0f));
        }
Пример #3
0
        public int GetHeight(BlockCoordinates coordinates)
        {
            ChunkColumn chunk = GetChunk(coordinates, true);

            if (chunk == null)
            {
                return(256);
            }

            return(chunk.GetHeight(coordinates.X & 0x0f, coordinates.Z & 0x0f));
        }
Пример #4
0
        public void ShowHeights(ChunkColumn chunk)
        {
            if (chunk == null)
            {
                return;
            }

            for (int x = 0; x < 16; x++)
            {
                for (int z = 0; z < 16; z++)
                {
                    var y = chunk.GetHeight(x, z);
                    chunk.SetBlock(x, y, z, 41);
                    //for (byte y = 255; y > 0; y--)
                    //{
                    //	if (chunk.GetSkylight(x, y, z) == 0)
                    //	{
                    //		chunk.SetBlock(x, y, z, 41);
                    //		break;
                    //	}
                    //}
                }
            }
        }