AnvilCombineCheck

Discussion in 'Plugin Requests' started by madtomic, Mar 19, 2020.

  1. Offline

    madtomic

    Plugin category: Mechanical

    Minecraft version: 1.12.2

    Suggested name:
    AnvilCombineCheck

    What I want: I would like a plugin that would make sure that no two different types of enchantment is able to be combine into the same enchanted book.

    Example:

    Enchanted book with Protection I, cannot be combine with Enchanted Book that has Sharpness I

    This is same the other way around. Similar enchanting checking system when an piece of armor, tool or weapon is put into anvil or enchantment table.

    It will detect which is type of enchantment in the enchanted book is applicable for that item.

    Commands: No commands

    Permissions
    :
    No permissions

    Thank you for reading.
     
    Last edited: Mar 20, 2020
  2. Offline

    MegaCrafter10

  3. Offline

    madtomic

    So, anyone interested? :)
     
  4. Offline

    CraftCreeper6

  5. Offline

    madtomic

    @CraftCreeper6
    It wasn't there when I send the message. I think, the page is not refreshed.

    @MegaCrafter10
    Thank you for trying to do this.

    EDIT: https://minecraft.gamepedia.com/Anvil/Mechanics
    The anvil mechanics will explain better.

    Code:
    If the target does not have the enchantment, it gains all levels of that enchantment, unless it already has an incompatible enchantment. Enchantments are incompatible if both are in one of the following groups:
    
        Sword: Sharpness, Smite, and Bane of Arthropods
        Tool: Fortune and Silk Touch (as of Java version 1.12.2 you can combine these; the sacrifice item's enchantment is lost)
        Armor: Protection, Fire Protection, Blast Protection, Projectile Protection
        Boots: Depth Strider and Frost Walker
        Bow: Infinity and Mending
        Crossbow: Multishot and Piercing
    Don't worry about Crossbow as 1.12.2 don't have this.

    https://minecraft.gamepedia.com/Enchanting

    Using this as a guide, Enchanted Book with Knockback and Looting should combine as both enchantment are applicable on a sword.

    But if trying to combine with Infinity with either Knockback or Looting. They aren't compatible as one enchantment will not be added based on which type of item is used to add the enchantment to.

    For example, if adding Knockable + Infinity to a bow. Only Bow would get the Infinity but if adding to a Sword, it would only get the Knockable as Infinity is not applicable to Swords.

    I hope you understand what I need. I think the only way to detect this is to use Itemstack item1 and treated as if it is the Primary or Secondary Item and use that to check to see if the Itemstack item2 enchantment is compatible with the item1.

    The request is to not allow players make enchanted book that don't make sense if you were to add all the enchantments on an item.

    To sums it all up. Different group of enchantments should not be on the same enchanted book.
     
    Last edited: Mar 21, 2020
  6. Offline

    MegaCrafter10

  7. Offline

    madtomic

    @MegaCrafter10

    Excellent, this is working as intended.

    Could you use anvil result event to cancel the bad combines so it may improve this feature a bit more than having to click on and get the error message. I think, simply null the anvil result would greatly improve this and thus remove the need of the error message.
     
  8. Offline

    MegaCrafter10

    I made this last modification: https://github.com/MegaCrafter10/AnvilCombineChecker/releases/tag/3.0 but there is a visual bug where the result item is set to air only when you click on it so I recommend using the release with the error message. The source code is available on Github along with all the releases so feel free to edit the code and recompile it if something is not to your liking.
     
  9. Offline

    madtomic

    @MegaCrafter10

    Thank you so much for all your help! As for refreshing the anvil result item.

    I was gonna suggest perhaps using getScheduler().runTask() using InventoryClickEvent() to start the task.

    Anyway, I understand if you don't want to make any more modifications but thank you for all your effort.

    EDIT: There is the bug issue with enchantment exp used up when InventoryClickEvent is executed when the group aren't compatible. Refunding this exp used up would be nice.


    Regards,
    madtomic
     
    Last edited: Mar 22, 2020
  10. Offline

    madtomic

    Anyone can finish the work on this by adding the fix to refund the exp used when an incompatible repair is executed?

    The author had released the source here: https://github.com/MegaCrafter10/AnvilCombineChecker/releases/tag/3.0

    Add config.yml
    refundExp: true/false
    errorMSG: "&cSome of your enchantments are not compatible with each other, experiences used are refunded."

    Thanks
     

Share This Page