Solved Impossible to populate a LootTable (Bukkit bug?)

Discussion in 'Plugin Development' started by Tim_M, Feb 9, 2022.

Thread Status:
Not open for further replies.
  1. Offline

    Tim_M

    I just wanted to generate a random item from the fishing loot table. Here is my code:
    Code:
    Random random = new Random();
    LootTable fishingLoot = LootTables.FISHING.getLootTable();
    LootContext.Builder builder = new LootContext.Builder(event.getPlayer().getLocation());
    LootContext context = builder.killer(event.getPlayer()).build();
    List<ItemStack> fishingDrops = (List<ItemStack>) fishingLoot.populateLoot(random, context);
    
    for (ItemStack item:fishingDrops)
        Main.instance.console.sendMessage(item + "");
    
    However the line
    Code:
    List<ItemStack> fishingDrops = (List<ItemStack>) fishingLoot.populateLoot(random, context);
    Throws this error:
    Code:
    java.lang.IllegalArgumentException: Missing required parameters: [<parameter minecraft:tool>
    From looking into the constructor there is no way to pass in this information (in this case the fishing rod used), it seems impossible. Is this a flaw of the Bukkit implementation or am I just stupid? Please help!

    Edit: I solved it by copying the entire LootTable into my code! Love my life!
     
    Last edited: Feb 16, 2022
Thread Status:
Not open for further replies.

Share This Page