Exemplo n.º 1
0
 /// <summary>
 /// Sets the block at the given position in local coordinates.
 /// </summary>
 public void SetBlock(Vector3I position, ChunkBlock value)
 {
     var x = (int)position.X;
     var y = (int)position.Y;
     var z = (int)position.Z;
     int index = x + (z*Width) + (y*Height*Width);
     Blocks[index] = (byte)value.type; // TODO: Allow block IDs greater than 255
     Metadata[index] = value.metadata;
     BlockLight[index] = value.lighting;
     //SkyLight[index] = value.SkyLight;
     if (value.type == 0)
         nonAirCount--;
     else
         nonAirCount++;
 }
Exemplo n.º 2
0
        public void CalculateLighting()
        {
            Logger.Log( LogType.Debug, "Calculating lighting for chunk ({0}, {1})", X, Z );

            // Loop through all blocks and search for light sources
            for ( byte bX = 0; bX < 16; bX++ ) {
                for ( byte bY = 0; bY < 128; bY++ ) {
                    for ( byte bZ = 0; bZ < 16; bZ++ ) {
                        if ( bY >= world.Map.Blocks[GetHeightmapIndex( bX, bZ )] ) {
                            ChunkBlock curBlock = new ChunkBlock( ( byte )world.Map.GetBlock( bX, bY, bZ ), 0, 1 );
                            curBlock.lighting = 0x0F;
                            // SetBlock( curBlock, bX, bY, bZ );
                        }
                    }
                }
            }

            terrainPopulated = true;
        }
Exemplo n.º 3
0
 /// <summary>
 /// Gets the block at the given position in local coordinates.
 /// </summary>
 public ChunkBlock GetBlock( Vector3I position )
 {
     var x = (int)position.X;
     var y = (int)position.Y;
     var z = (int)position.Z;
     int index = x + (z*Width) + (y*Height*Width);
     ChunkBlock block = new ChunkBlock() { type = Blocks[index], lighting = 5, metadata = 0 };
     return block;
 }