Get Enchants on Enchanted Books

  • 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.
Apr 12, 2017
36
0
0
24
I've had to totally change anvils on my server due to a naming bug, so I am having to create a system which allows player's to enchant their tools without anvils. I have a system where if they right click with a piece of paper, it enchants the player's first slot with the enchantments of the paper. I want this to be done with enchanted books aswell as the paper, but it does not seem enchanted books actually have enchantments.
code_language.skript:
on right click:
    player is holding paper
    player's tool is enchanted
    loop enchants of player's tool:
        enchant slot 0 of player's inventory with "%loop-value% %level of loop-value of the tool%" parsed as enchantment type
    remove 1 paper from player's tool


on right click with enchanted book:
    loop enchants of player's tool:
        enchant slot 0 of player's inventory with "%loop-value% %level of loop-value of the tool%" parsed as enchantment type
        send "%loop-value% %level of loop-value of the tool%" to player
    remove 1 enchanted book from player's tool
 
You're right, enchanted books are not actually enchanted themselves... they have StoredEnchantments in their NBT.
You would need to pull the enchantment from the NBT of the book, then apply that to the tool
 
oh that's odd.... which version/author of skript are you using? and which version of server software? Bukkit/Spigot/Paper?

Im just curious because im running a test server with spigot 1.12.2 and bensku's skript 2.2 dev 36 and its working totally fine with SkStuff
 
Im just curious because im running a test server with spigot 1.12.2 and bensku's skript 2.2 dev 36 and its working totally fine with SkStuff
I'm actually personally unable to use item NBT in SkStuff (Tuke's fork) on dev36.
 
I'm actually personally unable to use item NBT in SkStuff (Tuke's fork) on dev36.
im having some trouble with it, I can GET the NBT of an item, but im having a super hard time ADDING NBT to an item

Im trying to pull the NBT off of an enchantment book, and put it onto a tool

for testing sake, im just trying to add NBT to a sword, and nothing happens, this is the code im currently testing
code_language.skript:
command /test:
    trigger:
        set {_item} to diamond sword
        add "{ench:[{i'd:16s,lvl:1s}]}" to nbt of {_item}
        give player 1 of {_item}

it is just giving me a plain old diamond sword
 
Yeah, due to recent change in Skript with how slots are handled internally some add-ons are having issues, including SkStuff. Pika talked about working on a new NBT add-on but I'm not sure if he intends to finish it and he also said future support wouldn't be guaranteed. Either that or SkStuff needs to be updated by someone.
 
Status
Not open for further replies.