Example #1
0
 internal override void Read(NBTStream stream)
 {
     this.Data = stream.ReadFloatTag();
 }
Example #2
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();
                }
            }
        }