[SPIGOT-6199] LootContext#build() still non-functional Created: 24/Oct/20  Updated: 25/Oct/20

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

Type: Bug Priority: Minor
Reporter: Novalescent Assignee: Unassigned
Resolution: Unresolved Votes: 1
Labels: loot, lootcontext, loottable

Version: CraftBukkit version git-Spigot-57bbdd8-55a78ff (MC: 1.16.3) (Implementing API version 1.16.3-R0.1-SNAPSHOT)
Guidelines Read: Yes

 Description   

After testing the resolved issue SPIGOT-6130 (https://hub.spigotmc.org/jira/projects/SPIGOT/issues/SPIGOT-6130?filter=doneissues ), I can confirm that this fix is not present in the latest versions of Spigot 1.16.3

 

[19:40:57] [Server thread/INFO]: Novalescent issued server command: /questtrigger -747563197
[19:40:57] [Server thread/WARN]: java.lang.IllegalArgumentException: Missing required parameters: [<parameter minecraft:tool>, <parameter minecraft:killer_entity>, <parameter minecraft:this_entity>, <parameter minecraft:last_damage_player>, <parameter minecraft:direct_killer_entity>, <parameter minecraft:explosion_radius>, <parameter minecraft:block_entity>, <parameter minecraft:block_state>, <parameter minecraft:damage_source>]
[19:40:57] [Server thread/WARN]:        at net.minecraft.server.v1_16_R2.LootTableInfo$Builder.build(SourceFile:208)
[19:40:57] [Server thread/WARN]:        at org.bukkit.craftbukkit.v1_16_R2.CraftLootTable.convertContext(CraftLootTable.java:115)
[19:40:57] [Server thread/WARN]:        at org.bukkit.craftbukkit.v1_16_R2.CraftLootTable.populateLoot(CraftLootTable.java:44)
[19:40:57] [Server thread/WARN]:        at com.playmonumenta.scriptedquests.utils.InventoryUtils.getLootTableContents(InventoryUtils.java:88)
[19:40:57] [Server thread/WARN]:        at com.playmonumenta.scriptedquests.quests.components.actions.ActionGiveReward$RewardMenu.openMenu(ActionGiveReward.java:65)
[19:40:57] [Server thread/WARN]:        at com.playmonumenta.scriptedquests.quests.components.actions.ActionGiveReward.doAction(ActionGiveReward.java:339)
[19:40:57] [Server thread/WARN]:        at com.playmonumenta.scriptedquests.quests.components.QuestActions.doActions(QuestActions.java:122)
[19:40:57] [Server thread/WARN]:        at com.playmonumenta.scriptedquests.quests.components.actions.dialog.DialogClickableTextEntry$PlayerClickableTextEntry.doActionsIfConditionsMatch(DialogClickableTextEntry.java:48)
[19:40:57] [Server thread/WARN]:        at com.playmonumenta.scriptedquests.commands.QuestTrigger.onCommand(QuestTrigger.java:71)
[19:40:57] [Server thread/WARN]:        at org.bukkit.command.PluginCommand.execute(PluginCommand.java:45)
[19:40:57] [Server thread/WARN]:        at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:149)
[19:40:57] [Server thread/WARN]:        at org.bukkit.craftbukkit.v1_16_R2.CraftServer.dispatchCommand(CraftServer.java:758)
[19:40:57] [Server thread/WARN]:        at net.minecraft.server.v1_16_R2.PlayerConnection.handleCommand(PlayerConnection.java:1697)
[19:40:57] [Server thread/WARN]:        at net.minecraft.server.v1_16_R2.PlayerConnection.a(PlayerConnection.java:1540)
[19:40:57] [Server thread/WARN]:        at net.minecraft.server.v1_16_R2.PacketPlayInChat.a(PacketPlayInChat.java:47)
[19:40:57] [Server thread/WARN]:        at net.minecraft.server.v1_16_R2.PacketPlayInChat.a(PacketPlayInChat.java:1)
[19:40:57] [Server thread/WARN]:        at net.minecraft.server.v1_16_R2.PlayerConnectionUtils.lambda$0(PlayerConnectionUtils.java:19)
[19:40:57] [Server thread/WARN]:        at net.minecraft.server.v1_16_R2.TickTask.run(SourceFile:18)
[19:40:57] [Server thread/WARN]:        at net.minecraft.server.v1_16_R2.IAsyncTaskHandler.executeTask(SourceFile:144)
[19:40:57] [Server thread/WARN]:        at net.minecraft.server.v1_16_R2.IAsyncTaskHandlerReentrant.executeTask(SourceFile:23)
[19:40:57] [Server thread/WARN]:        at net.minecraft.server.v1_16_R2.IAsyncTaskHandler.executeNext(SourceFile:118)
[19:40:57] [Server thread/WARN]:        at net.minecraft.server.v1_16_R2.MinecraftServer.ba(MinecraftServer.java:941)
[19:40:57] [Server thread/WARN]:        at net.minecraft.server.v1_16_R2.MinecraftServer.executeNext(MinecraftServer.java:934)
[19:40:57] [Server thread/WARN]:        at net.minecraft.server.v1_16_R2.IAsyncTaskHandler.awaitTasks(SourceFile:127)
[19:40:57] [Server thread/WARN]:        at net.minecraft.server.v1_16_R2.MinecraftServer.sleepForTick(MinecraftServer.java:918)
[19:40:57] [Server thread/WARN]:        at net.minecraft.server.v1_16_R2.MinecraftServer.w(MinecraftServer.java:850)
[19:40:57] [Server thread/WARN]:        at net.minecraft.server.v1_16_R2.MinecraftServer.lambda$0(MinecraftServer.java:164)
[19:40:57] [Server thread/WARN]:        at java.lang.Thread.run(Unknown Source)
>version
[19:41:15] [Server thread/INFO]: This server is running CraftBukkit version git-Spigot-57bbdd8-55a78ff (MC: 1.16.3) (Implementing API version 1.16.3-R0.1-SNAPSHOT)
[19:41:15] [Server thread/INFO]: You are running the latest version

 

To reproduce:

  1. Create a Minecraft Datapack with a loot table. You can generate a loot table here: https://amaury.carrade.eu/minecraft/loot_tables
  2. Get the path of the loot table in the datapack, and use the following code to attempt to build the LootTable by inputting the path in the namespace variable
Player player;

String namespace = "datapack:loot_table/goes/here";
String[] split = namespace.split(":");
LootTable table = Bukkit.getLootTable(new NamespacedKey(split[0], split[1]));
Collection<ItemStack> items = table.populateLoot(new Random(), new LootContext.Builder(player.getLocation()).build());
  1. If successful, the last line should error out, unable to build the loot context.

When able to, please take another look into this ASAP. Me and my team desperately need a fix for this, as we are unable to update versions without fear of our loot tables breaking because of it.



 Comments   
Comment by Novalescent [ 25/Oct/20 ]

The following code causes the IllegalArgumentException to occur:

 

 

NamespacedKey lootNamespace = getNamespacedKey(lootPath);
LootContext lootContext = new LootContext.Builder(player.getLocation())
   .luck(0)
   .lootingModifier(0)
   .killer(player)
   .lootedEntity(null)
   .build();

 

and

 

NamespacedKey lootNamespace = getNamespacedKey(lootPath);
LootContext lootContext = new LootContext.Builder(player.getLocation()).build();

We're getting the loottables via our own Datapacks, which look similar to this:

 

{
    "pools": [
        {
            "rolls": 1,
            "bonus_rolls": {
                "min": 1,
                "max": 2
            },
            "entries": [
                {
                    "type": "loot_table",
                    "weight": 1,
                    "name": "rpg:misc/lifeflower_chances_loottable"
                }
            ]
        },
        {
            "rolls": 1,
            "entries": [
                {
                    "type": "item",
                    "weight": 1,
                    "name": "minecraft:stone",
                    "conditions": [
                        {
                            "condition": "random_chance",
                            "chance": 0.05
                        }
                    ],
                    "functions": [
                        {
                            "function": "set_nbt",
                            "tag": "{lootName:\"Strange Wildflower\"}"
                        }
                    ]
                }
            ]
        }
    ]
}

Note that it isn't whenever we use the context to get the loot from the loottable, but rather when we try to build the LootContext.

 

Comment by md_5 [ 24/Oct/20 ]

Also it would be helpful if you included the specific loot tables, I tested various builtin contexts after fixing SPIGOT-6175 and they worked fine

Comment by md_5 [ 24/Oct/20 ]

>When able to, please take another look into this ASAP. Me and my team desperately need a fix for this, as we are unable to update versions without fear of our loot tables breaking because of it.

Your team is also free to fix the issue and open a pull request

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