Sueta

SkEnchants (Skript Addon for creating Custom Enchants)

Release-04.29.22-v1.0.1

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

·Script

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>)

Example
hasEnchant(event-item, "Poison")

Boolean, returns true or false if you have the enchantment on your item.

#2: getEnchantLevel(<item>, <enchant>)

Example
getEnchantLevel(event-item, "Poison")

Returns the enchantment level of enchantment on an item.

#3: applyEnchant(<item>, <enchant>, <level>, <roman=true/false>)

Example
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>)

Example
removeEnchant(event-item, "Poison")

Removes enchantment from your item.

#5: addEnchantLevel(<item>, <enchant>, <level>, <roman=true/false>)

Example
addEnchantLevel(event-item, "Poison", 1, true)

Increases existing enchantment level

#6: subtractEnchantLevel(<item>, <enchant>, <level>, <roman=true/false>)

Example
subtractEnchantLevel(event-item, "Poison", 1, true)

Decreases existing enchantment level

Jackhammer Enchantment Example
import:
    com.sk89q.worldedit.regions.CuboidRegion
    com.sk89q.worldedit.Vector as WorldEditVector
    com.sk89q.worldedit.EditSession
    com.boydti.fawe.FaweAPI
    com.boydti.fawe.util.EditSessionBuilder
    com.sk89q.worldedit.blocks.BaseBlock
    com.sk89q.worldedit.patterns.BlockChance
    java.util.Arrays
    com.sk89q.worldedit.patterns.RandomFillPattern
    java.util.stream.Collectors
function getRegion(pos1: location, pos2: location) :: object:
    loop 1 and 2:
        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%}))
    return new CuboidRegion({_vec::*})
function getBaseBlock(block: itemtype) :: object:
    return new BaseBlock({_block}.getRandom().getTypeId() and {_block}.getRandom().getData().getData())
function getBlockChance(block: itemtype, chance: number) :: object:
    return new BlockChance(getBaseBlock({_block}) and {_chance})
function getWorld(world: world) :: object:
    return FaweAPI.getWorld("%{_world}%")
function getEditSession(world: world) :: object:
    return new EditSessionBuilder(getWorld({_world})).fastmode(true).build()
function setBlocks(pos1: location, pos2: location, block: object) :: boolean:
    set {_session} to getEditSession(world of {_pos1})
    set {_args::*} to getRegion({_pos1}, {_pos2}) and getBaseBlock({_block})
    if {_block} is a text:
        loop split {_block} at ",":
            set {_it::*} to join (split loop-value at "%%") with " " parsed as "%integer% %item%"
            if {_it::*} is set:
                add getBlockChance({_it::2}, {_it::1}) to {_c::*}
                delete {_it::*}
            else:
                return false
        set {_args::*} to getRegion({_pos1}, {_pos2})
        add new RandomFillPattern(Arrays.stream([{_c::*}]).collect(Collectors.toList())) to {_args::*}
    {_session}.setBlocks({_args::*})
    {_session}.flushQueue()
    return true

on mine:
    if player's tool is a pickaxe:
        if player is in world "world":
            event.setDropItems(false)
            "%region at event-block%" contains "mine"
            if getEnchantLevel(player's held item, "Jackhammer") >= 1:
                set {_chance} to (0.0000112 * getEnchantLevel(player's held item, "Jackhammer")) * 100
                set {_region} to "%region at event-block%"
                replace " in world world" with "" in {_region}
                set {_pos1} to sharpsk worldguard point 1 of region "%{_region}%" in world "world"
                set {_pos2} to sharpsk worldguard point 2 of region "%{_region}%" in world "world"
                chance of {_chance}%:
                    set {_y} to y coordinate of event-block
                    set y coord of {_pos1} to {_y}
                    set y coord of {_pos2} to {_y}
                    setBlocks({_pos1}, {_pos2}, air)
                    loop all blocks between block at {_pos1} and block at {_pos2}:
                        if getEnchantLevel(player's held item, "Fortune") >= 1:
                            procFortune(player, loop-block)
                            procLucky(player)
                            procCharity(player)
                            procBlessing(player)
                        set {_loc} to location of loop-block
                        set {_nbt} to tag "ID" of nbt of player's tool
                        add 1 to {blocks::pickaxe::%{_nbt}%}
                        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

Similar projects

Script →