quarry.sk

Created by Zeldaboy111

Just so you know, we don't know the file format for every file. If it's just a bunch of random characters, it's probably a .zip or .jar.

function checkQuarry(p: Player, loc: Location) :: boolean:
	set {_below} to block 1 meters below {_loc}
	if block at {_below} is not dropper:
		return false
	set {_detected} to false
	if block at location 1 meters north of {_below} is hopper:
		if block at location 1 meters south of {_below} is chest:
			if block at location 2 meters south of {_below} is chest:
				set {_detected} to true
				set {quarry.chestDetect.%{_loc}%} to south
	else if block at location 1 meters east of {_below} is hopper:
		if block at location 1 meters west of {_below} is chest:
			if block at location 2 meters west of {_below} is chest:
				set {_detected} to true
				set {quarry.chestDetect.%{_loc}%} to west
	else if block at location 1 meters south of {_below} is hopper:
		if block at location 1 meters north of {_below} is chest:
			if block at location 2 meters north of {_below} is chest:
				set {_detected} to true
				set {quarry.chestDetect.%{_loc}%} to north
	else if block at location 1 meters west of {_below} is hopper:
		if block at location 1 meters east of {_below} is chest:
			if block at location 2 meters east of {_below} is chest:
				set {_detected} to true
				set {quarry.chestDetect.%{_loc}%} to east

	return {_detected}

function quarryGUI(p: Player, loc: Location):
	set {quarry.open.%{_p}%} to {_loc}
	open chest with 5 rows named "Quarry" to {_p}
	wait 2 ticks
	set {_count} to 45
	loop 9 times:
		set slot loop-value - 1 of {_p}'s current inventory to gray stained glass pane named "&8"
		set slot {_count} - loop-value of {_p}'s current inventory to gray stained glass pane named "&8"

	loop 4 times:
		set slot 9*loop-value of {_p}'s current inventory to gray stained glass pane named "&8"
		set slot 9*loop-value - 1 of {_p}'s current inventory to gray stained glass pane named "&8"	

	#RESET SLOT

	if {quarry.list.%{_loc}%.enabled} is true:
		set slot 21 of {_p}'s current inventory to lime shulker box named "&aEnabled"
		set slot 23 of {_p}'s current inventory to red shulker box named "&cDisable"
		set slot 31 of {_p}'s current inventory to note block named "&7Reset" with lore "" and "&8This cannot be undone!"
	else:
		set slot 21 of {_p}'s current inventory to lime shulker box named "&aEnable"
		set slot 23 of {_p}'s current inventory to red shulker box named "&cDisabled"
		set slot 31 of {_p}'s current inventory to note block named "&7Reset" with lore "" and "&8This cannot be undone!"

function mine(loc: Location, startLoc: Location):
	set {_mine} to true
	set {_chest} to block at {quarry.chest.%{_loc}%}
	if {quarry.row.%{_loc}%} is not set:
		set {quarry.row.%{_loc}%} to 0
	if {quarry.colmn.%{_loc}%} is not set:
		set {quarry.colmn.%{_loc}%} to 0
	if {quarry.depth.%{_loc}%} is not set:
		set {quarry.depth.%{_loc}%} to 0
	while {quarry.list.%{_loc}%.enabled}:
		if {_mine}:
			wait 7 seconds
		else:
			wait 30 ticks
			
		if y-coordinate of {quarry.current.%{_loc}%} < 2:
			delete {quarry.list.%{_loc}%.enabled}
			stop

		set {_mine} to false
		if {quarry.row.%{_loc}%} is not set:
			set {quarry.row.%{_loc}%} to 0
		if {quarry.colmn.%{_loc}%} is not set:
			set {quarry.colmn.%{_loc}%} to 0
		if {quarry.depth.%{_loc}%} is not set:
			set {quarry.depth.%{_loc}%} to 0

		if {quarry.row.%{_loc}%} >= 6:
			set {quarry.row.%{_loc}%} to 0
			if {quarry.colmn.%{_loc}%} <= 4:
				add 1 to {quarry.colmn.%{_loc}%}
				if {quarry.chestDetect.%{_loc}%} is north:
					set {quarry.current.%{_loc}%} to location 1 meters east and 6 meters north of {quarry.current.%{_loc}%}
				else if {quarry.chestDetect.%{_loc}%} is east:
					set {quarry.current.%{_loc}%} to location 1 meters north and 6 meters east of {quarry.current.%{_loc}%}
				else if {quarry.chestDetect.%{_loc}%} is south:
					set {quarry.current.%{_loc}%} to location 1 meters west and 6 meters south of {quarry.current.%{_loc}%}
				else if {quarry.chestDetect.%{_loc}%} is west:
					set {quarry.current.%{_loc}%} to location 1 meters south and 6 meters west of {quarry.current.%{_loc}%}

			else:
				set {quarry.colmn.%{_loc}%} to 0
				if y-coordinate of {quarry.current.%{_loc}%} > 0:
					add 1 to {quarry.depth.%{_loc}%}
					set {quarry.current.%{_loc}%} to location {quarry.depth.%{_loc}%} meters below {_startLoc}
				else:
					set {quarry.list.%{_loc}%.enabled} to false
					delete {quarry.current.%{_loc}%}
		#else:
		add 1 to {quarry.row.%{_loc}%}
		if {quarry.chestDetect.%{_loc}%} is north:
			set {quarry.current.%{_loc}%} to location 1 meters south of {quarry.current.%{_loc}%}
		else if {quarry.chestDetect.%{_loc}%} is east:
			set {quarry.current.%{_loc}%} to location 1 meters west of {quarry.current.%{_loc}%}
		else if {quarry.chestDetect.%{_loc}%} is south:
			set {quarry.current.%{_loc}%} to location 1 meters north of {quarry.current.%{_loc}%}
		else if {quarry.chestDetect.%{_loc}%} is west:
			set {quarry.current.%{_loc}%} to location 1 meters east of {quarry.current.%{_loc}%}

		if checkQuarry("" parsed as an offline player, {_loc}) is false:
			stop
		set {_b} to block at {quarry.current.%{_loc}%}
		if {_b} is not bedrock:
			if {_b} is stone:
				set {_b} to cobblestone
			else if {_b} is iron ore:
				set {_b} to iron ingot
			else if {_b} is gold ore:
				set {_b} to gold ingot
			else if {_b} is redstone ore:
				set {_b} to 4 redstone
			else if {_b} is lapis ore:
				set {_b} to 4 lapis
			else if {_b} is emerald ore:
				set {_b} to emerald
			else if {_b} is diamond ore:
				set {_b} to diamond
			else if {_b} is coal ore:
				set {_b} to coal

			add {_b} to {_chest}'s inventory
			set block at {quarry.current.%{_loc}%} to air

		set {_mine} to true

on rightclick on daylight detector:
	if checkQuarry(player, location of clicked block):
		cancel event
		quarryGUI(player, location of clicked block)

on inventory click:
	if inventory name of player's current inventory is "Quarry":
		cancel event
		if clicked slot is 21:
			if name of clicked item is "&aEnable":
				set slot 21 of player's current inventory to lime shulker box named "&aEnabled"
				set slot 23 of player's current inventory to red shulker box named "&cDisable"
				set slot 31 of player's current inventory to note block named "&7Reset" with lore "" and "&8This cannot be undone!"
				play "ENTITY_PLAYER_LEVELUP" to player at volume 10
				if {quarry.chest.%{quarry.open.%player%}%} is not set:
					if {quarry.chestDetect.%{quarry.open.%player%}%} is north:
						set {quarry.chest.%{quarry.open.%player%}%} to location 1 meters below and 1 meters north of {quarry.open.%player%}

					else if {quarry.chestDetect.%{quarry.open.%player%}%} is east:
						set {quarry.chest.%{quarry.open.%player%}%} to location 1 meters below and 1 meters east of {quarry.open.%player%}

					else if {quarry.chestDetect.%{quarry.open.%player%}%} is south:
						set {quarry.chest.%{quarry.open.%player%}%} to location 1 meters below and 1 meters south of {quarry.open.%player%}

					else if {quarry.chestDetect.%{quarry.open.%player%}%} is west:
						set {quarry.chest.%{quarry.open.%player%}%} to location 1 meters below and 1 meters west of {quarry.open.%player%}
				
				if {quarry.current.%{quarry.open.%player%}%} is not set:
					if {quarry.chestDetect.%{quarry.open.%player%}%} is north:
						set {quarry.current.%{quarry.open.%player%}%} to location 4 meters north and 1 meters east and 2 meters below {quarry.open.%player%}
					else if {quarry.chestDetect.%{quarry.open.%player%}%} is east:
						set {quarry.current.%{quarry.open.%player%}%} to location 4 meters east and 1 meters north and 2 meters below {quarry.open.%player%}
					else if {quarry.chestDetect.%{quarry.open.%player%}%} is south:
						set {quarry.current.%{quarry.open.%player%}%} to location 4 meters south and 1 meters west and 2 meters below {quarry.open.%player%}
					else if {quarry.chestDetect.%{quarry.open.%player%}%} is west:
						set {quarry.current.%{quarry.open.%player%}%} to location 4 meters west and 1 meters south and 2 meters below {quarry.open.%player%}
					
					set {quarry.startLoc.%{quarry.open.%player%}%} to {quarry.current.%{quarry.open.%player%}%}
				if {quarry.list::*} doesn't contain {quarry.open.%player%}:
					add {quarry.open.%player%} to {quarry.list::*}
					
				set {quarry.list.%{quarry.open.%player%}%.enabled} to true
				mine({quarry.open.%player%}, {quarry.startLoc.%{quarry.open.%player%}%})

			else:
				play "ENTITY_ITEM_BREAK" to player at volume 10
		else if clicked slot is 23:
			if name of clicked item is "&cDisable":
				delete {quarry.list.%{quarry.open.%player%}%.enabled}
				set slot 21 of player's current inventory to lime shulker box named "&aEnable"
				set slot 23 of player's current inventory to red shulker box named "&cDisabled"
				set slot 31 of player's current inventory to note block named "&7Reset" with lore "" and "&8This cannot be undone!"
				play "ENTITY_PLAYER_LEVELUP" to player at volume 10
			else:
				play "ENTITY_ITEM_BREAK" to player at volume 10
		else if clicked slot is 31:
			delete {quarry.list.%{_quarry}%.enabled}
			set {_quarry} to {quarry.open.%player%}
			set {quarry.row.%{_quarry}%} to 0
			set {quarry.colmn.%{_quarry}%} to 0
			set {quarry.depth.%{_quarry}%} to 0
			set {quarry.current.%{_quarry}%} to {quarry.startLoc.%{_quarry}%}
			set slot 21 of player's current inventory to lime shulker box named "&aEnable"
			set slot 23 of player's current inventory to red shulker box named "&cDisabled"
			set slot 31 of player's current inventory to note block named "&7Reset" with lore "" and "&8This cannot be undone!"
			play "ENTITY_PLAYER_LEVELUP" to player at volume 10

on disable:
	loop {quarry.list::*}:
		if {quarry.list.%loop-value%.enabled} is true:
			set {quarry.list.%loop-value%.enabled} to false
			set {quarry.list.%loop-value%.forceEnabled} to true
		else:
			set {quarry.list.%loop-value%.forceEnabled} to false

on enable:
	loop {quarry.list::*}:
		if {quarry.list.%loop-value%.forceEnabled} is not false:
			set {quarry.list.%loop-value%.enabled} to true
			set {quarry.list.%loop-value%.forceEnabled} to false
			mine(loop-value, {quarry.startLoc.%loop-value%})