Advertisement
Zeldaboy111

Fuel functie ]|[ Skript #348

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