public void ReadFromStream(IPacketCodec content)
 {
     EntityId   = content.ReadVarInt();
     PlayerUuid = content.ReadUuid();
     Position   = content.ReadVector3d();
     Rotation   = content.ReadAngleRotation();
 }
Exemple #2
0
 public void ReadFromStream(IPacketCodec content)
 {
     EntityId = content.ReadVarInt();
     Position = content.ReadVector3d();
     Rotation = content.ReadAngleRotation();
     OnGround = content.ReadBoolean();
 }
Exemple #3
0
 public void ReadFromStream(IPacketCodec content)
 {
     ProtocolVersion = content.ReadVarInt();
     ServerAddress   = content.ReadString();
     ServerPort      = content.ReadUInt16();
     NextState       = content.ReadVarIntEnum <ProtocolState>();
 }
Exemple #4
0
        public void ReadFromStream(IPacketCodec rawCodec, PacketBoundTo boundTo, Func <int> compressThresholdCallback, Func <ProtocolState> stateCallback)
        {
            BoundTo = boundTo;
            State   = stateCallback();
            var length = rawCodec.ReadVarInt(); // Length of Packet ID + Data

            PacketLength = length;
            var threshold = compressThresholdCallback();
            int dataLength;

            using var recvStream = new MemoryStream(); //no extra bytes read
            rawCodec.CopyTo(recvStream, length);
            var recvCodec = rawCodec.Clone(recvStream);

            recvStream.Position = 0;
            if (threshold == 0 || (dataLength = recvCodec.ReadVarInt()) < threshold)
            {
                DataLength = length;
                recvCodec.CopyTo(BaseStream, length);
                BaseStream.Position = 0;
                PacketId            = Content.ReadVarInt();
                return;
            }
            DataLength = dataLength;
            using var compressedStream = new InflaterInputStream(recvStream)
                  {
                      IsStreamOwner = false
                  };
            rawCodec.Clone(compressedStream).CopyTo(BaseStream, dataLength);
            BaseStream.Position = 0;
            PacketId            = Content.ReadVarInt();
        }
Exemple #5
0
 public void ReadFromStream(IPacketCodec content)
 {
     EntityId            = content.ReadInt32();
     IsHardcore          = content.ReadBoolean();
     Gamemode            = content.ReadEnum <Gamemode>();
     PreviousGamemode    = content.ReadEnum <Gamemode>();
     WorldCount          = content.ReadVarInt();
     WorldNames          = content.ReadIdentifiers(WorldCount);
     DimensionCodec      = content.ReadNbtTag <NbtCompound>();
     Dimension           = content.ReadNbtTag <NbtCompound>();
     WorldName           = content.ReadString();
     HashedSeed          = content.ReadInt64();
     MaxPlayers          = content.ReadVarInt();
     ViewDistance        = content.ReadVarInt();
     ReducedDebugInfo    = content.ReadBoolean();
     EnableRespawnScreen = content.ReadBoolean();
     IsDebug             = content.ReadBoolean();
     IsFlat = content.ReadBoolean();
 }
Exemple #6
0
        public void ReadFromStream(IPacketCodec content)
        {
            EntityId = content.ReadVarInt();
            var delta = new Vector3d {
                X = content.ReadInt16(), Y = content.ReadInt16(), Z = content.ReadInt16()
            };

            delta   *= 0.000244140625 /* 1/4096 */;
            Delta    = delta;
            OnGround = content.ReadBoolean();
        }
        public void ReadFromStream(IPacketCodec content)
        {
            Position = content.ReadVector3d();
            Rotation = content.ReadRotation();
            var flags = content.ReadSByte();

            XKind           = (CoordKind)(flags & 0x01);
            YKind           = (CoordKind)(flags >> 1 & 0x01);
            ZKind           = (CoordKind)(flags >> 2 & 0x01);
            YRotKind        = (CoordKind)(flags >> 3 & 0x01);
            XRotKind        = (CoordKind)(flags >> 4 & 0x01);
            TeleportId      = content.ReadVarInt();
            DismountVehicle = content.ReadBoolean();
        }
 public void ReadFromStream(IPacketCodec content)
 {
     EntityId = content.ReadVarInt();
     Type     = content.ReadVarIntEnum <InteractType>();
     if (Type == InteractType.InteractAt)
     {
         Target = content.ReadVector3();
     }
     if (Type == InteractType.Interact || Type == InteractType.InteractAt)
     {
         Hand = content.ReadVarIntEnum <Hand>();
     }
     Sneaking = content.ReadBoolean();
 }
 public void ReadFromStream(IPacketCodec content)
 {
     Threshold = content.ReadVarInt();
 }
Exemple #10
0
 public void ReadFromStream(IPacketCodec content)
 {
     Count     = content.ReadVarInt();
     EntityIds = content.ReadVarInts(Count);
 }
 public void ReadFromStream(IPacketCodec content)
 {
     TeleportId = content.ReadVarInt();
 }
Exemple #12
0
 public void ReadFromStream(IPacketCodec content)
 {
     ChunkX = content.ReadVarInt();
     ChunkZ = content.ReadVarInt();
 }