diff options
author | Jake Potrebic <[email protected]> | 2024-01-27 11:21:18 -0800 |
---|---|---|
committer | GitHub <[email protected]> | 2024-01-27 20:21:18 +0100 |
commit | 3841722fe1ed1cc48c489265967bd39bc2984dc1 (patch) | |
tree | 5b78020ab6bc090afe4f14481e90c76fab32fc93 /patches/server/0008-CB-fixes.patch | |
parent | 0cc3a7ec6be29df36f492153f3d2a10a8515c79d (diff) | |
download | Paper-3841722fe1ed1cc48c489265967bd39bc2984dc1.tar.gz Paper-3841722fe1ed1cc48c489265967bd39bc2984dc1.zip |
Properly check if a loot table exists (#10190)
Diffstat (limited to 'patches/server/0008-CB-fixes.patch')
-rw-r--r-- | patches/server/0008-CB-fixes.patch | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/patches/server/0008-CB-fixes.patch b/patches/server/0008-CB-fixes.patch index c1b80fa115..5807a8e518 100644 --- a/patches/server/0008-CB-fixes.patch +++ b/patches/server/0008-CB-fixes.patch @@ -87,17 +87,15 @@ diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/ja index 5f12fce84e0ec001dc43523753883a098434fcb6..d6a1b9bbf9737ed884ecf4af31e1521f46807405 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java -@@ -2454,7 +2454,13 @@ public final class CraftServer implements Server { +@@ -2454,7 +2454,11 @@ public final class CraftServer implements Server { Preconditions.checkArgument(key != null, "NamespacedKey key cannot be null"); LootDataManager registry = this.getServer().getLootData(); - return new CraftLootTable(key, registry.getLootTable(CraftNamespacedKey.toMinecraft(key))); + // Paper start - honor method contract + final ResourceLocation lootTableKey = CraftNamespacedKey.toMinecraft(key); -+ if (registry.getLootTable(lootTableKey) == net.minecraft.world.level.storage.loot.LootTable.EMPTY) { -+ return null; -+ } -+ return new CraftLootTable(key, registry.getLootTable(lootTableKey)); ++ final Optional<net.minecraft.world.level.storage.loot.LootTable> table = registry.getElementOptional(net.minecraft.world.level.storage.loot.LootDataType.TABLE, lootTableKey); ++ return table.map(lootTable -> new CraftLootTable(key, lootTable)).orElse(null); + // Paper end } |