Skip to content

Commit

Permalink
Catch invalid loot table resource location in saved houses
Browse files Browse the repository at this point in the history
(Where are these coming from? not sure... house NBT does
 contain valid resource locations now)
  • Loading branch information
desht committed Oct 27, 2024
1 parent bd13a8f commit ddcd138
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import me.desht.pneumaticcraft.common.registry.ModBlockEntityTypes;
import me.desht.pneumaticcraft.common.registry.ModDataComponents;
import me.desht.pneumaticcraft.common.util.ContainerWrappedItemHandler;
import net.minecraft.ResourceLocationException;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.core.HolderLookup;
Expand Down Expand Up @@ -97,8 +98,14 @@ public void loadAdditional(CompoundTag tag, HolderLookup.Provider provider) {
super.loadAdditional(tag, provider);

if (tag.contains(NBT_LOOT_TABLE, Tag.TAG_STRING)) {
lootTable = ResourceKey.create(Registries.LOOT_TABLE, ResourceLocation.parse(tag.getString(NBT_LOOT_TABLE)));
lootTableSeed = tag.getLong(NBT_LOOT_TABLE_SEED);
try {
lootTable = ResourceKey.create(Registries.LOOT_TABLE, ResourceLocation.parse(tag.getString(NBT_LOOT_TABLE)));
lootTableSeed = tag.getLong(NBT_LOOT_TABLE_SEED);
setChanged();
} catch (ResourceLocationException e) {
lootTable = null;
lootTableSeed = 0L;
}
} else {
inventory.deserializeNBT(provider, tag.getCompound(NBT_ITEMS));
}
Expand Down
Binary file not shown.

0 comments on commit ddcd138

Please sign in to comment.