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.

Solved Enchanted Book Stored Enchants

Discussion in 'Skript' started by BALTICA, Aug 9, 2021.

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

    BALTICA New Member

    Joined:
    Jun 7, 2021
    Messages:
    6
    Likes Received:
    0
    Code (Text):
    1.             set {_pord} to 70
    2.             set {_item} to player's tool
    3.             set {_meta} to {_item}.getItemMeta()
    4.             set {_ench} to {_meta}.getStoredEnchants()
    5.             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
     
  2. Best Answer:
    Post #2 by Minecoll_YT, Aug 9, 2021
  3. Minecoll_YT

    Supporter Forums Helper

    Joined:
    Dec 2, 2018
    Messages:
    650
    Likes Received:
    39
    You could create a function that shortens it down
    Code (Text):
    1. function checkEnchant(item: item, enchant: text) :: boolean:
    2.     set {_meta} to {_item}.getItemMeta()
    3.     set {_ench} to {_meta}.getStoredEnchants()
    4.     if {_ench} = `{Enchantment[minecraft:efficiency, %{_enchant}%]=1}`:
    5.         return true
    6.     else:
    7.         return false
    8.        
    9. command /check:
    10.     trigger:
    11.         if checkEnchant(player's tool, "DIG_SPEED") is true:
    12.             send "has enchant"
     
    • Like Like x 1
  4. BALTICA

    BALTICA New Member

    Joined:
    Jun 7, 2021
    Messages:
    6
    Likes Received:
    0
    Thanks, that helped me a lot
     
  5. Minecoll_YT

    Supporter Forums Helper

    Joined:
    Dec 2, 2018
    Messages:
    650
    Likes Received:
    39
    No problem
     
Thread Status:
Not open for further replies.

Share This Page

Loading...