Exemple #1
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;
            }
        }
Exemple #2
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();
 }
        /// <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();
            }
        }
Exemple #4
0
        public void FinishReading()
        {
            using (MemoryStream ms = new MemoryStream(Data))
                using (MinecraftStream stream = new MinecraftStream(ms))
                {
                    byte index = 0;
                    do
                    {
                        index = (byte)stream.ReadByte();
                        if (index == 0xff)
                        {
                            break;
                        }

                        MetadataType  type = (MetadataType)stream.ReadVarInt();
                        MetaDataEntry meta = null;
                        switch (type)
                        {
                        case MetadataType.Byte:
                            meta = new MetadataByte(index, (byte)stream.ReadByte());
                            break;

                        case MetadataType.Varint:
                            meta = new MetadataVarInt(index, stream.ReadVarInt());
                            break;

                        case MetadataType.Float:
                            meta = new MetadataFloat(index, stream.ReadFloat());
                            break;

                        case MetadataType.String:
                            meta = new MetadataString(index, stream.ReadString());
                            break;

                        case MetadataType.Chat:
                            meta = new MetadataChat(index, stream.ReadChatObject());
                            break;

                        case MetadataType.OptChat:
                            var hasData = stream.ReadBool();
                            meta = new MetadataOptChat(index, hasData, hasData ? stream.ReadChatObject() : null);
                            break;

                        case MetadataType.Slot:
                            meta = new MetadataSlot(index, stream.ReadSlot());
                            break;

                        case MetadataType.Boolean:
                            meta = new MetadataBool(index, stream.ReadBool());
                            break;

                        case MetadataType.Rotation:
                            meta = new MetadataRotation(index, new Vector3(stream.ReadFloat(), stream.ReadFloat(), stream.ReadFloat()));
                            break;

                        case MetadataType.Position:
                            meta = new MetadataPosition(index, stream.ReadPosition());
                            break;

                        case MetadataType.OptPosition:
                        {
                            bool hasPosition = stream.ReadBool();

                            meta = new MetadataOptPosition(
                                index, hasPosition, hasPosition ? stream.ReadPosition() : (Vector3?)null);
                        }

                        break;

                        case MetadataType.Direction:
                            meta = new MetadataDirection(index, (API.Utils.Direction)stream.ReadVarInt());                         // stream.ReadVarInt();
                            break;

                        case MetadataType.OptUUID:
                        {
                            var hasUUID = stream.ReadBool();
                            meta = new MetadataOptUUID(index, hasUUID, hasUUID ? new UUID(stream.ReadUuid().ToByteArray()) : null);                        // stream.ReadUuid();
                        }
                        break;

                        case MetadataType.OptBlockID:
                            stream.ReadVarInt();
                            break;

                        case MetadataType.NBT:
                            meta = new MetadataNbt(index, stream.ReadNbtCompound());
                            break;

                        case MetadataType.Particle:
                            break;

                        case MetadataType.VillagerData:
                            meta = new MetadataVillagerData(
                                index, (MetadataVillagerData.VillagerTypes)stream.ReadVarInt(), (MetadataVillagerData.VillagerProfession)stream.ReadVarInt(), (MetadataVillagerData.VillagerLevel)stream.ReadVarInt());
                            break;

                        case MetadataType.OptVarInt:
                            stream.ReadVarInt();
                            break;

                        case MetadataType.Pose:
                            stream.ReadVarInt();
                            break;
                        }

                        if (meta != null)
                        {
                            Entries.Add(meta);
                        }
                    } while (index != 0xff);
                }
        }
        public void FinishReading()
        {
            using (MemoryStream ms = new MemoryStream(Data))
                using (MinecraftStream stream = new MinecraftStream(ms))
                {
                    byte index = 0;
                    do
                    {
                        index = (byte)stream.ReadByte();
                        if (index == 0xff)
                        {
                            break;
                        }

                        MetadataType  type = (MetadataType)stream.ReadVarInt();
                        MetaDataEntry meta = null;
                        switch (type)
                        {
                        case MetadataType.Byte:
                            meta = new MetadataByte(index, (byte)stream.ReadByte());
                            break;

                        case MetadataType.Varint:
                            meta = new MetadataVarInt(index, stream.ReadVarInt());
                            break;

                        case MetadataType.Float:
                            meta = new MetadataFloat(index, stream.ReadFloat());
                            break;

                        case MetadataType.String:
                            meta = new MetadataString(index, stream.ReadString());
                            break;

                        case MetadataType.Chat:
                            meta = new MetadataChat(index, stream.ReadChatObject());
                            break;

                        case MetadataType.OptChat:
                            var hasData = stream.ReadBool();
                            meta = new MetadataOptChat(index, hasData, hasData ? stream.ReadChatObject() : null);
                            break;

                        case MetadataType.Slot:
                            meta = new MetadataSlot(index, stream.ReadSlot());
                            break;

                        case MetadataType.Boolean:
                            meta = new MetadataBool(index, stream.ReadBool());
                            break;

                        case MetadataType.Rotation:
                            stream.ReadFloat();
                            stream.ReadFloat();
                            stream.ReadFloat();
                            break;

                        case MetadataType.Position:
                            stream.ReadPosition();
                            break;

                        case MetadataType.OptPosition:
                            if (stream.ReadBool())
                            {
                                stream.ReadPosition();
                            }
                            break;

                        case MetadataType.Direction:
                            stream.ReadVarInt();
                            break;

                        case MetadataType.OptUUID:
                            if (stream.ReadBool())
                            {
                                stream.ReadUuid();
                            }
                            break;

                        case MetadataType.OptBlockID:
                            stream.ReadVarInt();
                            break;

                        case MetadataType.NBT:
                            stream.ReadNbtCompound();
                            break;

                        case MetadataType.Particle:
                            break;

                        case MetadataType.VillagerData:
                            stream.ReadVarInt();
                            stream.ReadVarInt();
                            stream.ReadVarInt();
                            break;

                        case MetadataType.OptVarInt:
                            stream.ReadVarInt();
                            break;

                        case MetadataType.Pose:
                            stream.ReadVarInt();
                            break;
                        }

                        if (meta != null)
                        {
                            Entries.Add(meta);
                        }
                    } while (index != 0xff);
                }
        }