mirror of
https://github.com/PaperMC/Paper.git
synced 2025-08-01 20:52:12 -07:00
Properly check if a loot table exists (#10190)
This commit is contained in:
@@ -94,10 +94,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||||||
- return new CraftLootTable(key, registry.getLootTable(CraftNamespacedKey.toMinecraft(key)));
|
- return new CraftLootTable(key, registry.getLootTable(CraftNamespacedKey.toMinecraft(key)));
|
||||||
+ // Paper start - honor method contract
|
+ // Paper start - honor method contract
|
||||||
+ final ResourceLocation lootTableKey = CraftNamespacedKey.toMinecraft(key);
|
+ final ResourceLocation lootTableKey = CraftNamespacedKey.toMinecraft(key);
|
||||||
+ if (registry.getLootTable(lootTableKey) == net.minecraft.world.level.storage.loot.LootTable.EMPTY) {
|
+ final Optional<net.minecraft.world.level.storage.loot.LootTable> table = registry.getElementOptional(net.minecraft.world.level.storage.loot.LootDataType.TABLE, lootTableKey);
|
||||||
+ return null;
|
+ return table.map(lootTable -> new CraftLootTable(key, lootTable)).orElse(null);
|
||||||
+ }
|
|
||||||
+ return new CraftLootTable(key, registry.getLootTable(lootTableKey));
|
|
||||||
+ // Paper end
|
+ // Paper end
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user