Advertisement
Zeldaboy111

Bugfixes ]|[ Skript #352

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