mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-19 15:33:19 +01:00
Properly check if a loot table exists (#10190)
This commit is contained in:
parent
adf45d523a
commit
cc0082f248
1 changed files with 2 additions and 4 deletions
|
@ -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
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue