Esempio n. 1
0
        public void OnEntityAction(ref PacketReader _pReader, PacketType pt, ref ClientManager _client)
        {
            AnimationPacket p = new AnimationPacket(PacketType.EntityAction);
            p.EntityID = _pReader.ReadInt();
            p.Animation = _pReader.ReadByte();
            p.BuildPacket();

            EntityMetadataPacket e_packet = new EntityMetadataPacket(PacketType.EntityMetadata);

            /*
             * /// <summary>
            /// Metadata has a massively quirky packing format,
            /// the details of which are not quite all understood. However,
            /// successful parsing of metadata is possible, according to the following rules.
            /// A metadata field is a byte. The top three bits of the byte,
            /// when masked off and interpreted as a three-bit number from 0 to 7,
            /// indicate the type of the field. The lower five bits are some sort of unknown identifier.
            /// The type of the byte indicates the size and type of a payload which follows the initial byte of the field.
            /// The metadata format consists of at least one field,
            /// followed by either another field or the magic number 0x7F. 0x7F terminates a metadata stream.
            /// Thus, the example metadata stream 0x00 0x01 0x7f is decoded as a field of type 0, id 0,
            /// with a payload of byte 0x00.
            /// </summary>
             * */
        }
Esempio n. 2
0
        public void OnAnimation(ref PacketReader _pReader, PacketType pt, ref ClientManager _client)
        {
            AnimationPacket p = new AnimationPacket(PacketType.Animation);
            p.EntityID = _pReader.ReadInt();
            p.Animation = _pReader.ReadByte();
            p.BuildPacket();
            int index_me = Chunk.GetIndex((int)_client._player.position.X, (int)_client._player.position.Y, (int)_client._player.position.Z);
            ClientManager[] player = GridServer.player_list;
            for (int i = 0; i < player.Length; i++)
            {
                if (player[i] == null)
                {

                }
                else
                {
                    int index_remote = Chunk.GetIndex((int)player[i]._player.position.X, (int)player[i]._player.position.Y, (int)player[i]._player.position.Z);
                    if (index_remote - 5 < index_me && index_remote + 5 > index_me && _client.id != player[i].id)
                    {
                        player[i].SendPacket(p, player[i].id, ref player[i], false, false);
                    }
                }
            }
            _client.SendPacket(p, _client.id, ref _client, false, false);
        }