Exemplo n.º 1
0
        internal override void Read(NBTStream stream)
        {
            int len = stream.ReadIntTag();

            this.Data = new int[len];
            for (int i = 0; i < len; i++)
            {
                this.Data[i] = stream.ReadIntTag();
            }
        }
Exemplo n.º 2
0
        internal override void Read(NBTStream stream)
        {
            int len = stream.ReadIntTag();

            this.Data = new byte[len];
            for (int i = 0; i < len; ++i)
            {
                this.Data[i] = stream.ReadByteTag();
            }
        }
Exemplo n.º 3
0
        internal override void Read(NBTStream stream)
        {
            this.ListTagType = (NBTTagType)stream.ReadByteTag();
            for (int i = 0; i < stream.ReadIntTag(); ++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.END);
                    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.Tags.Add(tag);
            }
        }
Exemplo n.º 4
0
        internal override void Read(NBTStream stream)
        {
            while (stream.Position != stream.Length)
            {
                NBTTagType type = (NBTTagType)stream.ReadByteTag();
                String     name = "";
                int        len  = 0;
                switch (type)
                {
                case NBTTagType.END:
                    return;

                case NBTTagType.BYTE:
                    this.SetByte(stream.ReadStringTag(), stream.ReadByteTag());
                    break;

                case NBTTagType.SHORT:
                    this.SetShort(stream.ReadStringTag(), stream.ReadShortTag());
                    break;

                case NBTTagType.INT:
                    this.SetInt(stream.ReadStringTag(), stream.ReadIntTag());
                    break;

                case NBTTagType.LONG:
                    this.SetLong(stream.ReadStringTag(), stream.ReadLongTag());
                    break;

                case NBTTagType.FLOAT:
                    this.SetFloat(stream.ReadStringTag(), stream.ReadFloatTag());
                    break;

                case NBTTagType.DOUBLE:
                    this.SetDouble(stream.ReadStringTag(), stream.ReadDoubleTag());
                    break;

                case NBTTagType.BYTE_ARRAY:
                    name = stream.ReadStringTag();
                    byte[] byteArray = new byte[stream.ReadIntTag()];
                    for (int i = 0; i < len; ++i)
                    {
                        byteArray[i] = stream.ReadByteTag();
                    }
                    this.SetByteArray(name, byteArray);
                    break;

                case NBTTagType.STRING:
                    this.SetString(stream.ReadStringTag(), stream.ReadStringTag());
                    break;

                case NBTTagType.LIST:
                    ListTag list = new ListTag(stream.ReadStringTag(), NBTTagType.END);
                    list.Read(stream);
                    this.SetTag(list);
                    break;

                case NBTTagType.COMPOUND:
                    CompoundTag compound = new CompoundTag(stream.ReadStringTag());
                    compound.Read(stream);
                    this.SetTag(compound);
                    break;

                case NBTTagType.INT_ARRAY:
                    name = stream.ReadStringTag();
                    int[] intArray = new int[stream.ReadIntTag()];
                    for (int i = 0; i < len; ++i)
                    {
                        intArray[i] = stream.ReadIntTag();
                    }
                    this.SetIntArray(name, intArray);
                    break;

                case NBTTagType.LONG_ARRAY:
                    name = stream.ReadStringTag();
                    long[] longArray = new long[stream.ReadIntTag()];
                    for (int i = 0; i < len; ++i)
                    {
                        longArray[i] = stream.ReadLongTag();
                    }
                    this.SetLongArray(stream.ReadStringTag(), longArray);
                    break;

                default:
                    throw new FormatException();
                }
            }
        }
Exemplo n.º 5
0
 internal override void Read(NBTStream stream)
 {
     this.Data = stream.ReadIntTag();
 }