コード例 #1
0
 public override void Decode(MinecraftStream stream)
 {
     ProtocolVersion = stream.ReadVarInt();
     ServerAddress   = stream.ReadString();
     ServerPort      = stream.ReadUShort();
     NextState       = (ConnectionState)stream.ReadVarInt();
 }
コード例 #2
0
 /// <inheritdoc />
 public override void Decode(MinecraftStream stream)
 {
     Position   = stream.ReadPosition();
     Block      = stream.ReadVarInt();
     Status     = (DigStatus)stream.ReadVarInt();
     Successful = stream.ReadBool();
 }
コード例 #3
0
ファイル: JoinGamePacket.cs プロジェクト: lvyitian1/Alex
        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();
        }
コード例 #4
0
ファイル: ChunkDataPacket.cs プロジェクト: lvyitian1/Alex
        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());
            }
        }
コード例 #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());
            }
        }
コード例 #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);
                }
            }
        }
コード例 #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);
            }
        }
コード例 #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);
 }
コード例 #9
0
        public override void Decode(MinecraftStream stream)
        {
            int sharedSecretLength = stream.ReadVarInt();

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

            VerifyToken = stream.Read(verifyTokenLength);
        }
コード例 #10
0
ファイル: ClientSettings.cs プロジェクト: wqd1019dqw/Alex
 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();
 }
コード例 #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);
        }
コード例 #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);
        }
コード例 #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();
            }
        }
コード例 #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);
            }
        }
コード例 #15
0
ファイル: LoginStart.cs プロジェクト: jwoff78/MyvarCraft
        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);
        }
コード例 #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;
        }
コード例 #17
0
ファイル: SpawnLivingEntity.cs プロジェクト: lvyitian/Alex
 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();
 }
コード例 #18
0
ファイル: FacePlayerPacket.cs プロジェクト: lvyitian1/Alex
        /// <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;
            }
        }
コード例 #19
0
ファイル: EntityLook.cs プロジェクト: wqd1019dqw/Alex
 public override void Decode(MinecraftStream stream)
 {
     EntityId = stream.ReadVarInt();
     Yaw      = (sbyte)stream.ReadByte();
     Pitch    = (sbyte)stream.ReadByte();
     OnGround = stream.ReadBool();
 }
コード例 #20
0
 /// <inheritdoc />
 public override void Decode(MinecraftStream stream)
 {
     Location  = stream.ReadPosition();
     ActionId  = (byte)stream.ReadByte();
     Parameter = (byte)stream.ReadByte();
     BlockType = stream.ReadVarInt();
 }
コード例 #21
0
        public override void Decode(MinecraftStream stream)
        {
            Channel = stream.ReadString();
            var l = stream.ReadVarInt();

            Data = stream.Read(l);
        }
コード例 #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;
            }
        }
コード例 #23
0
ファイル: EntityVelocity.cs プロジェクト: lvyitian/Alex
 public override void Decode(MinecraftStream stream)
 {
     EntityId  = stream.ReadVarInt();
     VelocityX = stream.ReadShort();
     VelocityY = stream.ReadShort();
     VelocityZ = stream.ReadShort();
 }
コード例 #24
0
        public virtual Packet Read(byte[] data)
        {
            var             re = new Packet();
            MinecraftStream ms = new MinecraftStream(data);

            re.ID = ms.ReadVarInt();
            return(re);
        }
コード例 #25
0
ファイル: EntityRelativeMove.cs プロジェクト: lvyitian/Alex
 public override void Decode(MinecraftStream stream)
 {
     EntityId = stream.ReadVarInt();
     DeltaX   = stream.ReadShort();
     DeltaY   = stream.ReadShort();
     DeltaZ   = stream.ReadShort();
     OnGround = stream.ReadBool();
 }
コード例 #26
0
ファイル: Ping.cs プロジェクト: jwoff78/MyvarCraft
        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);
        }
コード例 #27
0
ファイル: TeamsPacket.cs プロジェクト: lvyitian/Alex
 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();
 }
コード例 #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);
        }
コード例 #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();
 }
コード例 #30
0
ファイル: HandShake.cs プロジェクト: jwoff78/MyvarCraft
        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);
        }