示例#1
0
 public static void HandleBlockChange(IPacket _packet, MultiplayerClient client)
 {
     var packet = (BlockChangePacket)_packet;
     var coordinates = new Coordinates3D(packet.X, packet.Y, packet.Z);
     Coordinates3D adjusted;
     IChunk chunk;
     try
     {
         adjusted = client.World.World.FindBlockPosition(coordinates, out chunk);
     }
     catch (ArgumentException)
     {
         // Relevant chunk is not loaded - ignore packet
         return;
     }
     chunk.SetBlockID(adjusted, (byte)packet.BlockID);
     chunk.SetMetadata(adjusted, (byte)packet.Metadata);
     client.OnBlockChanged(new BlockChangeEventArgs(coordinates, new TrueCraft.API.Logic.BlockDescriptor(),
         new TrueCraft.API.Logic.BlockDescriptor()));
     client.OnChunkModified(new ChunkEventArgs(new ReadOnlyChunk(chunk)));
 }
示例#2
0
        public static void HandleBlockChange(IPacket _packet, MultiplayerClient client)
        {
            var           packet      = (BlockChangePacket)_packet;
            var           coordinates = new Coordinates3D(packet.X, packet.Y, packet.Z);
            Coordinates3D adjusted;
            IChunk        chunk;

            try
            {
                adjusted = client.World.World.FindBlockPosition(coordinates, out chunk);
            }
            catch (ArgumentException)
            {
                // Relevant chunk is not loaded - ignore packet
                return;
            }
            chunk.SetBlockID(adjusted, (byte)packet.BlockID);
            chunk.SetMetadata(adjusted, (byte)packet.Metadata);
            client.OnBlockChanged(new BlockChangeEventArgs(coordinates, new TrueCraft.API.Logic.BlockDescriptor(),
                                                           new TrueCraft.API.Logic.BlockDescriptor()));
            client.OnChunkModified(new ChunkEventArgs(new ReadOnlyChunk(chunk)));
        }