Solved Give player item

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

    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.

Selvati

Active Member
Jun 26, 2017
190
11
18
So, I'm messing around with enchantments, and when a player uses my custom things, and doesn't roll a custom enchantment, they get one of the vanilla ench books, the problem is when the vanilla enchantment book is given to them, you can't use it in an anvil! anyone know how to fix this.
code_language.skript:
command /cosmeticgive <player>:
    permission: xc.cosmeticgive
    trigger:
        if arg-1 is set:
            give arg-1 1 enchanted_book named "&d&lMystery Book" with lore "&7Contains a random enchantment book!"
on rightclick:
    player is holding enchanted_book named "&d&lMystery Book" with lore "&7Contains a random enchantment book!"
    remove 1 enchanted_book named "&d&lMystery Book" with lore "&7Contains a random enchantment book!" from the player
    wait 1 second
    chance of 100%
    set {enchbook} to a random integer between 1 and 4
    if {enchbook} is 1:
        give player 1 of enchanted_book of Protection 1
    if {enchbook} is 2:
        give player 1 of enchanted_book of Protection 2
    if {enchbook} is 3:
        give player 1 of enchanted_book of Protection 3
    if {enchbook} is 4:
        give player 1 of enchanted_book of Protection 4
[doublepost=1502134472,1502134224][/doublepost]edit: the code works, but how do you make it so the vanilla books can be used in an anvil?
 
There may be a way to do it with nbt tags, but none that I could get to work for me. I know this works though
code_language.skript:
execute console command "/give %player% enchanted_book 1 0 {StoredEnchantments:[{id:0,lvl:1}]}"
The id and lvl portions you can get from this list here:
https://minecraft.gamepedia.com/Enchanting/ID

The reason your current one isn't working is because you're taking a blank enchanted book and adding the enchant to that item type, kind of like how enchanting a tool/weapon would work. So like "enchanted_book of sharpness 5" would give you a shiny book that does sharpness damage when you hit people with it lol
 
  • Like
Reactions: Selvati
Status
Not open for further replies.