1. Welcome to skUnity!

    Welcome to skUnity! This is a forum where members of the Skript community can communicate and interact. Skript Resource Creators can post their Resources for all to see and use.

    If you haven't done so already, feel free to join our official Discord server to expand your level of interaction with the comminuty!

    Now, what are you waiting for? Join the community now!

  2. LOOKING FOR A VERSION OF SKRIPT?

    You can always check out our Wiki for downloads and any other information about Skript!

Dismiss Notice
This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Anvil Questions!

Discussion in 'Skript' started by BrownMee, Aug 18, 2018.

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

    BrownMee Active Member

    Joined:
    Apr 16, 2018
    Messages:
    126
    Likes Received:
    6
    Is it possible to disable anvil fixing options? But player can still use anvil for enchantments and others just not anything related to fixing the tools/armour.

    Anyone know if this is possible? Please provide me code if you can. Thanks
     
  2. Dabriel

    Dabriel Member

    Joined:
    Aug 13, 2018
    Messages:
    45
    Likes Received:
    5
    I used
    Code (Skript):
    1. On Anvil Prepare:
    2.     cancel event
    You will need sharpsk for that
     
  3. BrownMee

    BrownMee Active Member

    Joined:
    Apr 16, 2018
    Messages:
    126
    Likes Received:
    6
    does this disable enchant? I don't want it to disable enchant
    --- Double Post Merged, Aug 19, 2018, Original Post Date: Aug 18, 2018 ---
    An on ([item] anvil prepare|prepare [item] anvil) event cannot be cancelled.
    Have SharpSK doesn't work!

    I want to disable fixing but not enchanting.
    --- Double Post Merged, Aug 20, 2018 ---
    BUMP
    --- Double Post Merged, Aug 21, 2018 ---
    Still need help!
    --- Double Post Merged, Aug 26, 2018 ---
    Bump
     
  4. jaylawl

    jaylawl Active Member

    Joined:
    Jan 29, 2017
    Messages:
    173
    Likes Received:
    31
    Have you found a way to detect whether a player is trying to fix OR enchant an item? If yes, i have a solution

    Also please stop bumping so often
     
  5. BrownMee

    BrownMee Active Member

    Joined:
    Apr 16, 2018
    Messages:
    126
    Likes Received:
    6
    Can't find how... I want to disable people use anvil to fix their tool only. But they can still use to enchant
     
  6. Lego_freak1999

    Lego_freak1999 Well-Known Member

    Joined:
    Jan 26, 2017
    Messages:
    664
    Likes Received:
    45
    This would not be the easyist thing only thing what i can think of is canceling and completly add all possibilitys.
     
  7. jaylawl

    jaylawl Active Member

    Joined:
    Jan 29, 2017
    Messages:
    173
    Likes Received:
    31
  8. jjpwn1

    jjpwn1 Member

    Joined:
    Aug 18, 2018
    Messages:
    12
    Likes Received:
    8
    What you can do is compare the durabilities of the two items and the repaired item. If the end repaired item has less damage (or more uses) than either the first item or the second item, then we would know anvil fixing has occurred. Therefore, we would need to find a way to cancel that event.

    Here's my code:
    Code (Skript):
    1.    
    2. on inventory click:
    3.     if type of clicked inventory is anvil inventory:
    4.         if index of clicked slot is 2: #If anvil repair event
    5.             if damage value of slot 2 of clicked inventory is less than damage value of slot 0 of clicked inventory or damage value of slot 1 of clicked inventory: #If the repaired item is less damaged by either the first or second item:
    6.                 cancel event
    7.  
    on inventory click has three purposes:
    • Getting the durability of our items
    • Restricting the function to only work on anvils
    • Canceling the anvil repair event
    If you think about it, an anvil event only makes real meaningful changes to the items when the player has to physically click on slot #2 of the anvil. Therefore, the on inventory click event can be used to detect anvil repairs, because it's specialty is with the individual slots of an anvil inventory.


    A few things to note:
    • You can't use two enchanted tools(swords, weapons, anything with durability and is enchanted) together in an anvil. That is because, while item enchantments are permitted, changes to durability does not. Adding two enchanted tools together will still fix the item. If you do not like this change then please let me know and I'll be happy to adjust it.
    • When you attempt to fix an item, it may seem like as if you lost your exp used for the repair, despite actually not repairing the item at all. Don't worry, the exp levels did not really change. If you relog, you will have notice your exp levels returned back to normal
    Edit: Switched the slotNumber to index of clicked slot, which directly retrieves the slot number.
     
    #8 jjpwn1, Aug 30, 2018
    Last edited: Sep 9, 2018
Thread Status:
Not open for further replies.

Share This Page

Loading...