public override bool Equals(object obj)
        {
            if (!(obj is CompoundTag))
            {
                return(false);
            }
            CompoundTag tag = (CompoundTag)obj;

            if (this.Name != tag.Name)
            {
                return(false);
            }
            if (this.tags.Count != tag.tags.Count)
            {
                return(false);
            }
            foreach (string key in this.tags.Keys)
            {
                if (!tag.tags.ContainsKey(key))
                {
                    return(false);
                }
                if (!this.tags[key].Equals(tag.tags[key]))
                {
                    return(false);
                }
            }
            return(true);
        }
        internal override void Read(NBTStream stream)
        {
            this.ListTagType = (NBTTagType)stream.ReadByte();
            int len = stream.ReadInt();

            for (int i = 0; i < len; ++i)
            {
                Tag tag = null;
                switch (this.ListTagType)
                {
                case NBTTagType.BYTE:
                    tag = new ByteTag(0);
                    break;

                case NBTTagType.SHORT:
                    tag = new ShortTag(0);
                    break;

                case NBTTagType.INT:
                    tag = new IntTag(0);
                    break;

                case NBTTagType.LONG:
                    tag = new LongTag(0);
                    break;

                case NBTTagType.FLOAT:
                    tag = new FloatTag(0);
                    break;

                case NBTTagType.DOUBLE:
                    tag = new DoubleTag(0);
                    break;

                case NBTTagType.BYTE_ARRAY:
                    tag = new ByteArrayTag(new byte[0]);
                    break;

                case NBTTagType.STRING:
                    tag = new StringTag("");
                    break;

                case NBTTagType.LIST:
                    tag = new ListTag(NBTTagType.LIST);
                    break;

                case NBTTagType.COMPOUND:
                    tag = new CompoundTag();
                    break;

                case NBTTagType.INT_ARRAY:
                    tag = new IntArrayTag(new int[0]);
                    break;

                case NBTTagType.LONG_ARRAY:
                    tag = new LongArrayTag(new long[0]);
                    break;

                default:
                    throw new NotSupportedException();
                }

                tag.Read(stream);
                this.list.Add(tag);
            }
        }
        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();
                }
            }
        }
 public CompoundTag PutCompound(string name, CompoundTag data)
 {
     data.Name       = name;
     this.tags[name] = data;
     return(this);
 }