/// <summary> Creates a copy of given NbtString tag. </summary> /// <param name="other"> Tag to copy. May not be <c>null</c>. </param> /// <exception cref="ArgumentNullException"> <paramref name="other"/> is <c>null</c>. </exception> public NbtString(NbtString other) { if (other == null) throw new ArgumentNullException("other"); name = other.name; Value = other.Value; }
internal override bool ReadTag(NbtBinaryReader readStream) { if (readStream.Selector != null && !readStream.Selector(this)) { SkipTag(readStream); return(false); } ListType = readStream.ReadTagType(); int length = readStream.ReadInt32(); if (length < 0) { throw new NbtFormatException("Negative list size given."); } for (int i = 0; i < length; i++) { NbtTag newTag; switch (ListType) { case NbtTagType.Byte: newTag = new NbtByte(); break; case NbtTagType.Short: newTag = new NbtShort(); break; case NbtTagType.Int: newTag = new NbtInt(); break; case NbtTagType.Long: newTag = new NbtLong(); break; case NbtTagType.Float: newTag = new NbtFloat(); break; case NbtTagType.Double: newTag = new NbtDouble(); break; case NbtTagType.ByteArray: newTag = new NbtByteArray(); break; case NbtTagType.String: newTag = new NbtString(); break; case NbtTagType.List: newTag = new NbtList(); break; case NbtTagType.Compound: newTag = new NbtCompound(); break; case NbtTagType.IntArray: newTag = new NbtIntArray(); break; default: // should never happen, since ListType is checked beforehand throw new NbtFormatException("Unsupported tag type found in a list: " + ListType); } newTag.Parent = this; if (newTag.ReadTag(readStream)) { tags.Add(newTag); } } return(true); }