From 660b6d19a7fed4fdbc93ed4895eb772860cfd781 Mon Sep 17 00:00:00 2001 From: md_5 Date: Fri, 9 Aug 2019 20:19:06 +1000 Subject: [PATCH] SPIGOT-5249: Do not add data to empty loot table --- .../bukkit/craftbukkit/CraftLootTable.java | 26 ++++++++++--------- 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/src/main/java/org/bukkit/craftbukkit/CraftLootTable.java b/src/main/java/org/bukkit/craftbukkit/CraftLootTable.java index e736d3adca..0064d93274 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftLootTable.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftLootTable.java @@ -74,20 +74,22 @@ public class CraftLootTable implements org.bukkit.loot.LootTable { WorldServer handle = ((CraftWorld) loc.getWorld()).getHandle(); LootTableInfo.Builder builder = new LootTableInfo.Builder(handle); - // builder.luck(context.getLuck()); + if (getHandle() != LootTable.a) { // PAIL - empty + // builder.luck(context.getLuck()); - if (context.getLootedEntity() != null) { - Entity nmsLootedEntity = ((CraftEntity) context.getLootedEntity()).getHandle(); - builder.set(LootContextParameters.THIS_ENTITY, nmsLootedEntity); - builder.set(LootContextParameters.DAMAGE_SOURCE, DamageSource.GENERIC); - builder.set(LootContextParameters.POSITION, new BlockPosition(nmsLootedEntity)); - } + if (context.getLootedEntity() != null) { + Entity nmsLootedEntity = ((CraftEntity) context.getLootedEntity()).getHandle(); + builder.set(LootContextParameters.THIS_ENTITY, nmsLootedEntity); + builder.set(LootContextParameters.DAMAGE_SOURCE, DamageSource.GENERIC); + builder.set(LootContextParameters.POSITION, new BlockPosition(nmsLootedEntity)); + } - if (context.getKiller() != null) { - EntityHuman nmsKiller = ((CraftHumanEntity) context.getKiller()).getHandle(); - builder.set(LootContextParameters.KILLER_ENTITY, nmsKiller); - // If there is a player killer, damage source should reflect that in case loot tables use that information - builder.set(LootContextParameters.DAMAGE_SOURCE, DamageSource.playerAttack(nmsKiller)); + if (context.getKiller() != null) { + EntityHuman nmsKiller = ((CraftHumanEntity) context.getKiller()).getHandle(); + builder.set(LootContextParameters.KILLER_ENTITY, nmsKiller); + // If there is a player killer, damage source should reflect that in case loot tables use that information + builder.set(LootContextParameters.DAMAGE_SOURCE, DamageSource.playerAttack(nmsKiller)); + } } return builder.build(getHandle().getLootContextParameterSet());