Esempio n. 1
0
        internal void LoadChunk(IChunk chunk)
        {
            QueuePacket(new ChunkPreamblePacket(chunk.Coordinates.X, chunk.Coordinates.Z));
            QueuePacket(CreatePacket(chunk));
            Server.Scheduler.ScheduleEvent("client.finalize-chunks", this,
                                           TimeSpan.Zero, server =>
            {
                return;

                LoadedChunks.Add(chunk.Coordinates);
                foreach (var kvp in chunk.TileEntities)
                {
                    var coords     = kvp.Key;
                    var descriptor = new BlockDescriptor
                    {
                        Coordinates = coords + new Coordinates3D(chunk.X, 0, chunk.Z),
                        Metadata    = chunk.GetMetadata(coords),
                        ID          = chunk.GetBlockID(coords),
                        BlockLight  = chunk.GetBlockLight(coords),
                        SkyLight    = chunk.GetSkyLight(coords)
                    };
                    var provider = Server.BlockRepository.GetBlockProvider(descriptor.ID);
                    provider.TileEntityLoadedForClient(descriptor, World, kvp.Value, this);
                }
            });
        }
Esempio n. 2
0
        /// <summary>
        /// </summary>
        /// <param name="chunk"></param>
        /// <param name="coords"></param>
        /// <returns></returns>
        protected static int GetLight(IChunk chunk, Coordinates3D coords)
        {
            // Handle icon renderer.
            if (chunk == null)
            {
                return(15);
            }

            // Handle top (and bottom) of the world.
            if (coords.Y < 0)
            {
                return(0);
            }
            if (coords.Y >= Chunk.Height)
            {
                return(15);
            }

            // Handle coordinates outside the chunk.
            if (coords.X < 0 || coords.X >= Chunk.Width ||
                coords.Z < 0 || coords.Z >= Chunk.Depth)
            {
                return(15);
            }

            return(Math.Min(chunk.GetBlockLight(coords) + chunk.GetSkyLight(coords), 15));
        }
Esempio n. 3
0
 private BlockDescriptor GetBlockDataFromChunk(Coordinates3D adjustedCoordinates, IChunk chunk, Coordinates3D coordinates)
 {
     return(new BlockDescriptor
     {
         ID = chunk.GetBlockID(adjustedCoordinates),
         Metadata = chunk.GetMetadata(adjustedCoordinates),
         BlockLight = chunk.GetBlockLight(adjustedCoordinates),
         SkyLight = chunk.GetSkyLight(adjustedCoordinates),
         Coordinates = coordinates
     });
 }
Esempio n. 4
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="chunk"></param>
        /// <param name="coords"></param>
        /// <returns></returns>
        protected static int GetLight(IChunk chunk, Coordinates3D coords)
        {
            // Handle icon renderer.
            if (chunk == null)
                return 15;

            // Handle top (and bottom) of the world.
            if (coords.Y < 0)
                return 0;
            if (coords.Y >= Chunk.Height)
                return 15;

            // Handle coordinates outside the chunk.
            if ((coords.X < 0) || (coords.X >= Chunk.Width) ||
                (coords.Z < 0) || (coords.Z >= Chunk.Depth))
            {
                // TODO: Handle chunk boundaries properly.
                return 0;
            }

            return Math.Min(chunk.GetBlockLight(coords) + chunk.GetSkyLight(coords), 15);
        }
Esempio n. 5
0
 public byte GetSkyLight(Coordinates3D coordinates)
 {
     return(Chunk.GetSkyLight(coordinates));
 }
Esempio n. 6
0
 private BlockDescriptor GetBlockDataFromChunk(Coordinates3D adjustedCoordinates, IChunk chunk, Coordinates3D coordinates)
 {
     return new BlockDescriptor
     {
         ID = chunk.GetBlockID(adjustedCoordinates),
         Metadata = chunk.GetMetadata(adjustedCoordinates),
         BlockLight = chunk.GetBlockLight(adjustedCoordinates),
         SkyLight = chunk.GetSkyLight(adjustedCoordinates),
         Coordinates = coordinates
     };
 }
Esempio n. 7
0
        public int GetSkyLight(int x, int y, int z)
        {
            IChunk chunk = _chunkCache.GetChunk(new ChunkCoord(x >> 4, z >> 4));

            return(chunk.GetSkyLight(x & 15, y, z & 15));
        }