Advertisement
Zeldaboy111

Furnace Progress Bar ]|[ Skript #351

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