Anvil Questions!

  • 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!

  • LOOKING FOR A VERSION OF SKRIPT?

    You can always check out skUnity Downloads for downloads and any other information about Skript!

Status
Not open for further replies.

BrownMee

Active Member
Apr 16, 2018
126
6
18
23
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
 
I used
code_language.skript:
On Anvil Prepare:
    cancel event
You will need sharpsk for that
 
I used
code_language.skript:
On Anvil Prepare:
    cancel event
You will need sharpsk for that
does this disable enchant? I don't want it to disable enchant
[doublepost=1534669527,1534626685][/doublepost]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.
[doublepost=1534740501][/doublepost]BUMP
[doublepost=1534859372][/doublepost]Still need help!
[doublepost=1535274239][/doublepost]Bump
 
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
 
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
Can't find how... I want to disable people use anvil to fix their tool only. But they can still use to enchant
 
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_language.skript:
on inventory click:
    if type of clicked inventory is anvil inventory:
        if index of clicked slot is 2: #If anvil repair event
            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:
                cancel event

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.
 
Last edited:
Status
Not open for further replies.