public static Tag ReadNamedTag(EndianBinaryReader r, out string name) { byte type = r.ReadByte(); if (type == 0) { name = null; return(new TagEnd()); } name = TagString.Read(r).String; Tag tag = ReadTagType(r, type); return(tag); }
public static Tag ReadTagType(EndianBinaryReader r, byte type) { switch (type) { case 0: return(TagEnd.Read(r)); case 1: return(TagByte.Read(r)); case 2: return(TagShort.Read(r)); case 3: return(TagInt.Read(r)); case 4: return(TagLong.Read(r)); case 5: return(TagFloat.Read(r)); case 6: return(TagDouble.Read(r)); case 7: return(TagByteArray.Read(r)); case 8: return(TagString.Read(r)); case 9: return(TagListReader.Read(r)); case 10: return(TagCompound.Read(r)); case 11: return(TagIntArray.Read(r)); default: throw new NotImplementedException("NBT Tag type: " + type); } }
public static Tag ReadTag(EndianBinaryReader r) { //Console.WriteLine ("Reading tag..."); byte type = r.ReadByte(); //Console.WriteLine ("Read tag " + type); if (type == 0) { return(new TagEnd()); } //string name = TagString.Read(r);//.String; //Only for .dat files //if (name != "") // throw new InvalidDataException (); Tag tag = ReadTagType(r, type); return(tag); }