Пример #1
0
            internal override void Read(PrimitiveReader reader, int _)
            {
                var len = reader.ReadInt();

                if (len < 0)
                {
                    throw new NBTException("Negative length.");
                }
                Value = new byte[len];
                reader.ReadFully(Value, 0, Value.Length);
            }
Пример #2
0
        public override void Read(PrimitiveReader reader)
        {
            Type = (TypeEnum)reader.ReadVarint();
            switch (Type)
            {
            case TypeEnum.DisplayedRecipe:
                RecipeId = reader.ReadInt();
                break;

            case TypeEnum.CraftingBookStatus:
                CraftingBookOpen = reader.ReadBool();
                CraftingFilter   = reader.ReadBool();
                break;

            default:
                throw new InvalidPacketException(nameof(Type), Type);
            }
        }
Пример #3
0
            internal override void Read(PrimitiveReader reader, int level)
            {
                level++;
                if (level > MaxNestLevel)
                {
                    ThrowMaxNestLevel();
                }

                var id     = reader.ReadByte();
                var length = reader.ReadInt();

                if (length <= 0)
                {
                    return;
                }

                Value.Capacity = length;
                for (var i = 0; i < length; i++)
                {
                    var tag = CreateTagFromID(id);
                    tag.Read(reader, level);
                    Value.Add(tag);
                }
            }
Пример #4
0
 internal override void Read(PrimitiveReader reader, int _) => Value = reader.ReadInt();