i would like to introduce you to saveShared
This commit is contained in:
parent
e82d7b74a7
commit
e373512a61
@ -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<out String> = 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)
|
||||
|
Loading…
Reference in New Issue
Block a user