public override void ReadPayload(NBTStreamReader reader) { int length = reader.ReadInt(); Value = new int[length]; for (int i = 0; i < length; i++) { Value[i] = reader.ReadInt(); } }
public override void ReadPayload(NBTStreamReader reader) { Clear(); TagType type; string name; while ((type = reader.ReadTagType(true)) != TagType.End) { var tag = reader.ReadTag(type, out name); if (ContainsKey(name)) { throw new InvalidDataException(string.Format( "Multiple occurance of key '{0}' in compound", name)); } this[name] = tag; } }
public override void ReadPayload(NBTStreamReader reader) { Clear(); var type = reader.ReadTagType(); int count = reader.ReadInt(); if ((type == TagType.End) && (Count > 0)) { throw new InvalidDataException("List tag with ListType of 'End' isn't empty"); } _tags.Capacity = count; _listType = ((Count > 0) ? type : default(TagType?)); for (int i = 0; i < count; i++) { var tag = CreateTagFromType(type); tag.ReadPayload(reader); _tags.Add(tag); } }
/// <summary> /// Reads an NBT tag from a stream. /// </summary> /// <param name="stream">The stream to load from.</param> /// <param name="name">Will be set to the name of the root tag.</param> /// <param name="compression">The compression to use, null or default to auto-detect.</param> /// <param name="encoding">The encoding to use for strings. Uses Java's weird MUTF8 encoding by default.</param> /// <param name="endianness">The endianness to use. PC = Big, Pocket Edition = Little.</param> /// <param name="ensureCompound">If true, throws an exception if the root tag isn't a compound.</param> public static TagBase ReadFrom(Stream stream, out string name, NbtCompression compression = null, Encoding encoding = null, Endianness endianness = Endianness.Big, bool ensureCompound = true) { if (stream == null) { throw new ArgumentNullException("stream"); } compression = compression ?? NbtCompression.AutoDetect(stream); encoding = encoding ?? MUTF8Encoding.Instance; using (stream = compression.Decompress(stream)) { var reader = new NBTStreamReader(stream, encoding, endianness); var type = reader.ReadTagType(); if (ensureCompound && (type != TagType.Compound)) { throw new InvalidDataException("Root tag is not a compound"); } return(reader.ReadTag(type, out name)); } }
public override void ReadPayload(NBTStreamReader reader) { Value = reader.ReadLong(); }
public override void ReadPayload(NBTStreamReader reader) { int length = reader.ReadInt(); Value = reader.Read(length); }
/// <summary> /// Reads the payload (data) of this NBT tag. /// </summary> public abstract void ReadPayload(NBTStreamReader reader);