Exemple #1
0
            public NbtTag Deserialize(BinaryReader br, bool requireName)
            {
                string name = null;

                if (requireName)
                {
                    name = br.ReadTagString();
                }

                var elementType = br.ReadTagType();
                var count       = br.ReadInt32().ToggleEndian();

                if (count <= 0)
                {
                    return(new NbtList(elementType, name));
                }

                var elements = new NbtTag[count];

                for (var i = 0; i < count; ++i)
                {
                    elements[i] = NbtTagSerializer.DeserializeTag(br, elementType, false);
                }

                return(new NbtList(elements, name));
            }
Exemple #2
0
            public void Serialize(NbtTag tag, BinaryWriter bw)
            {
                var nbtLong = (NbtLong)tag;

                if (nbtLong.Name != null)
                {
                    bw.WriteTagValue(nbtLong.Name);
                }

                bw.Write(nbtLong.Value.ToggleEndian());
            }
Exemple #3
0
            public void Serialize(NbtTag tag, BinaryWriter bw, bool requireName)
            {
                var nbtShort = (NbtShort)tag;

                if (requireName)
                {
                    bw.WriteTagValue(nbtShort.Name);
                }

                bw.Write(nbtShort.Value.ToggleEndian());
            }
Exemple #4
0
            public void Serialize(NbtTag tag, BinaryWriter bw, bool requireName)
            {
                var nbtByte = (NbtByte)tag;

                if (requireName)
                {
                    bw.WriteTagValue(nbtByte.Name);
                }

                bw.Write(nbtByte.Value);
            }
Exemple #5
0
            public void Serialize(NbtTag tag, BinaryWriter bw)
            {
                var nbtDouble = (NbtDouble)tag;

                if (nbtDouble.Name != null)
                {
                    bw.WriteTagValue(nbtDouble.Name);
                }

                bw.WriteTagValue(nbtDouble.Value);
            }
Exemple #6
0
            public void Serialize(NbtTag tag, BinaryWriter bw)
            {
                var nbtList = (NbtList)tag;

                if (nbtList.Name != null)
                {
                    bw.WriteTagValue(nbtList.Name);
                }

                foreach (var elem in nbtList._childTags)
                {
                    NbtTagSerializer.SerializeTag(elem, bw, false);
                }
            }
            public void Serialize(NbtTag tag, BinaryWriter bw, bool requireName)
            {
                var nbtCompound = (NbtCompound)tag;

                if (requireName)
                {
                    bw.WriteTagValue(nbtCompound.Name);
                }

                foreach (var elem in nbtCompound._childTags)
                {
                    NbtTagSerializer.SerializeTag(elem.Value, bw);
                }

                NbtTagSerializer.SerializeTag(new NbtEnd(), bw);
            }
Exemple #8
0
            public void Serialize(NbtTag tag, BinaryWriter bw, bool requireName)
            {
                var nbtList = (NbtList)tag;

                if (requireName)
                {
                    bw.WriteTagValue(nbtList.Name);
                }

                bw.WriteTagValue(nbtList.ElementType);
                bw.Write(nbtList.Count.ToggleEndian());

                foreach (var elem in nbtList._childTags)
                {
                    NbtTagSerializer.SerializeTag(elem, bw, false, false);
                }
            }
Exemple #9
0
 public void Serialize(NbtTag tag, BinaryWriter bw)
 {
 }
Exemple #10
0
 public void Serialize(NbtTag tag, BinaryWriter bw, bool requireName)
 {
 }