From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Video Date: Fri, 10 Jun 2022 22:55:01 -0500 Subject: [PATCH] Fixes invalid LootTables causing problems when applied to Minecart entities diff --git a/src/main/java/com/destroystokyo/paper/loottable/PaperContainerEntityLootableInventory.java b/src/main/java/com/destroystokyo/paper/loottable/PaperContainerEntityLootableInventory.java index d4a8c1bbb8fef27ac42bdf27dde495b4c649e6cb..865c61accf211d28be3c82dcf158fec9778b50c1 100644 --- a/src/main/java/com/destroystokyo/paper/loottable/PaperContainerEntityLootableInventory.java +++ b/src/main/java/com/destroystokyo/paper/loottable/PaperContainerEntityLootableInventory.java @@ -17,7 +17,7 @@ public class PaperContainerEntityLootableInventory implements PaperLootableEntit @Override public org.bukkit.loot.LootTable getLootTable() { - return entity.getLootTable() != null && !entity.getLootTable().getPath().isEmpty() ? Bukkit.getLootTable(CraftNamespacedKey.fromMinecraft(entity.getLootTable())) : null; + return entity.getLootTable() != null && !entity.getLootTable().getPath().isEmpty() && entity.getLootTable().toString().length() < 256 ? Bukkit.getLootTable(CraftNamespacedKey.fromMinecraft(entity.getLootTable())) : null; // Scissors - Validate length of loot tables before even trying } @Override diff --git a/src/main/java/com/destroystokyo/paper/loottable/PaperTileEntityLootableInventory.java b/src/main/java/com/destroystokyo/paper/loottable/PaperTileEntityLootableInventory.java index 2ee4ee14ab3345486dad6b24fd9a4fcc6c746b99..c5ac6cda91a81d3075f5c763e30dc009b6be7936 100644 --- a/src/main/java/com/destroystokyo/paper/loottable/PaperTileEntityLootableInventory.java +++ b/src/main/java/com/destroystokyo/paper/loottable/PaperTileEntityLootableInventory.java @@ -15,7 +15,7 @@ public class PaperTileEntityLootableInventory implements PaperLootableBlockInven @Override public org.bukkit.loot.LootTable getLootTable() { - return tileEntityLootable.lootTable != null && !tileEntityLootable.lootTable.getPath().isEmpty() ? Bukkit.getLootTable(CraftNamespacedKey.fromMinecraft(tileEntityLootable.lootTable)) : null; + return tileEntityLootable.lootTable != null && !tileEntityLootable.lootTable.getPath().isEmpty() && tileEntityLootable.lootTable.toString().length() < 256 ? Bukkit.getLootTable(CraftNamespacedKey.fromMinecraft(tileEntityLootable.lootTable)) : null; // Scissors - Validate length of loot tables before even trying } @Override diff --git a/src/main/java/net/minecraft/world/level/block/entity/RandomizableContainerBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/RandomizableContainerBlockEntity.java index d559f93a9a09bac414dd5d58afccad42c127f09b..8ac4e76bf9acf2f99539c4f874ac5c8605573604 100644 --- a/src/main/java/net/minecraft/world/level/block/entity/RandomizableContainerBlockEntity.java +++ b/src/main/java/net/minecraft/world/level/block/entity/RandomizableContainerBlockEntity.java @@ -45,7 +45,7 @@ public abstract class RandomizableContainerBlockEntity extends BaseContainerBloc protected boolean tryLoadLootTable(CompoundTag nbt) { this.lootableData.loadNbt(nbt); // Paper if (nbt.contains("LootTable", 8)) { - this.lootTable = new ResourceLocation(nbt.getString("LootTable")); + this.lootTable = ResourceLocation.tryParse(nbt.getString("LootTable")); // Scissors - Validate loot tables try { org.bukkit.craftbukkit.util.CraftNamespacedKey.fromMinecraft(this.lootTable); } catch (IllegalArgumentException ex) { this.lootTable = null; } // Paper - validate this.lootTableSeed = nbt.getLong("LootTableSeed"); return false; // Paper - always load the items, table may still remain