Zeldaboy111

Mine Functie {3/4} ]|[ Skript #324

Jun 29th, 2020
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.20 KB | None | 0 0
  1. #GUI when clicking on it
  2. function checkQuarry(p: Player, loc: Location) :: boolean:
  3. set {_below} to block 1 meters below {_loc}
  4. if block at {_below} is not dropper:
  5. return false
  6. set {_detected} to false
  7. if block at location 1 meters north of {_below} is hopper:
  8. if block at location 1 meters south of {_below} is chest:
  9. if block at location 2 meters south of {_below} is chest:
  10. set {_detected} to true
  11. set {quarry.chestDetect.%{_loc}%} to south
  12. else if block at location 1 meters east of {_below} is hopper:
  13. if block at location 1 meters west of {_below} is chest:
  14. if block at location 2 meters west of {_below} is chest:
  15. set {_detected} to true
  16. set {quarry.chestDetect.%{_loc}%} to west
  17. else if block at location 1 meters south of {_below} is hopper:
  18. if block at location 1 meters north of {_below} is chest:
  19. if block at location 2 meters north of {_below} is chest:
  20. set {_detected} to true
  21. set {quarry.chestDetect.%{_loc}%} to north
  22. else if block at location 1 meters west of {_below} is hopper:
  23. if block at location 1 meters east of {_below} is chest:
  24. if block at location 2 meters east of {_below} is chest:
  25. set {_detected} to true
  26. set {quarry.chestDetect.%{_loc}%} to east
  27.  
  28. return {_detected}
  29.  
  30. function quarryGUI(p: Player, loc: Location):
  31. set {quarry.open.%{_p}%} to {_loc}
  32. open chest with 5 rows named "Quarry" to {_p}
  33. wait 2 ticks
  34. set {_count} to 45
  35. loop 9 times:
  36. set slot loop-value - 1 of {_p}'s current inventory to gray stained glass pane named "&8"
  37. set slot {_count} - loop-value of {_p}'s current inventory to gray stained glass pane named "&8"
  38.  
  39. loop 4 times:
  40. set slot 9*loop-value of {_p}'s current inventory to gray stained glass pane named "&8"
  41. set slot 9*loop-value - 1 of {_p}'s current inventory to gray stained glass pane named "&8"
  42.  
  43. #RESET SLOT
  44.  
  45. if {quarry.list.%{_loc}%.enabled} is true:
  46. set slot 21 of {_p}'s current inventory to lime shulker box named "&aEnabled"
  47. set slot 23 of {_p}'s current inventory to red shulker box named "&cDisable"
  48. else:
  49. set slot 21 of {_p}'s current inventory to lime shulker box named "&aEnable"
  50. set slot 23 of {_p}'s current inventory to red shulker box named "&cDisabled"
  51.  
  52. function mine(loc: Location, startLoc: Location):
  53. set {_mine} to true
  54. set {_chest} to block at {quarry.chest.%{_loc}%}
  55. set {quarry.row.%{_loc}%} to 0
  56. set {quarry.colmn.%{_loc}%} to 0
  57. set {quarry.depth.%{_loc}%} to 0
  58. while {quarry.list.%{_loc}%.enabled}:
  59.  
  60. if {_mine}:
  61. wait 10 ticks
  62. #wait 7 seconds
  63. else:
  64. wait 30 ticks
  65.  
  66.  
  67. set {_mine} to false
  68. if {quarry.row.%{_loc}%} is not set:
  69. set {quarry.row.%{_loc}%} to 0
  70. if {quarry.colmn.%{_loc}%} is not set:
  71. set {quarry.colmn.%{_loc}%} to 0
  72. if {quarry.depth.%{_loc}%} is not set:
  73. set {quarry.depth.%{_loc}%} to 0
  74.  
  75. if {quarry.row.%{_loc}%} > 5:
  76. set {quarry.row.%{_loc}%} to 0
  77. if {quarry.colmn.%{_loc}%} <= 5:
  78. add 1 to {quarry.colmn.%{_loc}%}
  79. if {quarry.chestDetect.%{_loc}%} is north:
  80. set {quarry.current.%{_loc}%} to location 1 meters east and 5 meters north of {quarry.current.%{_loc}%}
  81. else if {quarry.chestDetect.%{_loc}%} is east:
  82. set {quarry.current.%{_loc}%} to location 1 meters north and 5 meters east of {quarry.current.%{_loc}%}
  83. else if {quarry.chestDetect.%{_loc}%} is south:
  84. set {quarry.current.%{_loc}%} to location 1 meters west and 5 meters south of {quarry.current.%{_loc}%}
  85. else if {quarry.chestDetect.%{_loc}%} is west:
  86. set {quarry.current.%{_loc}%} to location 1 meters south and 5 meters west of {quarry.current.%{_loc}%}
  87.  
  88. else:
  89. set {quarry.colmn.%{_loc}%} to 0
  90. if y-coordinate of {quarry.current.%{_loc}%} > 0:
  91. add 1 to {quarry.depth.%{_loc}%}
  92. set {quarry.current.%{_loc}%} to location {quarry.depth.%{_loc}%} meters below {_startLoc}
  93. else:
  94. set {quarry.list.%{_loc}%.enabled} to false
  95. delete {quarry.current.%{_loc}%}
  96. else:
  97. add 1 to {quarry.row.%{_loc}%}
  98. if {quarry.chestDetect.%{_loc}%} is north:
  99. set {quarry.current.%{_loc}%} to location 1 meters south of {quarry.current.%{_loc}%}
  100. else if {quarry.chestDetect.%{_loc}%} is east:
  101. set {quarry.current.%{_loc}%} to location 1 meters west of {quarry.current.%{_loc}%}
  102. else if {quarry.chestDetect.%{_loc}%} is south:
  103. set {quarry.current.%{_loc}%} to location 1 meters north of {quarry.current.%{_loc}%}
  104. else if {quarry.chestDetect.%{_loc}%} is west:
  105. set {quarry.current.%{_loc}%} to location 1 meters east of {quarry.current.%{_loc}%}
  106.  
  107. if checkQuarry("" parsed as an offline player, {_loc}) is false:
  108. stop
  109. set {_b} to block at {quarry.current.%{_loc}%}
  110. add {_b} to {_chest}'s inventory
  111. set block at {quarry.current.%{_loc}%} to air
  112.  
  113. set {_mine} to true
  114.  
  115. on rightclick on daylight detector:
  116. if checkQuarry(player, location of clicked block):
  117. cancel event
  118. quarryGUI(player, location of clicked block)
  119.  
  120. on inventory click:
  121. if inventory name of player's current inventory is "Quarry":
  122. cancel event
  123. if clicked slot is 21:
  124. if name of clicked item is "&aEnable":
  125. set {quarry.list.%{quarry.open.%player%}%.enabled} to true
  126. set slot 21 of player's current inventory to lime shulker box named "&aEnabled"
  127. set slot 23 of player's current inventory to red shulker box named "&cDisable"
  128. play "ENTITY_PLAYER_LEVELUP" to player at volume 10
  129. if {quarry.chest.%{quarry.open.%player%}%} is not set:
  130. if {quarry.chestDetect.%{quarry.open.%player%}%} is north:
  131. set {quarry.chest.%{quarry.open.%player%}%} to location 1 meters below and 1 meters north of {quarry.open.%player%}
  132.  
  133. else if {quarry.chestDetect.%{quarry.open.%player%}%} is east:
  134. set {quarry.chest.%{quarry.open.%player%}%} to location 1 meters below and 1 meters east of {quarry.open.%player%}
  135.  
  136. else if {quarry.chestDetect.%{quarry.open.%player%}%} is south:
  137. set {quarry.chest.%{quarry.open.%player%}%} to location 1 meters below and 1 meters south of {quarry.open.%player%}
  138.  
  139. else if {quarry.chestDetect.%{quarry.open.%player%}%} is west:
  140. set {quarry.chest.%{quarry.open.%player%}%} to location 1 meters below and 1 meters west of {quarry.open.%player%}
  141.  
  142. set {_quarry} to {quarry.open.%player%}
  143. delete {quarry.current.%{_quarry}%}
  144. if {quarry.current.%{_quarry}%} is not set:
  145. if {quarry.chestDetect.%{_quarry}%} is north:
  146. set {quarry.current.%{_quarry}%} to location 4 meters north and 1 meters east and 2 meters below {_quarry}
  147. else if {quarry.chestDetect.%{_quarry}%} is east:
  148. set {quarry.current.%{_quarry}%} to location 4 meters east and 1 meters north and 2 meters below {_quarry}
  149. else if {quarry.chestDetect.%{_quarry}%} is south:
  150. set {quarry.current.%{_quarry}%} to location 4 meters south and 1 meters west and 2 meters below {_quarry}
  151. else if {quarry.chestDetect.%{_quarry}%} is west:
  152. set {quarry.current.%{_quarry}%} to location 4 meters west and 1 meters south and 2 meters below {_quarry}
  153.  
  154. set {quarry.startLoc.%{_quarry}%} to {quarry.current.%{_quarry}%}
  155. if {quarry.list::*} doesn't contain {_quarry}:
  156. add {_quarry} to {quarry.list::*}
  157.  
  158. mine({_quarry}, {quarry.startLoc.%{_quarry}%})
  159.  
  160. else:
  161. play "ENTITY_ITEM_BREAK" to player at volume 10
  162. else if clicked slot is 23:
  163. if name of clicked item is "&cDisable":
  164. delete {quarry.list.%{quarry.open.%player%}%.enabled}
  165. set slot 21 of player's current inventory to lime shulker box named "&aEnable"
  166. set slot 23 of player's current inventory to red shulker box named "&cDisabled"
  167. #CHECK SET AND SET INTO VARIABLE
  168. play "ENTITY_PLAYER_LEVELUP" to player at volume 10
  169. else:
  170. play "ENTITY_ITEM_BREAK" to player at volume 10
  171.  
  172. on disable:
  173. loop {quarry.list::*}:
  174. if {quarry.list.%loop-value%.enabled} is true:
  175. set {quarry.list.%loop-value%.enabled} to false
  176. set {quarry.list.%loop-value%.forceEnabled} to true
  177. else:
  178. set {quarry.list.%loop-value%.forceEnabled} to false
  179.  
  180. on enable:
  181. loop {quarry.list::*}:
  182. if {quarry.list.%loop-value%.forceEnabled} is not false:
  183. set {quarry.list.%loop-value%.enabled} to true
  184. set {quarry.list.%loop-value%.forceEnabled} to false
  185. mine(loop-value, {quarry.startLoc.%loop-value%})
Add Comment
Please, Sign In to add comment