Exemplo n.º 1
0
 public override void Decode(MinecraftStream stream)
 {
     ProtocolVersion = stream.ReadVarInt();
     ServerAddress   = stream.ReadString();
     ServerPort      = stream.ReadUShort();
     NextState       = (ConnectionState)stream.ReadVarInt();
 }
Exemplo n.º 2
0
 /// <inheritdoc />
 public override void Decode(MinecraftStream stream)
 {
     Position   = stream.ReadPosition();
     Block      = stream.ReadVarInt();
     Status     = (DigStatus)stream.ReadVarInt();
     Successful = stream.ReadBool();
 }
Exemplo n.º 3
0
        public override void Decode(MinecraftStream stream)
        {
            EntityId         = stream.ReadInt();
            IsHardcore       = stream.ReadBool();
            Gamemode         = (byte)stream.ReadByte();
            PreviousGamemode = (byte)stream.ReadByte();

            int worldCount = stream.ReadVarInt();

            WorldNames = new string[worldCount];
            for (int i = 0; i < worldCount; i++)
            {
                WorldNames[i] = stream.ReadString();
            }

            DimensionCodec = stream.ReadNbtCompound();

            Dimension = stream.ReadNbtCompound();             //stream.ReadString();
            WorldName = stream.ReadString();

            HashedSeed = stream.ReadLong();
            //Difficulty = (byte) stream.ReadByte();
            stream.ReadByte();
            ViewDistance        = stream.ReadVarInt();
            ReducedDebugInfo    = stream.ReadBool();
            EnableRespawnScreen = stream.ReadBool();
            IsDebug             = stream.ReadBool();
            IsFlat = stream.ReadBool();
        }
Exemplo n.º 4
0
        public override void Decode(MinecraftStream stream)
        {
            ChunkX   = stream.ReadInt();
            ChunkZ   = stream.ReadInt();
            GroundUp = stream.ReadBool();
            //IgnoreOldData = stream.ReadBool();
            PrimaryBitmask = stream.ReadVarInt();

            HeightMaps = stream.ReadNbtCompound();

            if (GroundUp)
            {
                int biomeCount = stream.ReadVarInt();

                int[] biomeIds = new int[biomeCount];
                for (int idx = 0; idx < biomeIds.Length; idx++)
                {
                    biomeIds[idx] = stream.ReadVarInt();
                }

                Biomes = biomeIds;
            }

            int i = stream.ReadVarInt();

            Buffer = new Memory <byte>(new byte[i]);
            stream.Read(Buffer.Span, Buffer.Length);

            int tileEntities = stream.ReadVarInt();

            for (int k = 0; k < tileEntities; k++)
            {
                TileEntities.Add(stream.ReadNbtCompound());
            }
        }
Exemplo n.º 5
0
        public override void Decode(MinecraftStream stream)
        {
            ChunkX         = stream.ReadInt();
            ChunkZ         = stream.ReadInt();
            GroundUp       = stream.ReadBool();
            PrimaryBitmask = stream.ReadVarInt();

            HeightMaps = stream.ReadNbtCompound();

            if (GroundUp)
            {
                int[] biomeIds = new int[1024];
                for (int idx = 0; idx < biomeIds.Length; idx++)
                {
                    biomeIds[idx] = stream.ReadInt();
                }
            }

            int i = stream.ReadVarInt();

            Buffer = new byte[i];
            stream.Read(Buffer, 0, Buffer.Length);

            int tileEntities = stream.ReadVarInt();

            for (int k = 0; k < tileEntities; k++)
            {
                TileEntities.Add(stream.ReadNbtCompound());
            }
        }
Exemplo n.º 6
0
        public override void Decode(MinecraftStream stream)
        {
            EntityId = stream.ReadVarInt();
            int count = stream.ReadInt();

            for (int i = 0; i < count; i++)
            {
                string key   = stream.ReadString();
                double value = stream.ReadDouble();

                int        propCount = stream.ReadVarInt();
                Modifier[] modifiers = new Modifier[propCount];

                for (int y = 0; y < modifiers.Length; y++)
                {
                    UUID         uuid   = new UUID(stream.ReadUuid().ToByteArray());
                    double       amount = stream.ReadDouble();
                    ModifierMode op     = (ModifierMode)stream.ReadByte();

                    modifiers[y] = EntityProperty.Factory.CreateModifier(uuid, amount, op);
                }

                EntityProperty prop = EntityProperty.Factory.Create(key, value, modifiers);

                if (!Properties.ContainsKey(prop.Key))
                {
                    Properties.Add(prop.Key, prop);
                }
            }
        }
Exemplo n.º 7
0
        public override void Decode(MinecraftStream stream)
        {
            Action = (PlayerListAction)stream.ReadVarInt();
            int count = stream.ReadVarInt();

            if (Action == PlayerListAction.AddPlayer)
            {
                ReadAddPlayerEntries(count, stream);
                return;
            }

            if (Action == PlayerListAction.UpdateLatency)
            {
                ReadUpdateLatencyEntries(count, stream);
                return;
            }

            if (Action == PlayerListAction.RemovePlayer)
            {
                RemovePlayerEntries = new RemovePlayerEntry[count];
                for (int i = 0; i < RemovePlayerEntries.Length; i++)
                {
                    var entry = new RemovePlayerEntry();
                    entry.UUID             = stream.ReadUuid();
                    RemovePlayerEntries[i] = entry;
                }
            }

            if (Action == PlayerListAction.UpdateDisplayName)
            {
                ReadUpdateDisplayNameEntries(count, stream);
            }
        }
Exemplo n.º 8
0
 public State ReadFrom(MinecraftStream stream, State state)
 {
     ProtocolVersion = stream.ReadVarInt();
     ServerHostname  = stream.ReadString();
     ServerPort      = stream.Read <ushort>();
     NextState       = (State)stream.ReadVarInt();
     return(NextState);
 }
Exemplo n.º 9
0
        public override void Decode(MinecraftStream stream)
        {
            int sharedSecretLength = stream.ReadVarInt();

            SharedSecret = stream.Read(sharedSecretLength);
            int verifyTokenLength = stream.ReadVarInt();

            VerifyToken = stream.Read(verifyTokenLength);
        }
Exemplo n.º 10
0
 public override void Decode(MinecraftStream stream)
 {
     Locale       = stream.ReadString();
     ViewDistance = (byte)stream.ReadByte();
     ChatMode     = stream.ReadVarInt();
     ChatColors   = stream.ReadBool();
     SkinParts    = (byte)stream.ReadByte();
     MainHand     = stream.ReadVarInt();
 }
Exemplo n.º 11
0
        public State ReadFrom(MinecraftStream stream, State state)
        {
            int sharedSecretLength = stream.ReadVarInt();

            SharedSecret = stream.ReadBytes(sharedSecretLength);
            int verificationTokenLength = stream.ReadVarInt();

            VerificationToken = stream.ReadBytes(verificationTokenLength);
            return(state);
        }
Exemplo n.º 12
0
        public override void Decode(MinecraftStream stream)
        {
            ServerId = stream.ReadString();
            int publicKeyLength = stream.ReadVarInt();

            PublicKey = stream.Read(publicKeyLength);
            int verifyTokenLength = stream.ReadVarInt();

            VerifyToken = stream.Read(verifyTokenLength);
        }
Exemplo n.º 13
0
        public override void Decode(MinecraftStream stream)
        {
            int count = stream.ReadVarInt();

            EntityIds = new int[count];
            for (int i = 0; i < count; i++)
            {
                EntityIds[i] = stream.ReadVarInt();
            }
        }
Exemplo n.º 14
0
        public void Read(MinecraftStream ms)
        {
            var blockCount   = ms.ReadShort();
            var bitsPerBlock = (byte)ms.ReadByte();

            int palleteLength = 0;// = ms.ReadVarInt();

            if (bitsPerBlock <= 4)
            {
                bitsPerBlock = 4;
            }

            if (bitsPerBlock <= 8)
            {
                _bits = bitsPerBlock;

                palleteLength = ms.ReadVarInt();

                Pallette = new IntIdentityHashBiMap(palleteLength);
                Pallette.Add(Air);

                for (int id = 0; id < palleteLength; id++)
                {
                    uint       stateId = (uint)ms.ReadVarInt();
                    BlockState state   = BlockFactory.GetBlockState(stateId);
                    Pallette.Put(state, (uint)id);
                }
            }
            else
            {
                _bits    = (int)Math.Ceiling(Math.Log2(BlockFactory.AllBlockstates.Count));
                Pallette = new DirectPallete();
            }

            int length = ms.ReadVarInt();

            long[] dataArray = new long[length];
            for (int i = 0; i < dataArray.Length; i++)
            {
                dataArray[i] = ms.ReadLong();
            }

            Storage = new FlexibleStorage(_bits, 4096);
            var valueMask = (uint)((1L << _bits) - 1);

            for (int index = 0; index < 4096; index++)
            {
                var state = index / (64 / _bits);
                var data  = dataArray[state];

                var shiftedData = data >> (index % (64 / _bits) * _bits);

                Storage[index] = (uint)(shiftedData & valueMask);
            }
        }
Exemplo n.º 15
0
        public override Packet Read(byte[] data)
        {
            var ms = new MinecraftStream(data);
            var re = new LoginStart()
            {
                ID = ms.ReadVarInt()
            };
            var l = ms.ReadVarInt();

            re.Name = ms.ReadString(l);
            return(re);
        }
Exemplo n.º 16
0
        public void Read(MinecraftStream ms)
        {
            var blockCount   = ms.ReadShort();
            var bitsPerBlock = (byte)ms.ReadByte();

            int palleteLength = 0;// = ms.ReadVarInt();

            if (bitsPerBlock <= 4)
            {
                bitsPerBlock = 4;
            }

            if (bitsPerBlock <= 8)
            {
                _bits = bitsPerBlock;

                palleteLength = ms.ReadVarInt();

                Pallette = new IntIdentityHashBiMap <BlockState>(palleteLength);
                Pallette.Add(Air);

                //else
                //     palleteLength =

                for (int id = 0; id < palleteLength; id++)
                {
                    uint       stateId = (uint)ms.ReadVarInt();
                    BlockState state   = BlockFactory.GetBlockState(stateId);
                    Pallette.Put(state, (uint)id);
                    // idToState.Set(id, state);
                    // stateToId.Set(state, id);
                }
            }
            else
            {
                _bits    = (int)Math.Ceiling(Math.Log2(BlockFactory.AllBlockstates.Count));
                Pallette = new DirectPallete();
            }

            int length = ms.ReadVarInt();

            long[] dataArray = new long[length];
            for (int i = 0; i < dataArray.Length; i++)
            {
                dataArray[i] = ms.ReadLong();
            }

            Storage = new FlexibleStorage(_bits, dataArray);
            //Storage._data = dataArray;
        }
Exemplo n.º 17
0
 public override void Decode(MinecraftStream stream)
 {
     EntityId  = stream.ReadVarInt();
     Uuid      = stream.ReadUuid();
     Type      = stream.ReadVarInt();
     X         = stream.ReadDouble();
     Y         = stream.ReadDouble();
     Z         = stream.ReadDouble();
     Yaw       = (byte)stream.ReadByte();
     Pitch     = (byte)stream.ReadByte();
     HeadPitch = (byte)stream.ReadByte();
     VelocityX = stream.ReadShort();
     VelocityY = stream.ReadShort();
     VelocityZ = stream.ReadShort();
 }
Exemplo n.º 18
0
        /// <inheritdoc />
        public override void Decode(MinecraftStream stream)
        {
            AimWithHead = stream.ReadVarInt() == 1;
            var x = (float)stream.ReadDouble();
            var y = (float)stream.ReadDouble();
            var z = (float)stream.ReadDouble();

            Target   = new Vector3(x, y, z);
            IsEntity = stream.ReadBool();

            if (IsEntity)
            {
                EntityId   = stream.ReadVarInt();
                LookAtEyes = stream.ReadVarInt() == 1;
            }
        }
Exemplo n.º 19
0
 public override void Decode(MinecraftStream stream)
 {
     EntityId = stream.ReadVarInt();
     Yaw      = (sbyte)stream.ReadByte();
     Pitch    = (sbyte)stream.ReadByte();
     OnGround = stream.ReadBool();
 }
Exemplo n.º 20
0
 /// <inheritdoc />
 public override void Decode(MinecraftStream stream)
 {
     Location  = stream.ReadPosition();
     ActionId  = (byte)stream.ReadByte();
     Parameter = (byte)stream.ReadByte();
     BlockType = stream.ReadVarInt();
 }
Exemplo n.º 21
0
        public override void Decode(MinecraftStream stream)
        {
            Channel = stream.ReadString();
            var l = stream.ReadVarInt();

            Data = stream.Read(l);
        }
Exemplo n.º 22
0
        public override void Decode(MinecraftStream stream)
        {
            Action = (ActionEnum)stream.ReadVarInt();
            switch (Action)
            {
            case ActionEnum.SetTitle:
                TitleText = stream.ReadChatObject();
                break;

            case ActionEnum.SetSubTitle:
                SubtitleText = stream.ReadChatObject();
                break;

            case ActionEnum.SetActionBar:
                ActionBarText = stream.ReadChatObject();
                break;

            case ActionEnum.SetTimesAndDisplay:
                FadeIn  = stream.ReadInt();
                Stay    = stream.ReadInt();
                FadeOut = stream.ReadInt();
                break;

            case ActionEnum.Hide:

                break;

            case ActionEnum.Reset:

                break;
            }
        }
Exemplo n.º 23
0
 public override void Decode(MinecraftStream stream)
 {
     EntityId  = stream.ReadVarInt();
     VelocityX = stream.ReadShort();
     VelocityY = stream.ReadShort();
     VelocityZ = stream.ReadShort();
 }
Exemplo n.º 24
0
        public virtual Packet Read(byte[] data)
        {
            var             re = new Packet();
            MinecraftStream ms = new MinecraftStream(data);

            re.ID = ms.ReadVarInt();
            return(re);
        }
Exemplo n.º 25
0
 public override void Decode(MinecraftStream stream)
 {
     EntityId = stream.ReadVarInt();
     DeltaX   = stream.ReadShort();
     DeltaY   = stream.ReadShort();
     DeltaZ   = stream.ReadShort();
     OnGround = stream.ReadBool();
 }
Exemplo n.º 26
0
        public override Packet Read(byte[] data)
        {
            var             re = new Ping();
            MinecraftStream ms = new MinecraftStream(data);

            re.ID      = ms.ReadVarInt();
            re.Payload = ms.ReadLong();
            return(re);
        }
Exemplo n.º 27
0
 public virtual void Read(MinecraftStream stream)
 {
     TeamDisplayName   = stream.ReadChatObject();
     Flags             = (byte)stream.ReadByte();
     NameTagVisibility = stream.ReadString();
     CollisionRule     = stream.ReadString();
     TeamColor         = (TeamsPacket.TeamColor)stream.ReadVarInt();
     TeamPrefix        = stream.ReadChatObject();
     TeamSuffix        = stream.ReadChatObject();
 }
Exemplo n.º 28
0
        public override void Decode(MinecraftStream stream)
        {
            MessageId = stream.ReadVarInt();
            Channel   = stream.ReadString();

            long length = stream.Length - stream.Position;

            byte[] buffer = new byte[length];
            Data = stream.Read(buffer.Length);
        }
Exemplo n.º 29
0
 public override void Decode(MinecraftStream stream)
 {
     X          = stream.ReadDouble();
     Y          = stream.ReadDouble();
     Z          = stream.ReadDouble();
     Yaw        = stream.ReadFloat();
     Pitch      = stream.ReadFloat();
     Flags      = (byte)stream.ReadByte();
     TeleportId = stream.ReadVarInt();
 }
Exemplo n.º 30
0
        public override Packet Read(byte[] data)
        {
            var re = new HandShake();

            MinecraftStream ms = new MinecraftStream(data);

            re.ID = ms.ReadVarInt();

            re.ProtocolVersion = ms.ReadVarInt();

            var l = ms.ReadVarInt();

            re.ServerAddress = ms.ReadString(l);

            re.ServerPort = ms.ReadUShort();

            re.NextState = ms.ReadVarInt();

            return(re);
        }