From e373512a61c0ec3212da5ce3917b1375ec6b5897 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Tue, 30 May 2023 09:50:23 +0700 Subject: [PATCH] i would like to introduce you to `saveShared` --- .../mc/otm/data/loot/CopyTileNbtFunction.kt | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/data/loot/CopyTileNbtFunction.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/data/loot/CopyTileNbtFunction.kt index d607e1ec4..4858c7cf3 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/data/loot/CopyTileNbtFunction.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/data/loot/CopyTileNbtFunction.kt @@ -14,6 +14,7 @@ import net.minecraft.world.level.storage.loot.Serializer import net.minecraft.world.level.storage.loot.functions.LootItemFunction import net.minecraft.world.level.storage.loot.functions.LootItemFunctionType import net.minecraft.world.level.storage.loot.parameters.LootContextParams +import ru.dbotthepony.mc.otm.block.entity.MatteryBlockEntity import ru.dbotthepony.mc.otm.core.nbt.set import ru.dbotthepony.mc.otm.core.set import ru.dbotthepony.mc.otm.core.stream @@ -34,7 +35,14 @@ class CopyTileNbtFunction(filter: Stream = Stream.empty()) : LootIte val blockEntity = u.getParamOrNull(LootContextParams.BLOCK_ENTITY) ?: return t val result = t.tagNotNull[BlockItem.BLOCK_ENTITY_TAG] as? CompoundTag - val data = blockEntity.saveWithoutMetadata() + val data: CompoundTag + + if (blockEntity is MatteryBlockEntity) { + data = CompoundTag() + blockEntity.saveShared(data) + } else { + data = blockEntity.saveWithoutMetadata() + } for (k in filter) { data.remove(k)