Solved Enchanted Book Stored Enchants

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

BALTICA

New Member
Jun 7, 2021
7
0
1
51
Code:
            set {_pord} to 70
            set {_item} to player's tool
            set {_meta} to {_item}.getItemMeta()
            set {_ench} to {_meta}.getStoredEnchants()
            if {_ench} = `{Enchantment[minecraft:efficiency, DIG_SPEED]=1}`:

(this is a snippet of my full script)

Is there an alternative way to compare this function with a text, since if {_ench} = `{Enchantment [minecraft: efficiency, DIG_SPEED] = 1}`: it doesn't work for me
I would like to be able to check if the enchantment that the player has in his enchanted book is the one requested.
Excuse my bad English, I speak Spanish
 
You could create a function that shortens it down
Code:
function checkEnchant(item: item, enchant: text) :: boolean:
    set {_meta} to {_item}.getItemMeta()
    set {_ench} to {_meta}.getStoredEnchants()
    if {_ench} = `{Enchantment[minecraft:efficiency, %{_enchant}%]=1}`:
        return true
    else:
        return false
        
command /check:
    trigger:
        if checkEnchant(player's tool, "DIG_SPEED") is true:
            send "has enchant"
 
  • Like
Reactions: BALTICA
Status
Not open for further replies.