internal override void ReadTag(NBTStream stream)
        {
            stream.ReadByte();
            string name = stream.ReadString();

            this.Read(stream);
        }
Exemplo n.º 2
0
 internal override void Read(NBTStream stream)
 {
     this.Data = stream.ReadString();
 }
        internal override void Read(NBTStream stream)
        {
            while (stream.Offset != stream.Length)
            {
                NBTTagType type    = (NBTTagType)stream.ReadByte();
                string     tagName = "";
                int        len     = 0;
                switch (type)
                {
                case NBTTagType.END:
                    return;

                case NBTTagType.BYTE:
                    tagName = stream.ReadString();
                    this.PutByte(tagName, stream.ReadByte());
                    break;

                case NBTTagType.SHORT:
                    tagName = stream.ReadString();
                    this.PutShort(tagName, stream.ReadShort());
                    break;

                case NBTTagType.INT:
                    tagName = stream.ReadString();
                    this.PutInt(tagName, stream.ReadInt());
                    break;

                case NBTTagType.LONG:
                    tagName = stream.ReadString();
                    this.PutLong(tagName, stream.ReadLong());
                    break;

                case NBTTagType.FLOAT:
                    tagName = stream.ReadString();
                    this.PutFloat(tagName, stream.ReadFloat());
                    break;

                case NBTTagType.DOUBLE:
                    tagName = stream.ReadString();
                    this.PutDouble(tagName, stream.ReadDouble());
                    break;

                case NBTTagType.BYTE_ARRAY:
                    tagName = stream.ReadString();
                    len     = stream.ReadInt();
                    byte[] b = new byte[len];
                    for (int i = 0; i < len; ++i)
                    {
                        b[i] = stream.ReadByte();
                    }
                    this.PutByteArray(tagName, b);
                    break;

                case NBTTagType.STRING:
                    tagName = stream.ReadString();
                    this.PutString(tagName, stream.ReadString());
                    break;

                case NBTTagType.LIST:
                    tagName = stream.ReadString();
                    ListTag listtag = new ListTag(NBTTagType.BYTE);
                    listtag.Read(stream);
                    listtag.Name = tagName;
                    this.PutList(listtag);
                    break;

                case NBTTagType.COMPOUND:
                    tagName = stream.ReadString();
                    CompoundTag comp = new CompoundTag();
                    comp.Read(stream);
                    this.PutCompound(tagName, comp);
                    break;

                case NBTTagType.INT_ARRAY:
                    tagName = stream.ReadString();
                    len     = stream.ReadInt();
                    int[] n = new int[len];
                    for (int i = 0; i < len; ++i)
                    {
                        n[i] = stream.ReadInt();
                    }
                    this.PutIntArray(tagName, n);
                    break;

                case NBTTagType.LONG_ARRAY:
                    tagName = stream.ReadString();
                    len     = stream.ReadInt();
                    long[] l = new long[len];
                    for (int i = 0; i < len; ++i)
                    {
                        l[i] = stream.ReadLong();
                    }
                    this.PutLongArray(tagName, l);
                    break;

                default:
                    throw new FormatException();
                }
            }
        }