Files
drills.sk
INSTALLATION.txt
itemsadder-config-example.yml
Code
3 301
drills.sk
options:
prefix: &6[Drills]&r
drill3x3: custom:drill_3x3
drill3x3x3: custom:drill_3x3x3
permission3x3: drills.use.3x3
permission3x3x3: drills.use.3x3x3
sneakToDisable: true
on break:
set {_itemid} to nbt tag "CustomModelData" of player's tool
if {_itemid} is not set:
set {_itemid} to nbt tag "PublicBukkitValues.""itemsadder:item-id""" of player's tool
if {_itemid} is "{@drill3x3}":
set {_is3x3} to true
else if {_itemid} is "{@drill3x3x3}":
set {_is3x3x3} to true
else:
stop
if {@sneakToDisable}:
if player is sneaking:
stop
set {_drill} to player's tool
set {_mode} to "3x3"
set {_permission} to "{@permission3x3}"
if {_is3x3x3} is set:
set {_mode} to "3x3x3"
set {_permission} to "{@permission3x3x3}"
if player doesn't have permission {_permission}:
send "{@prefix} &cYou don't have permission to use this drill!" to player
stop
set {_center} to event-block
set {_face} to player's facing
if {_mode} is "3x3":
loop getDrill3x3Blocks({_center}, {_face}):
drillBlock(player, loop-value, {_drill})
else:
loop getDrill3x3x3Blocks({_center}, {_face}):
drillBlock(player, loop-value, {_drill})
function drillBlock(p: player, b: block, drill: item):
if {_b} is air:
stop
if {_b} is bedrock:
stop
if {_b} is barrier:
stop
if {_b} is end portal frame:
stop
if {_b} is end portal (teleport cause):
stop
if {_b} is nether portal (teleport cause):
stop
set {_drops::*} to drops of {_b}
set {_fortune} to level of fortune of {_p}'s tool
set {_hasSilk} to false
if {_p}'s tool has silk touch:
set {_hasSilk} to true
if {_hasSilk} is true:
drop {_b} at {_b}
else:
loop {_drops::*}:
if {_fortune} > 0:
if loop-value is diamond or coal or redstone or lapis lazuli or emerald or quartz:
set {_amount} to amount of loop-value
set {_bonus} to random integer between 0 and {_fortune}
add {_bonus} to {_amount}
set amount of loop-value to {_amount}
drop loop-value at {_b}
break {_b} naturally using {_p}'s tool
damage {_drill} by 1
if durability of {_drill} >= max durability of {_drill}:
set {_p}'s tool to air
play sound "entity.item.break" with volume 1 and pitch 1 at {_p}
send "{@prefix} &cYour drill broke!" to {_p}
function getDrill3x3Blocks(center: block, face: text) :: blocks:
set {_blocks::*} to {_center}
if {_face} is "north" or "south":
add block above {_center} to {_blocks::*}
add block below {_center} to {_blocks::*}
add block east of {_center} to {_blocks::*}
add block west of {_center} to {_blocks::*}
add block above block east of {_center} to {_blocks::*}
add block above block west of {_center} to {_blocks::*}
add block below block east of {_center} to {_blocks::*}
add block below block west of {_center} to {_blocks::*}
else if {_face} is "east" or "west":
add block above {_center} to {_blocks::*}
add block below {_center} to {_blocks::*}
add block north of {_center} to {_blocks::*}
add block south of {_center} to {_blocks::*}
add block above block north of {_center} to {_blocks::*}
add block above block south of {_center} to {_blocks::*}
add block below block north of {_center} to {_blocks::*}
add block below block south of {_center} to {_blocks::*}
else if {_face} is "up" or "down":
add block north of {_center} to {_blocks::*}
add block south of {_center} to {_blocks::*}
add block east of {_center} to {_blocks::*}
add block west of {_center} to {_blocks::*}
add block north of block east of {_center} to {_blocks::*}
add block south of block east of {_center} to {_blocks::*}
add block north of block west of {_center} to {_blocks::*}
add block south of block west of {_center} to {_blocks::*}
return {_blocks::*}
function getDrill3x3x3Blocks(center: block, face: text) :: blocks:
set {_blocks::*} to getDrill3x3Blocks({_center}, {_face})
if {_face} is "north":
loop getDrill3x3Blocks(block north of {_center}, {_face}):
add loop-value to {_blocks::*}
else if {_face} is "south":
loop getDrill3x3Blocks(block south of {_center}, {_face}):
add loop-value to {_blocks::*}
else if {_face} is "east":
loop getDrill3x3Blocks(block east of {_center}, {_face}):
add loop-value to {_blocks::*}
else if {_face} is "west":
loop getDrill3x3Blocks(block west of {_center}, {_face}):
add loop-value to {_blocks::*}
else if {_face} is "up":
loop getDrill3x3Blocks(block above {_center}, {_face}):
add loop-value to {_blocks::*}
else if {_face} is "down":
loop getDrill3x3Blocks(block below {_center}, {_face}):
add loop-value to {_blocks::*}
return {_blocks::*}
on script load:
send "{@prefix} &aDrill System loaded! 3x3 and 3x3x3 drills ready." to console
command /drill [<text>] [<offline player>]:
permission: drills.admin
trigger:
if arg-1 is not set:
send "{@prefix} &eCommands:"
send "&7/drill give3x3 <player> &8- &fGive 3x3 drill"
send "&7/drill give3x3x3 <player> &8- &fGive 3x3x3 drill"
send "&7/drill reload &8- &fReload script"
stop
if arg-1 is "reload":
execute console command "/sk reload drills"
send "{@prefix} &aScript reloaded!"
stop
if arg-1 is "give3x3":
if arg-2 is not set:
send "{@prefix} &cUse: /drill give3x3 <player>"
stop
send "{@prefix} &eYou need to create the item '{@drill3x3}' in ItemsAdder!"
send "{@prefix} &7Add this to your items after creating the custom item."
stop
if arg-1 is "give3x3x3":
if arg-2 is not set:
send "{@prefix} &cUse: /drill give3x3x3 <player>"
stop
send "{@prefix} &eYou need to create the item '{@drill3x3x3}' in ItemsAdder!"
send "{@prefix} &7Add this to your items after creating the custom item."
stop