dsls my belovededed

This commit is contained in:
yrsegal@gmail.com 2022-05-24 23:59:00 -04:00
parent 3e0d1f9fe0
commit 5945d6ea70
2 changed files with 4 additions and 4 deletions

View file

@ -429,10 +429,7 @@ class CastingHarness private constructor(
fun serializeToNBT() = NBTBuilder {
TAG_STACK %= list {
for (datum in stack)
+datum.serializeToNBT()
}
TAG_STACK %= stack.serializeToNBT()
TAG_LOCAL %= localIota.serializeToNBT()
TAG_PAREN_COUNT %= parenCount

View file

@ -30,6 +30,7 @@ object NBTBuilder {
inline fun list(vararg elements: Tag): ListTag = ListTag().also { it.addAll(elements) }
inline fun list(elements: Collection<Tag>): ListTag = ListTag().also { it.addAll(elements) }
inline fun <T> list(elements: Collection<T>, mapper: (T) -> Tag): ListTag = ListTag().also { it.addAll(elements.map(mapper)) }
inline fun double(value: Number): DoubleTag = DoubleTag.valueOf(value.toDouble())
inline fun float(value: Number): FloatTag = FloatTag.valueOf(value.toFloat())
@ -97,6 +98,7 @@ value class NbtCompoundBuilder(val tag: CompoundTag) {
inline fun list(vararg elements: Tag): ListTag = ListTag().also { it.addAll(elements) }
inline fun list(elements: Collection<Tag>): ListTag = ListTag().also { it.addAll(elements) }
inline fun <T> list(elements: Collection<T>, mapper: (T) -> Tag): ListTag = ListTag().also { it.addAll(elements.map(mapper)) }
inline fun double(value: Number): DoubleTag = DoubleTag.valueOf(value.toDouble())
inline fun float(value: Number): FloatTag = FloatTag.valueOf(value.toFloat())
@ -170,6 +172,7 @@ value class NbtListBuilder(val tag: ListTag) {
inline fun list(vararg elements: Tag): ListTag = ListTag().also { it.addAll(elements) }
inline fun list(elements: Collection<Tag>): ListTag = ListTag().also { it.addAll(elements) }
inline fun <T> list(elements: Collection<T>, mapper: (T) -> Tag): ListTag = ListTag().also { it.addAll(elements.map(mapper)) }
inline fun double(value: Number): DoubleTag = DoubleTag.valueOf(value.toDouble())
inline fun float(value: Number): FloatTag = FloatTag.valueOf(value.toFloat())