SkEnchants

SkEnchants Release-04.29.22-v1.0.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!

Supported Minecraft Versions
  1. 1.8
  2. 1.9
  3. 1.10
  4. 1.11
  5. 1.12
  6. 1.13
  7. 1.14
  8. 1.15
  9. 1.16
  10. 1.17
  11. 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:
hasEnchant(event-item, "Poison")
Boolean, returns true or false if you have the enchantment on your item.

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

#3: applyEnchant(<item>, <enchant>, <level>, <roman=true/false>)
Code:
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:
removeEnchant(event-item, "Poison")
Removes enchantment from your item.

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

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

Code:
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
Author
Terry Jackson
Downloads
556
Views
556
First release
Last update
Rating
0.00 star(s) 0 ratings