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!

Dismiss Notice
This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Addon SkEnchants Release-04.29.22-v1.0.1

Suite of helpful functions that help creating custom enchants easy (Proper Skript addon indev)

  1. Terry Jackson
    Supported Minecraft Versions:
    • 1.8, 1.9, 1.10, 1.11, 1.12, 1.13, 1.14, 1.15, 1.16, 1.17, 1.18
    SkEnchants
    (This is currently a script but a proper addon jar is in development)

    A suite of functions that make creating custom enchantments easier.

    <item> = The item you want to check.
    <enchant> = The enchantment name (You can use color codes).
    <level> = The level of the enchantment you want to apply.
    <roman=true/false> = True or False option to convert normal numbers into roman numerals.


    #1: hasEnchant(<item>, <enchant>)
    Code (Text):
    1. hasEnchant(event-item, "Poison")
    Boolean, returns true or false if you have the enchantment on your item.

    #2: getEnchantLevel(<item>, <enchant>)
    Code (Text):
    1. getEnchantLevel(event-item, "Poison")
    Returns the enchantment level of enchantment on an item.

    #3: applyEnchant(<item>, <enchant>, <level>, <roman=true/false>)
    Code (Text):
    1. addEnchant(event-item, "Poison", 1, true)
    Applies enchantment to your item and if the item already has the enchant it will replace it.

    #4: removeEnchant(<item>, <enchant>)
    Code (Text):
    1. removeEnchant(event-item, "Poison")
    Removes enchantment from your item.

    #5: addEnchantLevel(<item>, <enchant>, <level>, <roman=true/false>)
    Code (Text):
    1. addEnchantLevel(event-item, "Poison", 1, true)
    Increases existing enchantment level

    #6: subtractEnchantLevel(<item>, <enchant>, <level>, <roman=true/false>)
    Code (Text):
    1. subtractEnchantLevel(event-item, "Poison", 1, true)
    Decreases existing enchantment level

    Code (Text):
    1. import:
    2.     com.sk89q.worldedit.regions.CuboidRegion
    3.     com.sk89q.worldedit.Vector as WorldEditVector
    4.     com.sk89q.worldedit.EditSession
    5.     com.boydti.fawe.FaweAPI
    6.     com.boydti.fawe.util.EditSessionBuilder
    7.     com.sk89q.worldedit.blocks.BaseBlock
    8.     com.sk89q.worldedit.patterns.BlockChance
    9.     java.util.Arrays
    10.     com.sk89q.worldedit.patterns.RandomFillPattern
    11.     java.util.stream.Collectors
    12. function getRegion(pos1: location, pos2: location) :: object:
    13.     loop 1 and 2:
    14.         set {_vec::%loop-value%} to new WorldEditVector((x-coord of {_pos%loop-value%}), (y-coord of {_pos%loop-value%}) and (z-coord of {_pos%loop-value%}))
    15.     return new CuboidRegion({_vec::*})
    16. function getBaseBlock(block: itemtype) :: object:
    17.     return new BaseBlock({_block}.getRandom().getTypeId() and {_block}.getRandom().getData().getData())
    18. function getBlockChance(block: itemtype, chance: number) :: object:
    19.     return new BlockChance(getBaseBlock({_block}) and {_chance})
    20. function getWorld(world: world) :: object:
    21.     return FaweAPI.getWorld("%{_world}%")
    22. function getEditSession(world: world) :: object:
    23.     return new EditSessionBuilder(getWorld({_world})).fastmode(true).build()
    24. function setBlocks(pos1: location, pos2: location, block: object) :: boolean:
    25.     set {_session} to getEditSession(world of {_pos1})
    26.     set {_args::*} to getRegion({_pos1}, {_pos2}) and getBaseBlock({_block})
    27.     if {_block} is a text:
    28.         loop split {_block} at ",":
    29.             set {_it::*} to join (split loop-value at "%%") with " " parsed as "%integer% %item%"
    30.             if {_it::*} is set:
    31.                 add getBlockChance({_it::2}, {_it::1}) to {_c::*}
    32.                 delete {_it::*}
    33.             else:
    34.                 return false
    35.         set {_args::*} to getRegion({_pos1}, {_pos2})
    36.         add new RandomFillPattern(Arrays.stream([{_c::*}]).collect(Collectors.toList())) to {_args::*}
    37.     {_session}.setBlocks({_args::*})
    38.     {_session}.flushQueue()
    39.     return true
    40.  
    41. on mine:
    42.     if player's tool is a pickaxe:
    43.         if player is in world "world":
    44.             event.setDropItems(false)
    45.             "%region at event-block%" contains "mine"
    46.             if getEnchantLevel(player's held item, "Jackhammer") >= 1:
    47.                 set {_chance} to (0.0000112 * getEnchantLevel(player's held item, "Jackhammer")) * 100
    48.                 set {_region} to "%region at event-block%"
    49.                 replace " in world world" with "" in {_region}
    50.                 set {_pos1} to sharpsk worldguard point 1 of region "%{_region}%" in world "world"
    51.                 set {_pos2} to sharpsk worldguard point 2 of region "%{_region}%" in world "world"
    52.                 chance of {_chance}%:
    53.                     set {_y} to y coordinate of event-block
    54.                     set y coord of {_pos1} to {_y}
    55.                     set y coord of {_pos2} to {_y}
    56.                     setBlocks({_pos1}, {_pos2}, air)
    57.                     loop all blocks between block at {_pos1} and block at {_pos2}:
    58.                         if getEnchantLevel(player's held item, "Fortune") >= 1:
    59.                             procFortune(player, loop-block)
    60.                             procLucky(player)
    61.                             procCharity(player)
    62.                             procBlessing(player)
    63.                         set {_loc} to location of loop-block
    64.                         set {_nbt} to tag "ID" of nbt of player's tool
    65.                         add 1 to {blocks::pickaxe::%{_nbt}%}
    66.                         drawDot count 2, particle "explosion", XYZ 10, 0, 10, center {_loc}, visibleRange 55, keepFor 0 ticks



    Need Help?
    Join the SlamStudios™ discord server where we offer support for our plugins, other projects and, you can even share your own projects, products, and services.
    CLICK TO JOIN