src/AnvilPacker/Data/NBT.cs
/// <summary> Tries to gets a tag, or the value of a primitive tag. </summary>
/// <returns> Whether the operation was successfull. </returns>
Tries to gets a tag, or the value of a primitive tag.
Tries to gets a tag or the value of a primitive tag .
public bool TryGet<T>(string name, [NotNullWhen(true)] out T? value)
        {
            if (_tags.TryGetValue(name, out NbtTag? tag)) {
                if (typeof(NbtTag).IsAssignableFrom(typeof(T))) {
                    value = (T)(object)tag;
                    return true;
                }
                if (tag is PrimitiveTag prim) {
                    value = prim.Value<T>()!;
                    return true;
                }
            }
            value = default;
            return false;
        }
public bool TryGet < T > ( string name , [ NotNullWhen ( true ) ] out T ? value ) { if ( _tags . TryGetValue ( name , out NbtTag ? tag ) ) { if ( typeof ( NbtTag ) . IsAssignableFrom ( typeof ( T ) ) ) { value = ( T ) ( object ) tag ; return true ; } if ( tag is PrimitiveTag prim ) { value = prim . Value < T > ( ) ! ; return true ; } } value = default ; return false ; }
Tries to gets a tag, or the value of a primitive tag.
Tries to gets a tag or the value of a primitive tag .
Whether the operation was successfull.
Whether the operation was successfull .
name
string
out
[NotNullWhen(true)]