public void WriteNBT(NbtWrapper value)
        {
            if (value == null)
            {
                this.WriteBoolean(false);
                return;
            }

            this.WriteBoolean(true);

            // Keep the original byte array if it's unchanged.
            byte[] data = value.Changed
                ? new NbtFile(value.RootTag).SaveToBuffer(NbtCompression.GZip)
                : value.OriginalData;

            this.WriteInt32(data.Length, 15);
            for (int i = 0; i < data.Length; i++)
            {
                this.WriteInt32(data[i], 8);
            }
        }
Beispiel #2
0
        public ItemStack ToItemStack()
        {
            NbtWrapper nbt = null;
            if (this.NBTData != null)
            {
                var nbtFile = new NbtFile();
                nbtFile.LoadFromBuffer(this.NBTData, 0, this.NBTData.Length, NbtCompression.GZip);

                nbt = new NbtWrapper { RootTag = nbtFile.RootTag, OriginalData = this.NBTData };
            }

            return new ItemStack
            {
                ItemId = this.ItemId,
                Size = this.Size,
                Damage = this.Damage,
                NBT = nbt
            };
        }