encodeToNbtElement

inline fun <T> Nbt.encodeToNbtElement(value: T): Tag(source)

Encodes the given value to an Tag. If the given value of the type T can be represented by a primitive NbtElement, such an element will be the result of this function. Otherwise, an net.minecraft.nbt.CompoundTag will be created.