Make lootTable decoding not throw an exception when meeting unexpected data

This commit is contained in:
DBotThePony 2025-03-06 16:13:24 +07:00
parent bc109e8020
commit c40f9a2c57
Signed by: DBot
GPG Key ID: DCC23B5715498507

View File

@ -103,7 +103,7 @@ class CargoCrateBlockEntity(
super.loadAdditional(nbt, registry)
if (nbt.contains(LOOT_TABLE_KEY, Tag.TAG_STRING.toInt())) {
lootTable = ResourceKey.create(Registries.LOOT_TABLE, ResourceLocation.tryParse(nbt.getString(LOOT_TABLE_KEY)))
lootTable = ResourceLocation.tryParse(nbt.getString(LOOT_TABLE_KEY))?.let { ResourceKey.create(Registries.LOOT_TABLE, it) }
lootTableSeed = if (nbt.contains(LOOT_TABLE_SEED_KEY, Tag.TAG_LONG.toInt())) nbt.getLong(LOOT_TABLE_SEED_KEY) else 0L
}
}