Esempio n. 1
0
        public static NbtBase ReadTag(Stream s)
        {
            NbtBase n = NbtBase.createtag(s);

            n.ReadStream(s);

            return(n);
        }
Esempio n. 2
0
        public NbtBase this[string name]
        {
            get
            {
                if (name.Length == 0)
                {
                    return(null);
                }

                if (name == tagname)
                {
                    return(this);
                }

                NbtBase        found = null;
                List <NbtBase> n;
                List <NbtBase> nn;

                switch (tagtype)
                {
                case NbtType.TAG_compound:
                    n = ((NbtCompound)this).tagvalue;

                    break;

                case NbtType.TAG_list:
                    n = ((NbtList)this).tagvalue;
                    break;

                default:
                    return(null);
                }

                found = n.Find(x => x.tagname == name);
                if (found != null)
                {
                    return(found);
                }

                nn = n.FindAll(x => (x.tagtype == NbtType.TAG_compound || x.tagtype == NbtType.TAG_list));
                foreach (NbtBase x in nn)
                {
                    found = x[name];
                    if (found != null)
                    {
                        return(found);
                    }
                }

                return(null);
            }
        }
Esempio n. 3
0
        public static NbtBase createtag(Stream s)
        {
            NbtType T = NbtReader.TagType(s);

            if (T == NbtType.TAG_end)
            {
                return(new NbtEnd());
            }

            NbtBase n = createtag(T);

            n.tagname = NbtReader.TagString(s);
            return(n);
        }
Esempio n. 4
0
        public static NbtBase createtag(NbtType tag)
        {
            NbtBase n = null;


            switch (tag)
            {
            case NbtType.TAG_byte:
                n = new NbtByte();
                break;

            case NbtType.TAG_short:
                n = new NbtShort();
                break;

            case NbtType.TAG_int:
                n = new NbtInt();
                break;

            case NbtType.TAG_long:
                n = new NbtLong();
                break;

            case NbtType.TAG_string:
                n = new NbtString();
                break;

            case NbtType.TAG_float:
                n = new NbtFloat();
                break;

            case NbtType.TAG_double:
                n = new NbtDouble();
                break;

            case NbtType.TAG_array_byte:
                n = new NbtByteArray();
                break;

            case NbtType.TAG_array_int:
                n = new NbtIntArray();
                break;

            case NbtType.TAG_array_long:
                n = new NbtLongArray();
                break;

            case NbtType.TAG_compound:
                n = new NbtCompound();
                break;

            case NbtType.TAG_list:
                n = new NbtList();
                break;

            default:
                throw new Exception("NBT Tag Invalid");
            }


            n.endpos = 0;

            return(n);
        }
Esempio n. 5
0
 public static void WriteTag(NbtBase Nbt, Stream s)
 {
     TagType(Nbt.tagtype, s);
     TagString(Nbt.tagname, s);
     Nbt.WriteStream(s);
 }