Advertisement
Zeldaboy111

Furnace GUI (event) ]|[ Skript #344

Sep 6th, 2020
228
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 13.25 KB | None | 0 0
  1. #multiblock structure
  2. #rename function
  3.  
  4. #requires: SkQuery, SkRayFall, Skellett, SkBee
  5.  
  6.  
  7. options:
  8. logo: &6&lBS&8:&7
  9.  
  10. function loop():
  11. if {furnace1.looping} is not true:
  12. set {furnace1.looping} to true
  13. while {furnace1.looping} is true:
  14. if size of {furnace1.loopList::*} is 0:
  15. set {furnace1.looping} to false
  16. stop loop
  17. else:
  18. loop {furnace1.loopList::*}:
  19. add 1 to {furnace1.%loop-value%.smeltTime}
  20. add 1 to {furnace1.%loop-value%.fuelingTime}
  21. if {furnace1.%loop-value%.smeltTime} >= 9:
  22. set {furnace1.%loop-value%.smeltTime} to 0
  23. remove 1 from {furnace1.%{_loc}%.contents.ore}
  24. add 1 to {furnace1.%{_loc}%.contents.ingot}
  25.  
  26. if {furnace1.%loop-value%.fuelingTime} >= {furnace1.%Loop-value%.fuelingTimeMax}:
  27. remove 1 from {furnace1.%loop-value%.contents.fuel}
  28. if {furnace1.%loop-value%.contents.fuel} <= 0:
  29. remove loop-value from {furnace1.loopList::*}
  30.  
  31. wait 1 second
  32.  
  33. function loop1():
  34. #if {furnace2.looping} is not true
  35.  
  36. # Returns how many ticks an item gives fuel
  37. function getFuelingTime(type: Item) :: integer:
  38. if {_type} is lava:
  39. return 20000
  40. else if {_type} is block of coal:
  41. return 16000
  42. else if {_type} is dried kelp block:
  43. return 4000
  44. else if {_type} is blaze rod:
  45. return 2400
  46. else if {_type} is coal or charcoal:
  47. return 1600
  48. else if {_type} is any boat or scaffolding:
  49. return 1200
  50. else if {_type} is any log or any planks or any wood slab or oak wood stairs or spruce wood stairs or birch wood stairs or jungle wood stairs or acacia wood stairs or dark oak wood stairs or any wooden button or any wooden trapdoor or any fence gate or any fence or ladder or crafting table or cartography table or fletching table or smithing table or loom or bookshelf or lectern or composter or chest or trapped chest or barrel or daylight detector or jukebox or note block or red mushroom block or brown mushroom block or mushroom stem or banner or bow or fishing rod:
  51. return 300
  52. else if {_type} is any wooden door or any sign or wooden pickaxe or wooden shovel or wooden hoe or wooden axe or wooden sword:
  53. return 200
  54. else if {_type} is bowl or any sapling or stick or any wool:
  55. return 100
  56. else if {_type} is any carpet:
  57. return 67
  58. else if {_type} is bamboo:
  59. return 50
  60. return 0
  61.  
  62. # Returns if the item can be smelted in the furnace, every smelt takes 10 seconds in a normal furnace
  63. function canSmelt(type: Item, tier: Integer) :: boolean:
  64. if {_type} is iron ore or gold ore or lapis ore or redstone ore or coal ore:
  65. return true
  66. else if {_tier} is 2:
  67. if {_type} is diamond ore or emerald ore or nether quartz ore:
  68. return true
  69.  
  70. return false
  71.  
  72. function outlineGui(p: Player):
  73. loop 9 times:
  74. set slot loop-value - 1 of {_p}'s current inventory to gray stained glass pane named "&8"
  75. set slot 54-loop-value of {_p}'s current inventory to gray stained glass pane named "&8"
  76.  
  77. loop 5 times:
  78. set slot loop-value * 9 of {_p}'s current inventory to gray stained glass pane named "&8"
  79. set slot loop-value * 9-1 of {_p}'s current inventory to gray stained glass pane named "&8"
  80.  
  81. function openGuiOutlined(p: Player, loc: Location, rows: integer, name: String):
  82. open chest with {_rows} rows named {_name} to {_p}
  83. set {inventory.%{_p}%.name} to uncolored {_name}
  84. set {inventory.%{_p}%.current} to {_loc}
  85. add {_p} to {inventoryList.%{_loc}%.%{inventory.%{_p}%.name}%::*}
  86. wait 2 ticks
  87. outlineGui({_p})
  88.  
  89. #function gui(p: Player):
  90. # openGuiOutlined({_p}, 6, "&8Anvil")
  91. #subcategorie armor -> alle armor die je kan maken laten zien
  92.  
  93. function guiFurnace1(p: Player, loc: Location):
  94. openGuiOutlined({_p}, {_loc}, 6, "&8Furnace I")
  95.  
  96. if {furnace1.%{_loc}%.contents.fuel} is not set:
  97. set {furnace1.%{_loc}%.contents.fuel} to 0
  98. if {furnace1.%{_loc}%.contents.ore} is not set:
  99. set {furnace1.%{_loc}%.contents.ore} to 0
  100. if {furnace1.%{_loc}%.contents.ingot} is not set:
  101. set {furnace1.%{_loc}%.contents.ingot} to 0
  102.  
  103. if {furnace1.%{_loc}%.contents.ingotType} is not set:
  104. set {furnace1.%{_loc}%.contents.ingot} to 0
  105. if {furnace1.%{_loc}%.contents.oreType} is not set:
  106. set {furnace1.%{_loc}%.contents.ore} to 0
  107. if {furnace1.%{_loc}%.contents.fuelType} is not set:
  108. set {furnace1.%{_loc}%.contents.fuel} to 0
  109.  
  110. set {furnace1.%{_loc}%.fuelingTimeMax} to 0
  111. if {furnace1.%{_loc}%.contents.fuelType} is set:
  112. set {furnace1.%{_loc}%.fuelingTimeMax} to getFuelingTime({furnace1.%{_loc}%.contents.fuelType}) / 20
  113.  
  114. set slot 38 of {_p}'s current inventory to lime stained glass pane named "&a&lOre"
  115. set slot 40 of {_p}'s current inventory to lime stained glass pane named "&a&lFuel"
  116. set slot 42 of {_p}'s current inventory to lime stained glass pane named "&a&lIngot"
  117.  
  118. if {furnace1.%{_loc}%.contents.ore} > 0:
  119. set slot 38 of {_p}'s current inventory to ("%{furnace1.%{_loc}%.contents.ore}% %{furnace1.%{_loc}%.contents.fuelType}%" parsed as an item)
  120.  
  121. if {furnace1.%{_loc}%.contents.fuel} > 0:
  122. set slot 40 of {_p}'s current inventory to ("%{furnace1.%{_loc}%.contents.fuel}% %{furnace1.%{_loc}%.contents.fuelType}%" parsed as an item)
  123.  
  124. if {furnace1.%{_loc}%.contents.ingot} > 0:
  125. set slot 42 of {_p}'s current inventory to ("%{furnace1.%{_loc}%.contents.ingot}% %{furnace1.%{_loc}%.contents.ingotType}%" parsed as an item)
  126.  
  127. #Slot for ore
  128.  
  129. #Slot for ingot
  130.  
  131. # loop for the cooking -- use states
  132.  
  133. loop 5 times:
  134. set slot 19 + loop-value of {_p}'s current inventory to gray stained glass pane named "&f0%%"
  135.  
  136.  
  137.  
  138. # U T I L I T I E S
  139.  
  140. function getNextNumber(base: number, addToDefault: number, max: number) :: number:
  141. set {_value} to {_base} + {_addToDefault}
  142. if {_value} > {_max}:
  143. set {_value} to {_addToDefault} - ({_max} - {_base})
  144.  
  145. return {_value}
  146.  
  147. function detectStair(facing: number, loc: Location, startValue: String) :: boolean:
  148. set {_list::*} to "westward red brick stair", "red brick stair", "eastward red brick stair" and "southward red brick stair"
  149. set {_dir} to {_facing}/2 + 1
  150.  
  151. if {_dir} > 4:
  152. remove 4 from {_dir}
  153.  
  154. if "%block at location of {_loc}%" is "%{_startValue}%%{_list::%{_dir}%}%":
  155. return true
  156. return false
  157.  
  158.  
  159. # F U R N A C E D E T E C T S
  160.  
  161. function isFurnace1(below: Location) :: boolean:
  162. if block at {_below} is campfire:
  163. set {_xAdjust::*} to 1, 1, 1, 0, 0, -1, -1 and -1
  164. set {_zAdjust::*} to 1, 0, -1, 1, -1, 1, 0 and -1
  165. loop 8 times:
  166. set {_checkLoc} to location at x-coordinate of {_below}+{_xAdjust::%loop-value%}, y-coordinate of {_below}, z-coordinate of {_below}+{_zAdjust::%loop-value%} in world of {_below}
  167. if block at {_checkLoc} is not red brick block:
  168. return false
  169. else:
  170. return false
  171. return true
  172.  
  173.  
  174. function isFurnace2(loc: Location) :: boolean:
  175. if block at {_loc} is not blast furnace:
  176. return false
  177.  
  178. set {_layer1::*} to air, brick slab, red brick block, air, red brick block, air, red brick block and brick slab
  179. set {_layer2::*} to air, red brick stair, eastward red brick stair and southward red brick stair
  180. set {_x::*} to 1, 1, 0, -1, -1, -1, 0 and 1
  181. set {_z::*} to 0, 1, 1, 1, 0, -1, -1 and -1
  182.  
  183. set {_base} to -2
  184. if block at location at x-coordinate of {_loc} + {_x::1}, y-coordinate of {_loc}, z-coordinate of {_loc} + {_z::1} in world of {_loc} is {_layer1::1}:
  185. set {_base} to 0
  186.  
  187. else if block at location at x-coordinate of {_loc} + {_x::3}, y-coordinate of {_loc}, z-coordinate of {_loc} + {_z::3} in world of {_loc} is {_layer1::1}:
  188. set {_base} to 2
  189.  
  190. else if block at location at x-coordinate of {_loc} + {_x::5}, y-coordinate of {_loc}, z-coordinate of {_loc} + {_z::5} in world of {_loc} is {_layer1::1}:
  191. set {_base} to 4
  192.  
  193. else if block at location at x-coordinate of {_loc} + {_x::7}, y-coordinate of {_loc}, z-coordinate of {_loc} + {_z::7} in world of {_loc} is {_layer1::1}:
  194. set {_base} to 6
  195.  
  196. set {_size} to size of {_x::*}
  197. if {_base} is not -2:
  198. loop 7 times:
  199. set {_value} to getNextNumber({_base}, loop-value, {_size})
  200. if block at location at x-coordinate of {_loc} + {_x::%{_value}%}, y-coordinate of {_loc}, z-coordinate of {_loc} + {_z::%{_value}%} in world of {_loc} is not {_layer1::%loop-value%}:
  201. return false
  202.  
  203.  
  204. set {_facingAdjust::*} to 0, 4, 6 and 8
  205. if detectStair({_base}, location 1 meters above {_loc}, "top "):
  206. loop 4 times:
  207. set {_value} to getNextNumber({_base}, loop-value*2, {_size}) - 1
  208. set {_check} to location at x-coordinate of {_loc} + {_x::%{_value}%}, y-coordinate of {_loc} + 1, z-coordinate of {_loc} + {_z::%{_value}%} in world of {_loc}
  209. set {_facing} to {_base}
  210. if {_facing} - {_facingAdjust::%loop-value%} >= 2:
  211. remove {_facingAdjust::%loop-value%} from {_facing}
  212. else:
  213. add {_facingAdjust::%loop-value%} to {_facing}
  214.  
  215. if loop-value is 1:
  216. if block at {_check} is not {_layer2::%loop-value%}:
  217. return false
  218. else if detectStair({_facing} - 2, {_check}, "") is false:
  219. return false
  220.  
  221. if block at location 2 meters above {_loc} is not red brick block:
  222. return false
  223. else:
  224. return false
  225. else:
  226. return false
  227. return true
  228.  
  229. # C L I C K E V E N T S
  230.  
  231. on rightclick on smooth stone:
  232. if player is not sneaking:
  233. if {anvil.%location of clicked block%} is true:
  234. #gui(player)
  235. cancel event
  236.  
  237. on rightclick on cauldron:
  238. if {furnace.%location of event-block%} is true:
  239. if isFurnace1(location 1 meters below clicked block):
  240. cancel event
  241. guiFurnace1(player, location of clicked block)
  242.  
  243. else:
  244. delete {furnace1.%location of clicked block%.contents.fuel}
  245. delete {furnace1.%location of clicked block%.contents.ore}
  246. delete {furnace1.%location of clicked block%.contents.ingot}
  247. delete {furnace.%location of event-block%}
  248.  
  249. on rightclick on blast furnace:
  250. if {furnace2.%location of event-block%} is true:
  251. if isFurnace2(location of clicked block):
  252. cancel event
  253. send "WIP"
  254. else:
  255. delete {furnace2.%location of event-block%}
  256.  
  257. on rightclick holding stone axe:
  258. if clicked block is smooth stone or iron block or diamond block:
  259. if {anvil.%location of event-block%} is not true:
  260. set {anvil.%location of event-block%} to true
  261. set {_tier} to "Tier I"
  262. if clicked block is smooth stone:
  263. set {anvil.%location of event-block%.tier} to 1
  264. else if clicked block is iron block:
  265. set {anvil.%location of event-block%.tier} to 2
  266. set {_tier} to "Tier II"
  267. else:
  268. set {anvil.%location of event-block%.tier} to 3
  269. set {_tier} to "Tier III"
  270.  
  271. set {_s} to 6
  272. loop all players in radius 6 around event-block:
  273. set {_v} to ({_s} - distance between loop-player and event-block)
  274. play sound "block.anvil.place" with volume {_v} and pitch 0 to loop-player
  275.  
  276. send "{@logo} Successfully created an anvil of %{_tier}%."
  277. summon armor stand at location 0.6 meters below event-block
  278. set name of last spawned armor stand to "&7Anvil"
  279. add "{Invisible:1b,NoGravity:1b,NoAI:1b,CustomNameVisible:1}" to NBT of last spawned armor stand
  280.  
  281. summon armor stand at location 0.9 meters below event-block
  282. set name of last spawned armor stand to "&7%{_tier}%"
  283. add "{Invisible:1b,NoGravity:1b,NoAI:1b,CustomNameVisible:1}" to NBT of last spawned armor stand
  284.  
  285. else if clicked block is cauldron:
  286. if {furnace.%location of event-block%} is not true:
  287. if isFurnace1(location 1 meters below clicked block):
  288. set {furnace.%location of event-block%} to true
  289. cancel event
  290.  
  291. else if clicked block is blast furnace:
  292. if {furnace.%location of event-block%} is not true:
  293. if isFurnace2(location of clicked block):
  294. set {furnace2.%location of event-block%} to true
  295. cancel event
  296. send "WIP"
  297.  
  298. on break of smooth stone or iron block or diamond block:
  299. if {anvil.%location of event-block%} is true:
  300. set {_s} to 6
  301. loop all players in radius 6 around event-block:
  302. set {_v} to ({_s} - distance between loop-player and event-block)
  303. play sound "block.anvil.place" with volume {_v} and pitch 0 to loop-player
  304. delete {anvil.%location of event-block%}
  305. delete {anvil.%location of event-block%.tier}
  306. loop entities in radius 1 around event-block:
  307. if type of loop-entity is armor stand:
  308. kill loop-entity
  309.  
  310.  
  311. on inventory click:
  312. if type of clicked inventory is chest inventory:
  313. if inventory name of player's current inventory is "&8Anvil":
  314. cancel event
  315.  
  316. else if inventory name of player's current inventory is "&8Furnace I":
  317. cancel event
  318. if clicked slot is set:
  319. if clicked item is not air:
  320. set {_item} to player's cursor slot
  321. if {_item} is not air:
  322. if name of clicked item is "&a&lOre":
  323. if canSmelt({_item}, 1):
  324. set slot (clicked slot) of player's current inventory to {_item}
  325.  
  326. else if name of clicked item is "&a&lFuel":
  327. if getFuelingTime({_item}) > 0:
  328. set slot (clicked slot) of player's current inventory to {_item}
  329.  
  330. #ore type
  331. #fuel type
  332.  
  333. # on inventory drag?
  334. # fuel/ore uit cursor slot verwijderen
  335. # fuel/ore uit inventory halen
  336. # fuel/ore opslaan
  337.  
  338.  
  339. on inventory close:
  340. if {inventory.%player%.name} is set:
  341. remove player from {inventoryList.%{inventory.%player%.current}%.%{inventory.%player%.name}%::*}
  342. delete {inventory.%player%.name}
  343. delete {inventory.%player%.current}
  344.  
  345. #Cancel in crafting table or below
  346. #register new shaped recipe for air using iron ingot, air, iron ingot, iron ingot, chest, iron ingot, air, iron ingot, air
  347.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement