Solved Prohibit Fortune 3 on Diamond Pickaxe

Discussion in 'Plugin Development' started by srspore, May 29, 2016.

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

    srspore

    I'm trying to make it so players can only have fortune three on a gold pickaxe. I've been able to use the "EnchantItemEvent" to stop fortune picks from being created via an enchantment table, but I don't know how to cancel them from being crafted with an anvil. Any ideas? Thank!
     
  2. Offline

    Lordloss

    The only way i know is using the InventoryClickEvent, check if it is an anvil menu, check if it is the output slot. Look if the new stack has the unwanted enchantment, and cancel the event.
     
  3. Offline

    I Al Istannen

    @srspore @Lordloss
    I don't know when (maybe 1.9) but this event (PrepareAnvilEvent) was introduced. Sounds promising, though I have never tried it.
     
  4. Offline

    srspore

    Alright, I'll try that. Thank you both
     
  5. Offline

    Lordloss

    @I Al Istannen Yes it sounds promising, but you cant cancel this event. You could remove the enchantment of the outcoming item though, but this would just waste the enchanted book + exp.
     
  6. Offline

    I Al Istannen

    @Lordloss
    Thanks for that! I didn't check, hence the "sounds" :p Then I don't see another way than what you suggested.

    Since the thread is set to "solved", maybe the op (@srspore ) could shed some light at what he ended up doing!
     
Thread Status:
Not open for further replies.

Share This Page