SkEnchants
(This is currently a script but a proper addon jar is in development)
(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")
#2: getEnchantLevel(<item>, <enchant>)
Code:
getEnchantLevel(event-item, "Poison")
#3: applyEnchant(<item>, <enchant>, <level>, <roman=true/false>)
Code:
addEnchant(event-item, "Poison", 1, true)
#4: removeEnchant(<item>, <enchant>)
Code:
removeEnchant(event-item, "Poison")
#5: addEnchantLevel(<item>, <enchant>, <level>, <roman=true/false>)
Code:
addEnchantLevel(event-item, "Poison", 1, true)
#6: subtractEnchantLevel(<item>, <enchant>, <level>, <roman=true/false>)
Code:
subtractEnchantLevel(event-item, "Poison", 1, true)
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
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