From 43d2abe7e3ba58fbe430e08dd8eb5db9d0a684a8 Mon Sep 17 00:00:00 2001 From: YuRaNnNzZZ Date: Tue, 4 Mar 2025 23:52:57 +0300 Subject: [PATCH] =?UTF-8?q?=D0=B0=20=D0=B4=D0=B0=D0=B2=D0=B0=D0=B9=D1=82?= =?UTF-8?q?=D0=B5=20=D0=BB=D1=83=D1=82=20=D1=82=D0=B0=D0=B1=D0=BB=D0=B8?= =?UTF-8?q?=D1=86=D1=8B=20=D0=B1=D1=83=D0=B4=D1=83=D1=82=20=D1=80=D0=B0?= =?UTF-8?q?=D0=B1=D0=BE=D1=82=D0=B0=D1=82=D1=8C=20=D0=B2=20=D1=8F=D1=89?= =?UTF-8?q?=D0=B8=D0=BA=D0=B0=D1=85.=20=D1=81=D0=BE=D0=B3=D0=BB=D0=B0?= =?UTF-8?q?=D1=81=D0=BD=D1=8B=3F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../entity/decorative/CargoCrateBlockEntity.kt | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/decorative/CargoCrateBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/decorative/CargoCrateBlockEntity.kt index ec7e9a5ac..7c1cfcbda 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/decorative/CargoCrateBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/decorative/CargoCrateBlockEntity.kt @@ -5,8 +5,6 @@ import net.minecraft.core.BlockPos import net.minecraft.core.HolderLookup import net.minecraft.core.registries.Registries import net.minecraft.nbt.CompoundTag -import net.minecraft.nbt.LongTag -import net.minecraft.nbt.StringTag import net.minecraft.network.chat.Component import net.minecraft.resources.ResourceKey import net.minecraft.resources.ResourceLocation @@ -33,8 +31,6 @@ import ru.dbotthepony.mc.otm.block.entity.MatteryDeviceBlockEntity import ru.dbotthepony.mc.otm.container.MatteryContainer import ru.dbotthepony.mc.otm.container.HandlerFilter import ru.dbotthepony.mc.otm.core.TranslatableComponent -import ru.dbotthepony.mc.otm.core.nbt.map -import ru.dbotthepony.mc.otm.core.nbt.set import ru.dbotthepony.mc.otm.core.otmRandom import ru.dbotthepony.mc.otm.menu.decorative.CargoCrateMenu import ru.dbotthepony.mc.otm.registry.game.MBlockEntities @@ -95,14 +91,20 @@ class CargoCrateBlockEntity( override fun saveLevel(nbt: CompoundTag, registry: HolderLookup.Provider) { super.saveLevel(nbt, registry) - lootTable?.let { nbt[LOOT_TABLE_KEY] = it.toString() } - lootTableSeed?.let { nbt[LOOT_TABLE_SEED_KEY] = it } + + if (lootTable != null) { + nbt.putString(LOOT_TABLE_KEY, lootTable!!.location().toString()) + nbt.putLong(LOOT_TABLE_SEED_KEY, lootTableSeed ?: 0L) + } } override fun loadAdditional(nbt: CompoundTag, registry: HolderLookup.Provider) { super.loadAdditional(nbt, registry) - lootTable = nbt.map(LOOT_TABLE_KEY) { it: StringTag -> ResourceLocation.tryParse(it.asString)?.let { ResourceKey.create(Registries.LOOT_TABLE, it) } } - lootTableSeed = (nbt[LOOT_TABLE_SEED_KEY] as LongTag?)?.asLong + + if (nbt.contains(LOOT_TABLE_KEY, 8)) { + lootTable = ResourceKey.create(Registries.LOOT_TABLE, ResourceLocation.parse(nbt.getString(LOOT_TABLE_KEY))) + lootTableSeed = if (nbt.contains(LOOT_TABLE_SEED_KEY, 4)) nbt.getLong(LOOT_TABLE_SEED_KEY) else 0L + } } fun unpackLootTable(ply: Player? = null) {