Validate ResourceLocation in NBT reading

This commit is contained in:
Nassim Jahnke
2024-01-04 13:49:14 +01:00
parent b37ffd3a00
commit 2506babe8e
11 changed files with 223 additions and 122 deletions

View File

@@ -17,7 +17,8 @@
default void readChestVehicleSaveData(CompoundTag nbt, HolderLookup.Provider registries) {
this.clearItemStacks();
if (nbt.contains("LootTable", 8)) {
this.setContainerLootTable(ResourceKey.create(Registries.LOOT_TABLE, ResourceLocation.parse(nbt.getString("LootTable"))));
- this.setContainerLootTable(ResourceKey.create(Registries.LOOT_TABLE, ResourceLocation.parse(nbt.getString("LootTable"))));
+ this.setContainerLootTable(net.minecraft.Optionull.map(ResourceLocation.tryParse(nbt.getString("LootTable")), rl -> ResourceKey.create(Registries.LOOT_TABLE, rl))); // Paper - Validate ResourceLocation
+ // Paper start - LootTable API
+ if (this.getContainerLootTable() != null) {
+ this.lootableData().loadNbt(nbt);