// get the next long array, prefixed by array length (signed int, 4 bytes) public static NbtLongArray ParseNbtLongArray(NbtByteReader reader, bool parseName = true) { NbtLongArray longArray = new NbtLongArray(parseName ? ParseString(reader) : ""); int arrayLength = reader.ReadInt(); for (int i = 0; i < arrayLength; i++) { longArray.Value.Add(reader.ReadLong()); } return(longArray); }
// get the next value prefixed by tag type (1 byte) and name length (unsigned short, 2 bytes) public static NbtTag ParseNextValueType(NbtByteReader reader) { TagType nextTagType = reader.ReadTagType(); switch (nextTagType) { case TagType.Byte: return(new NbtByte(ParseString(reader), reader.ReadSByte())); case TagType.Short: return(new NbtShort(ParseString(reader), reader.ReadShort())); case TagType.Int: return(new NbtInt(ParseString(reader), reader.ReadInt())); case TagType.Long: return(new NbtLong(ParseString(reader), reader.ReadLong())); case TagType.Float: return(new NbtFloat(ParseString(reader), reader.ReadFloat())); case TagType.Double: return(new NbtDouble(ParseString(reader), reader.ReadDouble())); case TagType.ByteArray: return(ParseNbtByteArray(reader)); case TagType.String: return(new NbtString(ParseString(reader), ParseString(reader))); case TagType.List: return(ParseNbtList(reader)); case TagType.Compound: return(ParseNbtCompound(reader)); case TagType.IntArray: return(ParseNbtIntArray(reader)); case TagType.LongArray: return(ParseNbtLongArray(reader)); default: throw new Exception("Should never get here."); } }