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

AnvilInventory#setRepairCost prevents Result-Item from being taken out


    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • None
    • None
    • 3473-Spigot-ffceeae-2542945
    • Yes

      When using the setRepairCost method of AnvilInventory during the PrepareAnvilEvent, the resulting item cannot be taken out. This happens with all anvil actions. Namely enchanting, repairing and renaming items. Changing the repair cost in a later tick does not resolve the issue.



      Tested on:

      • 3473-Spigot-ffceeae-2542945 (MC: 1.18.2)
      • 3473-Bukkit-2542945 (MC: 1.18.2)
      • ... Versions 1.18.1 and 1.18 left out due to nothing changing
      • 3284a-Spigot-3892929-0ab8487 (MC: 1.17.1)
      • 3284a-Bukkit-0ab8487 (MC: 1.17.1)

      Behaviour persists but differs on:

      • 3170-Spigot-a483d2c-ec116f6 (MC: 1.17)
      • 3170-Bukkit-ec116f6 (MC: 1.17)

      In 1.17, clicking on the result when enchanting still does not work. Clicking on the result item when renaming resets the inventory as if no name was entered yet.

      Behaviour stops on:

      • 3096a-Spigot-9fb885e-af1a232 (MC: 1.16.5)

      In 1.16.5 it doesn't prevent the result item from being taken out but also doesn't set the repair cost to 0. I assume this is a separate issue and not related to this, please correct me if this assumption is wrong.


      Below find a full code snippet to experience this issue yourself:

      import org.bukkit.event.EventHandler;
      import org.bukkit.event.Listener;
      import org.bukkit.event.inventory.PrepareAnvilEvent;
      import org.bukkit.plugin.java.JavaPlugin;
      public final class AnvilCostExample extends JavaPlugin implements Listener {
          public void onEnable() {
              getServer().getPluginManager().registerEvents(this, this);
          public void onPrepareAnvil(PrepareAnvilEvent event) {

      In the attachments is a compiled jar containing the above as a plugin.

            Doc Doc
            Gadse Gadse
            0 Vote for this issue
            3 Start watching this issue