void SkipValue() { // Make sure to check for "atValue" before calling this method switch (TagType) { case NbtTagType.Byte: reader.ReadByte(); break; case NbtTagType.Short: reader.ReadInt16(); break; case NbtTagType.Float: case NbtTagType.Int: reader.ReadInt32(); break; case NbtTagType.Double: case NbtTagType.Long: reader.ReadInt64(); break; case NbtTagType.ByteArray: reader.Skip(TagLength); break; case NbtTagType.IntArray: reader.Skip(sizeof(int) * TagLength); break; case NbtTagType.LongArray: reader.Skip(sizeof(long) * TagLength); break; case NbtTagType.String: reader.SkipString(); break; default: throw new InvalidOperationException(NonValueTagError); } atValue = false; valueCache = null; }
void SkipValue() { if (!atValue) { throw new NbtFormatException(NoValueToReadError); } switch (TagType) { case NbtTagType.Byte: reader.ReadByte(); break; case NbtTagType.Short: reader.ReadInt16(); break; case NbtTagType.Float: case NbtTagType.Int: reader.ReadInt32(); break; case NbtTagType.Double: case NbtTagType.Long: reader.ReadInt64(); break; case NbtTagType.ByteArray: reader.Skip(TagLength); break; case NbtTagType.IntArray: reader.Skip(sizeof(int) * TagLength); break; case NbtTagType.String: reader.SkipString(); break; default: throw new InvalidOperationException(NonValueTagError); } atValue = false; valueCache = null; }
internal override void SkipTag(NbtBinaryReader readStream) { int length = readStream.ReadInt32(); if (length < 0) { throw new NbtFormatException("Negative length given in TAG_Int_Array"); } readStream.Skip(length * sizeof(int)); }
internal override bool ReadTag(NbtBinaryReader readStream) { int length = readStream.ReadInt32(); if (length < 0) { throw new NbtFormatException("Negative length given in TAG_Byte_Array"); } if (readStream.Selector != null && !readStream.Selector(this)) { readStream.Skip(length); return(false); } Value = readStream.ReadBytes(length); return(true); }
internal override bool ReadTag(NbtBinaryReader readStream) { int length = readStream.ReadInt32(); if (length < 0) { throw new NbtFormatException("Negative length given in TAG_Int_Array"); } if (readStream.Selector != null && !readStream.Selector(this)) { readStream.Skip(length * sizeof(int)); return(false); } Value = new int[length]; for (int i = 0; i < length; i++) { Value[i] = readStream.ReadInt32(); } return(true); }
internal override void SkipTag(NbtBinaryReader readStream) { int length = readStream.ReadInt32(); if (length < 0) { throw new NbtFormatException("Negative length given in TAG_Int_Array"); } readStream.Skip(length*sizeof(int)); }
internal override bool ReadTag(NbtBinaryReader readStream) { int length = readStream.ReadInt32(); if (length < 0) { throw new NbtFormatException("Negative length given in TAG_Int_Array"); } if (readStream.Selector != null && !readStream.Selector(this)) { readStream.Skip(length*sizeof(int)); return false; } Value = new int[length]; for (int i = 0; i < length; i++) { Value[i] = readStream.ReadInt32(); } return true; }
internal override void SkipTag(NbtBinaryReader readStream) { // read list type, and make sure it's defined ListType = readStream.ReadTagType(); int length = readStream.ReadInt32(); if (length < 0) { throw new NbtFormatException("Negative list size given."); } switch (ListType) { case NbtTagType.Byte: readStream.Skip(length); break; case NbtTagType.Short: readStream.Skip(length * sizeof(short)); break; case NbtTagType.Int: readStream.Skip(length * sizeof(int)); break; case NbtTagType.Long: readStream.Skip(length * sizeof(long)); break; case NbtTagType.Float: readStream.Skip(length * sizeof(float)); break; case NbtTagType.Double: readStream.Skip(length * sizeof(double)); break; default: for (int i = 0; i < length; i++) { switch (listType) { case NbtTagType.ByteArray: new NbtByteArray().SkipTag(readStream); break; case NbtTagType.String: readStream.SkipString(); break; case NbtTagType.List: new NbtList().SkipTag(readStream); break; case NbtTagType.Compound: new NbtCompound().SkipTag(readStream); break; case NbtTagType.IntArray: new NbtIntArray().SkipTag(readStream); break; } } break; } }
internal override bool ReadTag( NbtBinaryReader readStream ) { int length = readStream.ReadInt32(); if( length < 0 ) { throw new NbtFormatException( "Negative length given in TAG_Byte_Array" ); } if( readStream.Selector != null && !readStream.Selector( this ) ) { readStream.Skip( length ); return false; } Value = readStream.ReadBytes( length ); return true; }