src/AnvilPacker/Data/NBT.cs
/// <summary> Sets the value of a tag. </summary>
Sets the value of a tag.
Sets the value of a tag .
public void Set<T>(string name, T value)
        {
            if (value is NbtTag tag) {
                _tags[name] = tag;
                return;
            }
            if (_tags.TryGetValue(name, out tag!) && tag is PrimitiveTag<T> prim) {
                prim.Value = value;
                return;
            }
            _tags[name] = PrimitiveTag.Create(value);
        }
public void Set < T > ( string name , T value ) { if ( value is NbtTag tag ) { _tags [ name ] = tag ; return ; } if ( _tags . TryGetValue ( name , out tag ! ) && tag is PrimitiveTag < T > prim ) { prim . Value = value ; return ; } _tags [ name ] = PrimitiveTag . Create ( value ) ; }
Sets the value of a tag.
Sets the value of a tag .
//try update value of existing tag to avoid allocations
name
string
value
T