Uploaded image for project: 'Spigot'
  1. Spigot
  2. SPIGOT-4972

LootTable API does not generate accurate loot

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • None
    • None
    • None
    • git-Spigot-03bd4b0-342194e (MC: 1.14.1)
    • Yes

      Per request, separate issue from SPIGOT-4874. It is possible to use a basic loot table to generate items, however, it is not possible to add any modifiers such as an entity's killer or current state. For example, blazes only drop rods when killed by a player, pigs drop cooked meat when killed with fire aspect, and slimes only drop slimeballs when at smallest size.

      1. This is an API issue, not a vanilla bug.
      2. This was tested on git-Spigot-03bd4b0-342194e (MC: 1.14.1) and git-Spigot-f09662d-9ead700 (MC: 1.13.2)
      3. I have already searched for reports of the same issue.
      4. This bug occurs on Spigot 1.14-1.14.1 and does not affect 1.13.2.
      5. Reproduction steps:
        • Install test plugin
        • Hit any entity to cause it to drop its drops from its loot table
        • Functions normally on 1.13.2, errors out on 1.14.1
      6. This is an API issue.
      7. Jar file included, source: here
      8. This is an API issue. Attempting to use in a plugin that combines mobs to reduce the strain of spawners, etc.
      9. I spent roughly 4 hours total on this, though half of it was probably writing this issue twice.

      I believe the simplest way to fix this would be to modify net.minecraft.server.LootTableInfo.Builder#build to not check if additional unused parameters are provided.

      The correct (and probably easier to maintain) way would be to obtain the net.minecraft.server.LootContextParameterSet for CraftLootTable::convertContext by way of CraftLootTable::getHandle and net.minecraft.server.LootTable::a.
      Maybe an additional constructor so it can fall through to LootContextParameterSets.EMPTY and not break existing plugins?
      Almost feels like the builder should be obtained from a new LootTable method, LootTable::getContextBuilder(Location) or something.

            Unassigned Unassigned
            Jikoo Jikoo
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: