Ejemplo n.º 1
0
 internal void ReadTag( NbtReader readStream, bool readName )
 {
     if( readName ) {
         Name = readStream.ReadString();
     }
     Value = readStream.ReadDouble();
 }
Ejemplo n.º 2
0
 internal void ReadTag(NbtReader readStream, bool readName)
 {
     if (readName)
     {
         Name = readStream.ReadString();
     }
     Value = readStream.ReadDouble();
 }
Ejemplo n.º 3
0
        internal void ReadTag(NbtReader readStream, bool readName)
        {
            if (readName)
            {
                Name = readStream.ReadString();
            }

            int length = readStream.ReadInt32();

            if (length < 0)
            {
                throw new NbtFormatException("Negative length given in TAG_Byte_Array");
            }

            Value = readStream.ReadBytes(length);
        }
Ejemplo n.º 4
0
        internal void ReadTag(NbtReader readStream, bool readName)
        {
            if (readName)
            {
                Name = readStream.ReadString();
            }

            int length = readStream.ReadInt32();

            if (length < 0)
            {
                throw new NbtFormatException("Negative length given in TAG_Int_Array");
            }

            Value = new int[length];
            for (int i = 0; i < length; i++)
            {
                Value[i] = readStream.ReadInt32();
            }
        }
Ejemplo n.º 5
0
        internal void ReadTag( NbtReader readStream, bool readName )
        {
            if( readName ) {
                Name = readStream.ReadString();
            }

            int length = readStream.ReadInt32();
            if( length < 0 ) {
                throw new NbtFormatException( "Negative length given in TAG_Byte_Array" );
            }

            Value = readStream.ReadBytes( length );
        }
Ejemplo n.º 6
0
        internal void ReadTag( NbtReader readStream, bool readName )
        {
            if( readName ) {
                Name = readStream.ReadString();
            }

            int length = readStream.ReadInt32();
            if( length < 0 ) {
                throw new NbtFormatException( "Negative length given in TAG_Int_Array" );
            }

            Value = new int[length];
            for( int i = 0; i < length; i++ ) {
                Value[i] = readStream.ReadInt32();
            }
        }
Ejemplo n.º 7
0
        internal void ReadTag(NbtReader readStream, bool readName)
        {
            // First read the name of this tag
            if (readName)
            {
                Name = readStream.ReadString();
            }

            tags.Clear();
            bool foundEnd = false;

            while (!foundEnd)
            {
                NbtTagType nextTag = readStream.ReadTagType();
                switch (nextTag)
                {
                case NbtTagType.End:
                    foundEnd = true;
                    break;

                case NbtTagType.Byte:
                    var nextByte = new NbtByte();
                    nextByte.ReadTag(readStream, true);
                    Add(nextByte);
                    //Console.WriteLine( nextByte.ToString() );
                    break;

                case NbtTagType.Short:
                    var nextShort = new NbtShort();
                    nextShort.ReadTag(readStream, true);
                    Add(nextShort);
                    //Console.WriteLine( nextShort.ToString() );
                    break;

                case NbtTagType.Int:
                    var nextInt = new NbtInt();
                    nextInt.ReadTag(readStream, true);
                    Add(nextInt);
                    //Console.WriteLine( nextInt.ToString() );
                    break;

                case NbtTagType.Long:
                    var nextLong = new NbtLong();
                    nextLong.ReadTag(readStream, true);
                    Add(nextLong);
                    //Console.WriteLine( nextLong.ToString() );
                    break;

                case NbtTagType.Float:
                    var nextFloat = new NbtFloat();
                    nextFloat.ReadTag(readStream, true);
                    Add(nextFloat);
                    //Console.WriteLine( nextFloat.ToString() );
                    break;

                case NbtTagType.Double:
                    var nextDouble = new NbtDouble();
                    nextDouble.ReadTag(readStream, true);
                    Add(nextDouble);
                    //Console.WriteLine( nextDouble.ToString() );
                    break;

                case NbtTagType.ByteArray:
                    var nextByteArray = new NbtByteArray();
                    nextByteArray.ReadTag(readStream, true);
                    Add(nextByteArray);
                    //Console.WriteLine( nextByteArray.ToString() );
                    break;

                case NbtTagType.String:
                    var nextString = new NbtString();
                    nextString.ReadTag(readStream, true);
                    Add(nextString);
                    //Console.WriteLine( nextString.ToString() );
                    break;

                case NbtTagType.List:
                    var nextList = new NbtList();
                    nextList.ReadTag(readStream, true);
                    Add(nextList);
                    //Console.WriteLine( nextList.ToString() );
                    break;

                case NbtTagType.Compound:
                    var nextCompound = new NbtCompound();
                    nextCompound.ReadTag(readStream, true);
                    Add(nextCompound);
                    //Console.WriteLine( nextCompound.ToString() );
                    break;

                case NbtTagType.IntArray:
                    var nextIntArray = new NbtIntArray();
                    nextIntArray.ReadTag(readStream, true);
                    Add(nextIntArray);
                    //Console.WriteLine( nextIntArray.ToString() );
                    break;

                default:
                    throw new NbtFormatException("Unsupported tag type found in NBT_Compound: " + nextTag);
                }
            }
        }
Ejemplo n.º 8
0
        internal void ReadTag(NbtReader readStream, bool readName)
        {
            // First read the name of this tag
            if (readName)
            {
                Name = readStream.ReadString();
            }

            // read list type, and make sure it's defined
            ListType = readStream.ReadTagType();
            if (!Enum.IsDefined(typeof(NbtTagType), ListType) || ListType == NbtTagType.Unknown)
            {
                throw new NbtFormatException("Unrecognized TAG_List tag type: " + ListType);
            }

            int length = readStream.ReadInt32();

            if (length < 0)
            {
                throw new NbtFormatException("Negative count given in TAG_List");
            }

            tags.Clear();
            for (int i = 0; i < length; i++)
            {
                switch (ListType)
                {
                case NbtTagType.Byte:
                    var nextByte = new NbtByte();
                    nextByte.ReadTag(readStream, false);
                    tags.Add(nextByte);
                    break;

                case NbtTagType.Short:
                    var nextShort = new NbtShort();
                    nextShort.ReadTag(readStream, false);
                    tags.Add(nextShort);
                    break;

                case NbtTagType.Int:
                    var nextInt = new NbtInt();
                    nextInt.ReadTag(readStream, false);
                    tags.Add(nextInt);
                    break;

                case NbtTagType.Long:
                    var nextLong = new NbtLong();
                    nextLong.ReadTag(readStream, false);
                    tags.Add(nextLong);
                    break;

                case NbtTagType.Float:
                    var nextFloat = new NbtFloat();
                    nextFloat.ReadTag(readStream, false);
                    tags.Add(nextFloat);
                    break;

                case NbtTagType.Double:
                    var nextDouble = new NbtDouble();
                    nextDouble.ReadTag(readStream, false);
                    tags.Add(nextDouble);
                    break;

                case NbtTagType.ByteArray:
                    var nextByteArray = new NbtByteArray();
                    nextByteArray.ReadTag(readStream, false);
                    tags.Add(nextByteArray);
                    break;

                case NbtTagType.String:
                    var nextString = new NbtString();
                    nextString.ReadTag(readStream, false);
                    tags.Add(nextString);
                    break;

                case NbtTagType.List:
                    var nextList = new NbtList();
                    nextList.ReadTag(readStream, false);
                    tags.Add(nextList);
                    break;

                case NbtTagType.Compound:
                    var nextCompound = new NbtCompound();
                    nextCompound.ReadTag(readStream, false);
                    tags.Add(nextCompound);
                    break;

                case NbtTagType.IntArray:
                    var nextIntArray = new NbtIntArray();
                    nextIntArray.ReadTag(readStream, false);
                    tags.Add(nextIntArray);
                    break;
                }
            }
        }