예제 #1
0
 /// <inheritdoc />
 public override void Decode(MinecraftStream stream)
 {
     Location  = stream.ReadPosition();
     ActionId  = (byte)stream.ReadByte();
     Parameter = (byte)stream.ReadByte();
     BlockType = stream.ReadVarInt();
 }
예제 #2
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();
        }
예제 #3
0
 public override void Decode(MinecraftStream stream)
 {
     Dimension  = stream.ReadInt();
     Difficulty = (byte)stream.ReadByte();
     Gamemode   = (Gamemode)stream.ReadByte();
     LevelType  = stream.ReadString();
 }
예제 #4
0
 public override void Decode(MinecraftStream stream)
 {
     EntityId = stream.ReadVarInt();
     Yaw      = (sbyte)stream.ReadByte();
     Pitch    = (sbyte)stream.ReadByte();
     OnGround = stream.ReadBool();
 }
예제 #5
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();
 }
예제 #6
0
 public override void Decode(MinecraftStream stream)
 {
     EntityId   = stream.ReadInt();
     Gamemode   = (byte)stream.ReadByte();
     Dimension  = stream.ReadInt();
     Difficulty = (byte)stream.ReadByte();
     stream.ReadByte();
     LevelType        = stream.ReadString();
     ReducedDebugInfo = stream.ReadBool();
 }
예제 #7
0
 public override void Decode(MinecraftStream stream)
 {
     EntityId = stream.ReadVarInt();
     Uuid     = stream.ReadUuid();
     X        = stream.ReadDouble();
     Y        = stream.ReadDouble();
     Z        = stream.ReadDouble();
     Yaw      = (sbyte)stream.ReadByte();
     Pitch    = (sbyte)stream.ReadByte();
     stream.ReadByte();
 }
예제 #8
0
        /// <inheritdoc />
        public override void Decode(MinecraftStream stream)
        {
            ObjectiveName = stream.ReadString();
            Mode          = (ObjectiveMode)stream.ReadByte();

            if (Mode == ObjectiveMode.Create || Mode == ObjectiveMode.UpdateText)
            {
                Value = stream.ReadChatObject();
                Type  = (ObjectiveType)stream.ReadByte();
            }
        }
예제 #9
0
 public override void Decode(MinecraftStream stream)
 {
     Dimension        = stream.ReadNbtCompound();
     WorldName        = stream.ReadString();
     HashedSeed       = stream.ReadLong();
     Gamemode         = (GameMode)stream.ReadByte();
     PreviousGamemode = (GameMode)stream.ReadByte();
     IsDebug          = stream.ReadBool();
     IsFlat           = stream.ReadBool();
     CopyMetadata     = stream.ReadBool();
 }
예제 #10
0
 public override void Decode(MinecraftStream stream)
 {
     EntityId   = stream.ReadInt();
     Gamemode   = (byte)stream.ReadByte();
     Dimension  = stream.ReadInt();
     HashedSeed = stream.ReadLong();
     //Difficulty = (byte) stream.ReadByte();
     stream.ReadByte();
     LevelType           = stream.ReadString();
     ReducedDebugInfo    = stream.ReadBool();
     EnableRespawnScreen = stream.ReadBool();
 }
예제 #11
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();
 }
예제 #12
0
//        public delegate IPacket CreatePacketInstance();

//        private static readonly CreatePacketInstance[] Packets = new CreatePacketInstance[]
//        {
//            () => new HandshakePacket()
//        };

//        public static IPacket ReadPacket(MinecraftStream stream)
//        {
//            byte len = stream.ReadUInt8();
//            byte id = stream.ReadUInt8();
//            Console.WriteLine("Message len " + len + " id " + id);
//            if (Packets[id] == null)
//                throw new InvalidOperationException("Invalid packet ID: 0x" + id.ToString("X2"));
//            var packet = Packets[id]();
//            packet.ReadPacket(stream);
//            return packet;
//        }

        public static int ReadVarInt(MinecraftStream stream)
        {
            ArrayList bytes = new ArrayList();
            int       i;

            do
            {
                i = stream.ReadByte();
                bytes.Add((byte)i);
            } while ((i >> 7) == 1);

            byte[] array = (byte[])bytes.ToArray(typeof(byte));

            if (array.Length == 1)
            {
                return(VariantBitConverter.ToByte(array));
            }
            else if (array.Length == 2)
            {
                return(VariantBitConverter.ToInt16(array));
            }
            else if (array.Length == 3)
            {
                return(VariantBitConverter.ToInt32(array));
            }
            else
            {
                return(0);
            }
        }
예제 #13
0
        /// <inheritdoc />
        public override void Decode(MinecraftStream stream)
        {
            TeamName   = stream.ReadString();
            PacketMode = (Mode)stream.ReadByte();

            switch (PacketMode)
            {
            case Mode.CreateTeam:
                var a = new CreateTeam();
                a.Read(stream);
                Payload = a;
                break;

            case Mode.RemoveTeam:
                break;

            case Mode.UpdateTeam:
                var upd = new UpdateTeam();
                upd.Read(stream);
                Payload = upd;
                break;

            case Mode.AddPlayer:
                var add = new AddPlayers();
                add.Read(stream);
                Payload = add;
                break;

            case Mode.RemovePlayer:
                var remove = new RemovePlayers();
                remove.Read(stream);
                Payload = remove;
                break;
            }
        }
예제 #14
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);
                }
            }
        }
예제 #15
0
 public override void Decode(MinecraftStream stream)
 {
     Message = stream.ReadString();
     if (!ServerBound)
     {
         Position = (byte)stream.ReadByte();
     }
 }
예제 #16
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();
 }
예제 #17
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();
 }
예제 #18
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);
            }
        }
예제 #19
0
        /// <inheritdoc />
        public override void Decode(MinecraftStream stream)
        {
            EntityName    = stream.ReadString();
            Action        = (UpdateScoreAction)stream.ReadByte();
            ObjectiveName = stream.ReadString();

            if (Action == UpdateScoreAction.CreateOrUpdate)
            {
                Value = stream.ReadVarInt();
            }
        }
예제 #20
0
        public override void Decode(MinecraftStream stream)
        {
            ChunkX = stream.ReadInt();
            ChunkZ = stream.ReadInt();

            int recordCount = stream.ReadVarInt();

            Records = new BlockUpdate[recordCount];
            for (int i = 0; i < Records.Length; i++)
            {
                byte horizontalPos = (byte)stream.ReadByte();

                BlockUpdate update = new BlockUpdate();
                update.X       = (horizontalPos >> 4 & 15) + (ChunkX * 16);
                update.Z       = (horizontalPos & 15) + (ChunkZ * 16);
                update.Y       = (byte)stream.ReadByte();
                update.BlockId = stream.ReadVarInt();

                Records[i] = update;
            }
        }
예제 #21
0
        public override void Decode(MinecraftStream stream)
        {
            WindowId = (byte)stream.ReadByte();

            short slotCount = stream.ReadShort();

            Slots = new SlotData[slotCount];

            for (int i = 0; i < Slots.Length; i++)
            {
                Slots[i] = stream.ReadSlot();
            }
        }
예제 #22
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;
        }
예제 #23
0
        public override void Decode(MinecraftStream stream)
        {
            EntityId = stream.ReadVarInt();
            int count = stream.ReadInt();

            for (int i = 0; i < count; i++)
            {
                Property prop  = new Property();
                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();
                    byte   op     = (byte)stream.ReadByte();

                    modifiers[y] = new Modifier()
                    {
                        Amount    = amount,
                        Operation = op,
                        Uuid      = uuid
                    };
                }

                prop.Value     = value;
                prop.Modifiers = modifiers;
                prop.Key       = key;

                if (!Properties.ContainsKey(key))
                {
                    Properties.Add(key, prop);
                }
            }
        }
예제 #24
0
 public override void Decode(MinecraftStream stream)
 {
     WindowId     = (byte)stream.ReadByte();
     ActionNumber = stream.ReadShort();
     Accepted     = stream.ReadBool();
 }
예제 #25
0
 public override void Decode(MinecraftStream stream)
 {
     Flags              = (byte)stream.ReadByte();
     FlyingSpeed        = stream.ReadFloat();
     FiedOfViewModifier = stream.ReadFloat();
 }
예제 #26
0
 public override void Decode(MinecraftStream stream)
 {
     EntityId = stream.ReadVarInt();
     HeadYaw  = (sbyte)stream.ReadByte();
 }
예제 #27
0
 /// <inheritdoc />
 public override void Decode(MinecraftStream stream)
 {
     Position = (ScoreboardPosition)stream.ReadByte();
     Name     = stream.ReadString();
 }
예제 #28
0
 public override void Decode(MinecraftStream stream)
 {
     Difficulty = (byte)stream.ReadByte();
 }
예제 #29
0
 public override void Decode(MinecraftStream stream)
 {
     Slot = (byte)stream.ReadByte();
 }
예제 #30
0
 public override void Decode(MinecraftStream stream)
 {
     WindowId = (byte)stream.ReadByte();
 }