[SPIGOT-6925] Missing Parameter Tool Created: 06/Feb/22  Updated: 20/Feb/22  Resolved: 20/Feb/22

Status: Resolved
Project: Spigot
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Minor
Reporter: John Barnhill Assignee: Doc
Resolution: Fixed Votes: 0
Labels: lootcontext, loottable
Environment:

Windows 10


Version: 1.18.1-R0.1-SNAPSHOT
Guidelines Read: Yes

 Description   

The CraftLootTable type does not have any implementation for setting LootContextParameters.TOOL. I was able to fix this in my own plugin by making an alternate type and adding the following line:

 

setMaybe(builder, LootContextParameters.KILLER_ENTITY, nmsKiller);
// If there is a player killer, damage source should reflect that in case loot tables use that information

//NEW LINE
setMaybe(builder, LootContextParameters.TOOL, (CraftItemStack.asNMSCopy(context.getKiller().getItemInUse())));

setMaybe(builder, LootContextParameters.DAMAGE_SOURCE, DamageSource.playerAttack(nmsKiller)); 

I imagine theres a better way of fixing it, I'm very new to this.

Anyways, this parameter is necessary when generating loot tables with fishing contexts which as far as I can tell does not work in current spigot implementation.



 Comments   
Comment by Doc [ 20/Feb/22 ]

PR Created: https://hub.spigotmc.org/stash/projects/SPIGOT/repos/craftbukkit/pull-requests/1017/overview

Generated at Fri Mar 14 15:03:41 UTC 2025 using Jira 10.3.3#10030003-sha1:d220e3fefc8dfc6d47f522d3b9a20c1455e12b7b.