Zeldaboy111

Hammer, Bend, Cool ]|[ Skript #371

Dec 10th, 2020
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 64.82 KB | None | 0 0
  1. #requires: SkQuery, SkRayFall, Skellett, SkBee, TuSKe
  2.  
  3.  
  4. options:
  5. logo: &6&lBS&8:&7
  6. tier1Furnace: "&8Furnace I"
  7.  
  8. command /blacksmith [<text>] [<text>]:
  9. aliases: /bs
  10. trigger:
  11. if player has permission "blacksmith":
  12. if arg-1 is not set:
  13. send "{@logo} Incorrect usage! &e/blacksmith advanced <true | false>&7."
  14. else if arg-1 is "advanced":
  15. if arg-2 is "true" or "enable":
  16. if {blacksmith.advancedMode} is true:
  17. send "{@logo} The &eadvanced mode &7is already enabled."
  18. else:
  19. set {blacksmith.advancedMode} to true
  20. send "{@logo} You have enabled the &eadvanced mode&7!"
  21. else if arg-2 is "false" or "enable":
  22. if {blacksmith.advancedMode} is false:
  23. send "{@logo} The &eadvanced mode &7is already disabled."
  24. else:
  25. set {blacksmith.advancedMode} to false
  26. send "{@logo} You have disabled the &eadvanced mode&7!"
  27. else:
  28. send "{@logo} Incorrect usage! &e/blacksmith advanced <true | false>&7."
  29. else:
  30. send "{@logo} You do not have enough permissions to do this!"
  31.  
  32.  
  33.  
  34.  
  35.  
  36.  
  37. function outlineGui(p: Player):
  38. loop 9 times:
  39. set slot loop-value - 1 of {_p}'s current inventory to gray stained glass pane named "&8"
  40. set slot 54-loop-value of {_p}'s current inventory to gray stained glass pane named "&8"
  41.  
  42. loop 5 times:
  43. set slot loop-value * 9 of {_p}'s current inventory to gray stained glass pane named "&8"
  44. set slot loop-value * 9-1 of {_p}'s current inventory to gray stained glass pane named "&8"
  45.  
  46. function openGuiOutlined(p: Player, loc: Location, rows: integer, name: String):
  47. open chest with {_rows} rows named {_name} to {_p}
  48. set {inventory.%{_p}%.name} to uncolored {_name}
  49. set {inventory.%{_p}%.current} to {_loc}
  50. add {_p} to {inventoryList.%{_loc}%.%{inventory.%{_p}%.name}%::*}
  51. wait 2 ticks
  52. outlineGui({_p})
  53.  
  54. function openAnvilGui(p: Player):
  55. if {anvil.current.%{_p}%} is 1:
  56. open chest with 6 rows named "Anvil Tier I" to {_p}
  57. wait 2 ticks
  58. outlineGui({_p})
  59.  
  60. set slot 12 of {_p}'s current inventory to golden helmet named "&6Golden Helmet" with lore "&8" and "&7Cost&8: &e5 Gold Ingot" without any NBT
  61. set slot 21 of {_p}'s current inventory to golden chestplate named "&6Golden Chestplate" with lore "&8" and "&7Cost&8: &e8 Gold Ingot" without any NBT
  62. set slot 30 of {_p}'s current inventory to golden leggings named "&6Golden Leggings" with lore "&8" and "&7Cost&8: &e7 Gold Ingot" without any NBT
  63. set slot 39 of {_p}'s current inventory to golden boots named "&6Golden Boots" with lore "&8" and "&7Cost&8: &e4 Gold Ingot" without any NBT
  64.  
  65. set slot 14 of {_p}'s current inventory to chainmail helmet named "&fChain Helmet" with lore "&8" and "&7Cost&8: &75 Iron Nugget" without any NBT
  66. set slot 23 of {_p}'s current inventory to chainmail chestplate named "&fChain Chestplate" with lore "&8" and "&7Cost&8: &78 Iron Nugget" without any NBT
  67. set slot 32 of {_p}'s current inventory to chainmail leggings named "&fChain Leggings" with lore "&8" and "&7Cost&8: &77 Iron Nugget" without any NBT
  68. set slot 41 of {_p}'s current inventory to chainmail boots named "&fChain Boots" with lore "&8" and "&7Cost&8: &74 Iron Nugget" without any NBT
  69.  
  70. #else if {anvil.curent.%{_p}%} is 2:
  71.  
  72. #else if {anvil.current.%{_p}%} is 3:
  73.  
  74. #advanced mode = short minigame / extra work to do whilst smithing weapons / tools
  75.  
  76.  
  77.  
  78. # U T I L I T I E S
  79.  
  80. function getNextNumber(base: number, addToDefault: number, max: number) :: number:
  81. set {_value} to {_base} + {_addToDefault}
  82. if {_value} > {_max}:
  83. set {_value} to {_addToDefault} - ({_max} - {_base})
  84.  
  85. return {_value}
  86.  
  87. function detectStair(facing: number, loc: Location, startValue: String) :: boolean:
  88. set {_list::*} to "westward red brick stair", "red brick stair", "eastward red brick stair" and "southward red brick stair"
  89. set {_dir} to {_facing}/2 + 1
  90.  
  91. if {_dir} > 4:
  92. remove 4 from {_dir}
  93.  
  94. if "%block at location of {_loc}%" is "%{_startValue}%%{_list::%{_dir}%}%":
  95. return true
  96. return false
  97.  
  98. function setItemInSlot(p: Player, type: String, slot: number, clickedItem: Item, item: Item, startLoop: Boolean, leftClick: Boolean):
  99. if {_type} is "Ore" or "Fuel" or "Ingot":
  100. set {_typeLower} to {_type} in lower case
  101. if {_leftClick} is false:
  102. if {furnace1.%{inventory.%{_p}%.current}%.contents.%{_typeLower}%} >= 64:
  103. stop
  104. add 1 to {furnace1.%{inventory.%{_p}%.current}%.contents.%{_typeLower}%}
  105. set {furnace1.%{inventory.%{_p}%.current}%.contents.%{_typeLower}%Type} to "%type of {_item}%"
  106. set {_item} to "%item amount of {_item}-1% %type of {_item}%"
  107. else:
  108. if {furnace1.%{inventory.%{_p}%.current}%.contents.%{_typeLower}%} >= 64:
  109. stop
  110. if {furnace1.%{inventory.%{_p}%.current}%.contents.%{_typeLower}%} + item amount of {_item} > 64:
  111. set {_item} to "%(item amount of {_item} - (64 - {furnace1.%{inventory.%{_p}%.current}%.contents.%{_typeLower}%}))% %type of {_item}%"
  112. set {furnace1.%{inventory.%{_p}%.current}%.contents.%{_typeLower}%} to 64
  113. set {_p}'s cursor to ("%{_item}%" parsed as an item)
  114. else:
  115. add item amount of {_item} to {furnace1.%{inventory.%{_p}%.current}%.contents.%{_typeLower}%}
  116. set {furnace1.%{inventory.%{_p}%.current}%.contents.%{_typeLower}%Type} to "%type of {_item}%"
  117. set {_item} to air
  118.  
  119. set {_typeId} to 2
  120. set {_typeString} to " II"
  121. if {inventory.%{_p}%.name} is uncolored {@tier1Furnace}:
  122. set {_typeId} to 1
  123. set {_typeString} to " I"
  124.  
  125. set {_p}'s cursor to ("%{_item}%" parsed as an item)
  126. updateItemInSlot({inventory.%{_p}%.current}, {_type}, {_slot}, {_typeString}, {_typeId})
  127. if {_startLoop}:
  128. if {furnace.%{inventory.%{_p}%.current}%.isAddedToLoop} is not true:
  129. add {inventory.%{_p}%.current} to {furnace1.loopList::*}
  130. loop_furnace1()
  131.  
  132. # F U R N A C E D E T E C T S
  133.  
  134. function isFurnace1(below: Location) :: boolean:
  135. if block at {_below} is campfire:
  136. set {_xAdjust::*} to 1, 1, 1, 0, 0, -1, -1 and -1
  137. set {_zAdjust::*} to 1, 0, -1, 1, -1, 1, 0 and -1
  138. loop 8 times:
  139. 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}
  140. if block at {_checkLoc} is not red brick block:
  141. return false
  142. else:
  143. return false
  144. return true
  145.  
  146.  
  147. function isFurnace2(loc: Location) :: boolean:
  148. if block at {_loc} is not blast furnace:
  149. return false
  150.  
  151. set {_layer1::*} to air, brick slab, red brick block, air, red brick block, air, red brick block and brick slab
  152. set {_layer2::*} to air, red brick stair, eastward red brick stair and southward red brick stair
  153. set {_x::*} to 1, 1, 0, -1, -1, -1, 0 and 1
  154. set {_z::*} to 0, 1, 1, 1, 0, -1, -1 and -1
  155.  
  156. set {_base} to -2
  157. 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}:
  158. set {_base} to 0
  159.  
  160. 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}:
  161. set {_base} to 2
  162.  
  163. 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}:
  164. set {_base} to 4
  165.  
  166. 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}:
  167. set {_base} to 6
  168.  
  169. set {_size} to size of {_x::*}
  170. if {_base} is not -2:
  171. loop 7 times:
  172. set {_value} to getNextNumber({_base}, loop-value, {_size})
  173. 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%}:
  174. return false
  175.  
  176.  
  177. set {_facingAdjust::*} to 0, 4, 6 and 8
  178. if detectStair({_base}, location 1 meters above {_loc}, "top "):
  179. loop 4 times:
  180. set {_value} to getNextNumber({_base}, loop-value*2, {_size}) - 1
  181. 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}
  182. set {_facing} to {_base}
  183. if {_facing} - {_facingAdjust::%loop-value%} >= 2:
  184. remove {_facingAdjust::%loop-value%} from {_facing}
  185. else:
  186. add {_facingAdjust::%loop-value%} to {_facing}
  187.  
  188. if loop-value is 1:
  189. if block at {_check} is not {_layer2::%loop-value%}:
  190. return false
  191. else if detectStair({_facing} - 2, {_check}, "") is false:
  192. return false
  193.  
  194. if block at location 2 meters above {_loc} is not red brick block:
  195. return false
  196. else:
  197. return false
  198. else:
  199. return false
  200. return true
  201.  
  202. function getRecipeItemFromType(type: String) :: item:
  203. if {_type} is "chain":
  204. return "iron nugget" parsed as an item
  205. else if {_type} is "diamond":
  206. return "diamond" parsed as an item
  207. return "%{_type}% ingot" parsed as an item
  208.  
  209. function tryCraftArmour(player: Player, type: String, piece: String):
  210. set {_result} to "%{_type}% %{_piece}%" parsed as an item
  211. set {_recipeItem} to "air" parsed as an item
  212. set {_recipeAmount} to 0
  213. if {_player}'s gamemode is survival or adventure:
  214. set {_recipeItem} to getRecipeItemFromType({_type})
  215. set {_recipeAmount} to {blacksmith.cost.%{_piece}%}
  216. set {_recipeAmountFromPlayer} to amount of {_recipeItem} in {_player}'s inventory
  217. if {_recipeAmountFromPlayer} < {_recipeAmount}:
  218. play "ENTITY_ITEM_BREAK" to {_player} at volume 10
  219. stop
  220.  
  221. else if {_player}'s gamemode is spectator:
  222. stop
  223. if {blacksmith.advancedMode} is false:
  224. give {_result} to {_player}
  225. remove {_recipeAmount} of {_recipeItem} from {_player}'s inventory
  226. play sound "block.anvil.use" with volume 10 and pitch 1 to {_player}
  227. else:
  228. playBlacksmithMinigame({_player}, {_recipeItem}, {_recipeAmount}, {_result})
  229.  
  230. function playBlacksmithMinigame(player: Player, costItem: Item, cost: Number, result: Item):
  231. set {blacksmith.smithing.%{_player}%.costItem} to {_costItem}
  232. set {blacksmith.smithing.%{_player}%.cost} to {_cost}
  233. set {blacksmith.smithing.%{_player}%.result} to {_result}
  234. set {blacksmith.smithing.%{_player}%.chainmail} to false
  235. set {blacksmith.smithing.%{_player}%.stage} to 0
  236.  
  237. open chest with 6 rows named "Smithing" to {_player}
  238. outlineGui({_player})
  239. set {_result1} to "%type of {_result}%"
  240. if {_result1} contains "chain":
  241. set {inventory.%{_player}%.name} to uncolored "Smithing"
  242. set {blacksmith.smithing.%{_player}%.chainmail} to true
  243. set {_random::*} to 39 and 41
  244. set {_slot} to random element out of {_random::*}
  245. remove {_slot} from {_random::*}
  246. set {_slot1} to random element out of {_random::*}
  247.  
  248. set slot {_slot} of {_player}'s current inventory to iron nugget named "&fCreate Rings"
  249. set slot {_slot1} of {_player}'s current inventory to iron hoe named "&fJoin Rings" without any NBT
  250. set slot 22 of {_player}'s current inventory to iron nugget named "&a&lCreate Rings" with lore "&7", "&7Click the corresponding item" and "&7to continue crafting."
  251. set slot 13 of {_player}'s current inventory to {_result} named "&f&n%first character of {_result1} in upper case%%last (length of {_result1}-1) characters of {_result1} in lower case%" without any NBT
  252. else:
  253. setSmithingGui({_player})
  254.  
  255. function setSmithingGui(player: Player):
  256. set {blacksmith.smithing.%{_player}%.chainmail} to false
  257. set {blacksmith.smithing.%{_player}%.stage} to 0
  258. set {inventory.%{_player}%.name} to uncolored "Smithing II"
  259.  
  260. open chest with 6 rows named "Smithing" to {_player}
  261. outlineGui({_player})
  262. set {_result1} to "%type of {blacksmith.smithing.%{_player}%.result}%"
  263. set slot 22 of {_player}'s current inventory to iron ingot named "&a&lHammer" with lore "&7", "&7Click the corresponding item" and "&7to continue crafting."
  264. set slot 13 of {_player}'s current inventory to {blacksmith.smithing.%{_player}%.result} named "&f&n%first character of {_result1} in upper case%%last (length of {_result1}-1) characters of {_result1} in lower case%" without any NBT
  265.  
  266. set {_random::*} to 38, 40 and 42
  267. set {_slot} to random element out of {_random::*}
  268. remove {_slot} from {_random::*}
  269. set {_slot1} to random element out of {_random::*}
  270. remove {_slot1} from {_random::*}
  271. set {_slot2} to random element out of {_random::*}
  272.  
  273. set slot {_slot} of {_player}'s current inventory to iron ingot named "&a&lBend" without any NBT
  274. set slot {_slot1} of {_player}'s current inventory to iron axe named "&a&lHammer" without any NBT
  275. set slot {_slot2} of {_player}'s current inventory to water bucket named "&a&lCool" without any NBT
  276.  
  277.  
  278. function removeItemFromPlayer(player: Player, item: Item, amount: Number):
  279. if {_amount} > 0:
  280. if {_item} is set:
  281. if gamemode of {_player} is survival or adventure:
  282. remove "%{_amount}% %{_item}%" parsed as an item from {_player}'s inventory
  283.  
  284.  
  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. set {anvil.current.%player%} to 1
  292. openAnvilGui(player)
  293. cancel event
  294.  
  295. on rightclick on cauldron:
  296. if {furnace.%location of event-block%} is true:
  297. if isFurnace1(location 1 meters below clicked block):
  298. cancel event
  299. guiFurnace1(player, location of clicked block)
  300.  
  301. else:
  302. delete {furnace1.%location of clicked block%.contents.fuel}
  303. delete {furnace1.%location of clicked block%.contents.ore}
  304. delete {furnace1.%location of clicked block%.contents.ingot}
  305. delete {furnace.%location of event-block%}
  306.  
  307. on rightclick on blast furnace:
  308. if {furnace2.%location of event-block%} is true:
  309. if isFurnace2(location of clicked block):
  310. cancel event
  311. send "WIP"
  312. else:
  313. delete {furnace2.%location of event-block%}
  314.  
  315. on rightclick holding stone axe:
  316. if clicked block is smooth stone or iron block or diamond block:
  317. if {anvil.%location of event-block%} is not true:
  318. set {anvil.%location of event-block%} to true
  319. set {_tier} to "Tier I"
  320. if clicked block is smooth stone:
  321. set {anvil.%location of event-block%.tier} to 1
  322. else if clicked block is iron block:
  323. set {anvil.%location of event-block%.tier} to 2
  324. set {_tier} to "Tier II"
  325. else:
  326. set {anvil.%location of event-block%.tier} to 3
  327. set {_tier} to "Tier III"
  328.  
  329. set {_s} to 6
  330. loop all players in radius 6 around event-block:
  331. set {_v} to ({_s} - distance between loop-player and event-block)
  332. play sound "block.anvil.place" with volume {_v} and pitch 0 to loop-player
  333.  
  334. send "{@logo} Successfully created an anvil of %{_tier}%."
  335. summon armor stand at location 0.6 meters below event-block
  336. set name of last spawned armor stand to "&7Anvil"
  337. add "{Invisible:1b,NoGravity:1b,NoAI:1b,CustomNameVisible:1}" to NBT of last spawned armor stand
  338.  
  339. summon armor stand at location 0.9 meters below event-block
  340. set name of last spawned armor stand to "&7%{_tier}%"
  341. add "{Invisible:1b,NoGravity:1b,NoAI:1b,CustomNameVisible:1}" to NBT of last spawned armor stand
  342.  
  343. else if clicked block is cauldron:
  344. if {furnace.%location of event-block%} is not true:
  345. if isFurnace1(location 1 meters below clicked block):
  346. set {furnace.%location of event-block%} to true
  347. cancel event
  348.  
  349. else if clicked block is blast furnace:
  350. if {furnace.%location of event-block%} is not true:
  351. if isFurnace2(location of clicked block):
  352. set {furnace2.%location of event-block%} to true
  353. cancel event
  354. send "WIP"
  355.  
  356. on break of smooth stone or iron block or diamond block:
  357. if {anvil.%location of event-block%} is true:
  358. set {_s} to 6
  359. loop all players in radius 6 around event-block:
  360. set {_v} to ({_s} - distance between loop-player and event-block)
  361. play sound "block.anvil.place" with volume {_v} and pitch 0 to loop-player
  362. delete {anvil.%location of event-block%}
  363. delete {anvil.%location of event-block%.tier}
  364. loop entities in radius 1 around event-block:
  365. if type of loop-entity is armor stand:
  366. kill loop-entity
  367.  
  368.  
  369. on inventory click:
  370. if type of clicked inventory is chest inventory:
  371. if inventory name of player's current inventory is {@tier1Furnace}:
  372. cancel event
  373. if clicked slot is set:
  374. if clicked item is not air:
  375. set {_item} to player's cursor slot
  376. set {_leftClick} to false
  377. if click type is left mouse button:
  378. set {_leftClick} to true
  379. if {_item} is not air:
  380. if name of clicked item is "&a&lOre":
  381. if canSmelt({_item}, 1):
  382. if canSmeltInFurnace(player, {_item}):
  383. setItemInSlot(player, "Ore", clicked slot, clicked item, {_item}, true, {_leftClick})
  384. else if name of clicked item is "&a&lFuel":
  385. if getFuelingTime({_item}) > 0:
  386. setItemInSlot(player, "Fuel", clicked slot, clicked item, {_item}, true, {_leftClick})
  387. else if getFuelingTime(clicked item) > 0:
  388. if getFuelingTime({_item}) > 0:
  389. setItemInSlot(player, "Fuel", clicked slot, clicked item, {_item}, false, {_leftClick})
  390. else if canSmelt(clicked item, 1) is true:
  391. if canSmelt({_item}, 1):
  392. if canSmeltInFurnace(player, {_item}):
  393. setItemInSlot(player, "Ore", clicked slot, clicked item, {_item}, false, {_leftClick})
  394. else if clicked slot is 42:
  395. if type of clicked item is not lime stained glass pane:
  396. updateItemAndRemoveFromLoop(player, clicked item, clicked slot, 1, " I", "Ingot", {_leftClick})
  397. else if getFuelingTime(clicked item) > 0:
  398. updateItemAndRemoveFromLoop(player, clicked item, clicked slot, 1, " I", "Fuel", {_leftClick})
  399. else if canSmelt(clicked item, 1) is true:
  400. updateItemAndRemoveFromLoop(player, clicked item, clicked slot, 1, " I", "Ore", {_leftClick})
  401.  
  402. else if inventory name of player's current inventory is "Anvil Tier I":
  403. cancel event
  404. if clicked slot is set:
  405. if clicked item is any helmet, any chestplate, any leggings or any boots:
  406. set {_item::*} to ("%type of clicked item%") split at " "
  407. tryCraftArmour(player, {_item::1}, {_item::2})
  408.  
  409. else if inventory name of player's current inventory is "Smithing":
  410. cancel event
  411. if clicked slot is set:
  412. if {blacksmith.smithing.%{_player}%.chainmail} is true:
  413. if clicked item is iron nugget:
  414. if {blacksmith.smithing.%player%.stage} is 0:
  415. add 1 to {blacksmith.smithing.%player%.stage}
  416. set slot 22 of player's current inventory to iron hoe named "&a&lJoin Rings" with lore "&7", "&7Click the corresponding item" and "&7to continue crafting." without any NBT
  417. play sound "entity.item.pickup" with volume 12 and pitch 2 to player
  418. else:
  419. removeItemFromPlayer(player, iron nugget, {blacksmith.smithing.%player%.cost})
  420. play sound "entity.item.break" with volume 10 and pitch 1 to player
  421. close player's inventory
  422.  
  423. else if clicked item is iron hoe:
  424. if {blacksmith.smithing.%player%.stage} is 1:
  425. add 1 to {blacksmith.smithing.%player%.stage}
  426. play sound "block.anvil.land" with volume 10 and pitch 1 to player
  427. setSmithingGui(player)
  428. else:
  429. removeItemFromPlayer(player, iron nugget, {blacksmith.smithing.%player%.cost})
  430. play sound "entity.item.break" with volume 10 and pitch 1 to player
  431. close player's inventory
  432. else:
  433. if clicked item is iron ingot:
  434. if {blacksmith.smithing.%player%.stage} is 0 or 2:
  435. play sound "block.anvil.use" with volume 12 and pitch 2 to player
  436. if {blacksmith.smithing.%player%.stage} is 0:
  437. set slot 22 of player's current inventory to iron axe named "&a&lBend" with lore "&7", "&7Click the corresponding item" and "&7to continue crafting."
  438. else:
  439. set slot 22 of player's current inventory to water bucket named "&a&lCool" with lore "&7", "&7Click the corresponding item" and "&7to continue crafting."
  440. add 1 to {blacksmith.smithing.%player%.stage}
  441.  
  442.  
  443. else if clicked item is iron axe:
  444. if {blacksmith.smithing.%player%.stage} is 1:
  445. add 1 to {blacksmith.smithing.%player%.stage}
  446. play sound "block.anvil.use" with volume 12 and pitch 2 to player
  447. set slot 22 of player's current inventory to iron axe named "&a&lHammer" with lore "&7", "&7Click the corresponding item" and "&7to continue crafting." without any NBT
  448. else if clicked item is water bucket:
  449. if {blacksmith.smithing.%player%.stage} is 3:
  450. play sound "block.anvil.land" with volume 12 and pitch 2 to player
  451.  
  452.  
  453. on inventory close:
  454. if {inventory.%player%.name} is set:
  455. remove player from {inventoryList.%{inventory.%player%.current}%.%{inventory.%player%.name}%::*}
  456. delete {inventory.%player%.name}
  457. delete {inventory.%player%.current}
  458. else if {anvil.current.%player%} is set:
  459. delete {anvil.current.%player%}
  460.  
  461. on inventory drag:
  462. set {_tier1} to uncolored {@tier1Furnace}
  463. if {inventory.%player%.name} is "Anvil" or "%{_tier1}%" or "Furnace II":
  464. cancel event
  465. else if {anvil.current.%player%} is set:
  466. cancel event
  467.  
  468. on craft:
  469. if event-item is any helmet, any chestplate, any leggings or any boots:
  470. if "%event-item%" doesn't start with "leather":
  471. send "{@logo} You cannot craft this item in a crafting table!"
  472. cancel event
  473.  
  474. #|=============================================================|
  475. #| ______ _ _ _____ _ _ _____ ______ |
  476. #| | ____| | | | __ \| \ | | /\ / ____| ____| |
  477. #| | |__ | | | | |__) | \| | / \ | | | |__ |
  478. #| | __| | | | | _ /| . ` | / /\ \| | | __| |
  479. #| | | | |__| | | \ \| |\ |/ ____ \ |____| |____ |
  480. #| |_| \____/|_| \_\_| \_/_/ \_\_____|______| |
  481. #| |
  482. #|=============================================================|
  483.  
  484. function guiFurnace1(p: Player, loc: Location):
  485. openGuiOutlined({_p}, {_loc}, 6, {@tier1Furnace})
  486.  
  487. if {furnace1.%{_loc}%.contents.fuel} is not set:
  488. set {furnace1.%{_loc}%.contents.fuel} to 0
  489. if {furnace1.%{_loc}%.contents.ore} is not set:
  490. set {furnace1.%{_loc}%.contents.ore} to 0
  491. if {furnace1.%{_loc}%.contents.ingot} is not set:
  492. set {furnace1.%{_loc}%.contents.ingot} to 0
  493.  
  494. if {furnace1.%{_loc}%.contents.ingotType} is not set:
  495. set {furnace1.%{_loc}%.contents.ingot} to 0
  496. if {furnace1.%{_loc}%.contents.oreType} is not set:
  497. set {furnace1.%{_loc}%.contents.ore} to 0
  498. if {furnace1.%{_loc}%.contents.fuelType} is not set:
  499. set {furnace1.%{_loc}%.contents.fuel} to 0
  500.  
  501. set {furnace1.%{_loc}%.fuelingTimeMax} to 0
  502. if {furnace1.%{_loc}%.contents.fuelType} is set:
  503. set {furnace1.%{_loc}%.fuelingTimeMax} to getFuelingTime({furnace1.%{_loc}%.contents.fuelType}) / 20
  504.  
  505. set slot 38 of {_p}'s current inventory to lime stained glass pane named "&a&lOre"
  506. set slot 40 of {_p}'s current inventory to lime stained glass pane named "&a&lFuel"
  507. set slot 42 of {_p}'s current inventory to lime stained glass pane named "&a&lIngot"
  508.  
  509. if {furnace1.%{_loc}%.contents.ore} > 0:
  510. set slot 38 of {_p}'s current inventory to ("%{furnace1.%{_loc}%.contents.ore}% %{furnace1.%{_loc}%.contents.oreType}%" parsed as an item)
  511.  
  512. if {furnace1.%{_loc}%.contents.fuel} > 0:
  513. set slot 40 of {_p}'s current inventory to ("%{furnace1.%{_loc}%.contents.fuel}% %{furnace1.%{_loc}%.contents.fuelType}%" parsed as an item)
  514.  
  515. if {furnace1.%{_loc}%.contents.ingot} > 0:
  516. set slot 42 of {_p}'s current inventory to ("%{furnace1.%{_loc}%.contents.ingot}% %{furnace1.%{_loc}%.contents.ingotType}%" parsed as an item)
  517.  
  518. loop 5 times:
  519. set slot 19 + loop-value of {_p}'s current inventory to gray stained glass pane named "&f%20*loop-value%%%"
  520.  
  521. set {_progressBar} to "%{furnace1.%{_loc}%.smeltTime}/2.0%"
  522. if {_progressBar} contains ".":
  523. set {_progressBar::*} to {_progressBar} split at "."
  524. set {_progressBar} to {_progressBar::1}
  525.  
  526. loop ({_progressBar} parsed as an integer) times:
  527. set slot 20+loop-value -1 of {_p}'s current inventory to lime stained glass pane named "&f%20*loop-value%%%"
  528.  
  529. function updateItemInSlot(furnaceId: Location, type: String, slot: Number, furnaceTier: String, typeId: integer):
  530. set {_typeLower} to {_type} in lower case
  531. loop {inventoryList.%{_furnaceId}%.furnace%{_furnaceTier}%::*}:
  532. 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)
  533. if {furnace%{_typeId}%.%{_furnaceId}%.contents.%{_typeLower}%} <= 0:
  534. set slot {_slot} of loop-value's current inventory to lime stained glass pane named "&a&l%{_type}%"
  535.  
  536. function updateItemAndRemoveFromLoop(p: Player, item: Item, slot: Number, furnaceTier: Integer, furnaceTierString: String, itemName: String, leftClick: Boolean):
  537. set {_nameLower} to {_itemName} in lower case
  538. set {_amount} to {furnace1.%{inventory.%{_p}%.current}%.contents.%{_nameLower}%}
  539. set {_removedAmount} to {_amount}
  540. if {_leftClick} is false:
  541. set {_removedAmount} to "%{_amount} / 2%" parsed as an integer
  542. if {_removedAmount} is {_amount}:
  543. set {_removedAmount} to 1
  544. add "%({_amount}-1) / 2%" parsed as an integer to {_removedAmount}
  545. set {_item} to "%{_amount} - {_removedAmount} + 1% %type of {_item}%" parsed as an item
  546. else:
  547. set {_item} to "%{_amount} - {_removedAmount}% %type of {_item}%" parsed as an item
  548.  
  549. set {_p}'s cursor slot to {_item}
  550. set {furnace1.%{inventory.%{_p}%.current}%.contents.%{_nameLower}%} to {_amount}-{_removedAmount}
  551. if {_amount}-{_removedAmount} <= 0:
  552. delete {furnace1.%{inventory.%{_p}%.current}%.contents.%{_nameLower}%Type}
  553. set slot ({_slot}) of {_p}'s current inventory to lime stained glass pane named "&a&l%{_itemName}%"
  554. if {_nameLower} is "ore" or "fuel":
  555. resetFuelIndicator({inventory.%{_p}%.current}, {_furnaceTierString})
  556. else:
  557. set slot ({_slot}) of {_p}'s current inventory to "%{_amount}-{_removedAmount}% %{furnace1.%{inventory.%{_p}%.current}%.contents.%{_nameLower}%Type}%" parsed as an item
  558.  
  559.  
  560. function updateInventoryFuelIndicator(furnaceId: Location, progressBar: Integer, furnaceTier: String):
  561. if {_progressBar} <= 4:
  562. if {_progressBar} >= 0:
  563. loop {inventoryList.%{_furnaceId}%.furnace%{_furnaceTier}%::*}:
  564. set slot 20+{_progressBar} of loop-value's current inventory to gray stained glass pane named "&f%20*({_progressBar}+1)%%%"
  565. if {_progressBar} > 0:
  566. set slot 20+{_progressBar}-1 of loop-value's current inventory to lime stained glass pane named "&f%20*{_progressBar}%%%"
  567. loop 4-{_progressBar} times:
  568. 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)%%%"
  569.  
  570. function resetFuelIndicator(furnaceId: Location, furnaceTier: String):
  571. set {furnace1.%{_furnaceId}%.smeltTime} to 0
  572. loop {inventoryList.%{_furnaceId}%.furnace%{_furnaceTier}%::*}:
  573. loop 5 times:
  574. set slot 19 + loop-value-2 of loop-value-1's current inventory to gray stained glass pane named "&f%20*loop-value-2%%%"
  575. if {_furnaceTier} is " I":
  576. removeFurnaceFromLoop({_furnaceId}, 1)
  577. else:
  578. removeFurnaceFromLoop({_furnaceId}, 2)
  579.  
  580. function setIngotType(furnaceId: Location, tier: Number):
  581. delete {furnace%{_tier}%.%{_furnaceId}%.contents.ingotType}
  582. if {furnace%{_tier}%.%{_furnaceId}%.contents.ingotType} is set:
  583. stop
  584. set {_type} to "%{furnace%{_tier}%.%{_furnaceId}%.contents.oreType}%"
  585. if {_tier} is 2:
  586. if {_type} is "diamond ore", "emerald ore" or "nether quartz ore":
  587. replace all " ore" in {_type} with " ingot"
  588. {furnace%{_tier}%.%{_furnaceId}%.contents.ingotType}
  589. stop
  590. if "%{_type}%" is "iron ore", "gold ore", "lapis ore" or "redstone ore":
  591. replace "ore" in {_type} with "ingot"
  592. set {furnace%{_tier}%.%{_furnaceId}%.contents.ingotType} to {_type} parsed as an item
  593. else if {_type} is "coal ore":
  594. set {furnace%{_tier}%.%{_furnaceId}%.contents.ingotType} to coal
  595.  
  596. function removeFurnaceFromLoop(furnaceId: Location, typeId: integer):
  597. delete {furnace.%{_furnaceId}%.isAddedToLoop}
  598. remove {_furnaceId} from {furnace%{_typeId}%.loopList::*}
  599.  
  600.  
  601. function loop_furnace1():
  602. set {furnace1.looping} to false
  603. if {furnace1.looping} is not true:
  604. set {furnace1.looping} to true
  605. while {furnace1.looping} is true:
  606. if size of {furnace1.loopList::*} is 0:
  607. set {furnace1.looping} to false
  608. stop loop
  609. else:
  610. loop {furnace1.loopList::*}:
  611. if {furnace1.%loop-value%.contents.ore} < 1:
  612. updateInventoryFuelIndicator(loop-value, 0, " I")
  613. removeFurnaceFromLoop(loop-value, 1)
  614.  
  615. else:
  616. if {furnace1.%loop-value%.contents.fuelingTime} is not set:
  617. remove 1 from {furnace1.%loop-value%.contents.fuel}
  618. updateItemInSlot(loop-value, "Fuel", 40, " I", 1)
  619.  
  620. add 1 to {furnace1.%loop-value%.smeltTime}
  621. add 1 to {furnace1.%loop-value%.fuelingTime}
  622. if "%{furnace1.%loop-value%.smeltTime}/2.0%" doesn't contain ".":
  623. if {furnace1.%loop-value%.smeltTime}/2 > 4:
  624. updateInventoryFuelIndicator(loop-value, 0, " I")
  625. else:
  626. updateInventoryFuelIndicator(loop-value, "%{furnace1.%loop-value%.smeltTime}/2%" parsed as an integer, " I")
  627. if {furnace1.%loop-value%.smeltTime} > 9:
  628. delete {furnace1.%loop-value%.smeltTime}
  629. remove 1 from {furnace1.%loop-value%.contents.ore}
  630. add 1 to {furnace1.%loop-value%.contents.ingot}
  631. setIngotType(loop-value, 1)
  632. updateItemInSlot(loop-value, "Ore", 38, " I", 1)
  633. updateItemInSlot(loop-value, "Ingot", 42, " I", 1)
  634. updateInventoryFuelIndicator(loop-value, 0, " I")
  635.  
  636.  
  637. if {furnace1.%loop-value%.fuelingTime} >= {furnace1.%Loop-value%.fuelingTimeMax}:
  638. if {furnace1.%loop-value%.contents.fuel} <= 0:
  639. delete {furnace1.%loop-value%.smeltTime}
  640. removeFurnaceFromLoop(loop-value, 1)
  641. updateInventoryFuelIndicator(loop-value, 0, " I")
  642. else:
  643. delete {furnace1.%loop-value%.fuelingTime}
  644. wait 1 second
  645.  
  646. # Returns how many ticks an item gives fuel
  647. function getFuelingTime(type: Item) :: integer:
  648. if {_type} is lava:
  649. return 20000
  650. else if {_type} is block of coal:
  651. return 16000
  652. else if {_type} is dried kelp block:
  653. return 4000
  654. else if {_type} is blaze rod:
  655. return 2400
  656. else if {_type} is coal or charcoal:
  657. return 1600
  658. else if {_type} is any boat or scaffolding:
  659. return 1200
  660. 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:
  661. return 300
  662. 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:
  663. return 200
  664. else if {_type} is bowl or any sapling or stick or any wool:
  665. return 100
  666. else if {_type} is any carpet:
  667. return 67
  668. else if {_type} is bamboo:
  669. return 50
  670. return 0
  671.  
  672. # Returns if the item can be smelted in the furnace, every smelt takes 10 seconds in a normal furnace
  673. function canSmelt(type: Item, tier: Integer) :: boolean:
  674. if {_type} is iron ore or gold ore or lapis ore or redstone ore or coal ore:
  675. return true
  676. else if {_tier} is 2:
  677. if {_type} is diamond ore or emerald ore or nether quartz ore:
  678. return true
  679.  
  680. return false
  681.  
  682. function canSmeltInFurnace(p: Player, item: Item) :: boolean:
  683. set {_furnaceId} to {inventory.%{_p}%.current}
  684. if {furnace1.%{_furnaceId}%.contents.oreType} is set:
  685. if "%type of {_item}%" is not "%{furnace1.%{_furnaceId}%.contents.oreType}%":
  686. return false
  687. if {furnace1.%{_furnaceId}%.contents.ingotType} is set:
  688. send "true" to {_p}
  689. if type of {_item} is coal ore:
  690. if type of {furnace1.%{_furnaceId}%.contents.ingotType} is coal:
  691. return true
  692. set {_item} to "%type of {_item}%"
  693. replace all " ore" in {_item} with " ingot"
  694. if {_item} is not "%{furnace1.%{_furnaceId}%.contents.ingotType}%":
  695. return false
  696. return true
  697.  
  698.  
  699.  
  700.  
  701.  
  702. on disable:
  703. if {furnace1.looping} is true:
  704. set {furnace1.looping} to false
  705. set {furnace1.loopStopped} to true
  706.  
  707. on enable:
  708. set {blacksmith.cost.helmet} to 5
  709. set {blacksmith.cost.chestplate} to 8
  710. set {blacksmith.cost.leggings} to 7
  711. set {blacksmith.cost.boots} to 4
  712. if {blacksmith.advancedMode} is not set:
  713. set {blacksmith.advancedMode} to true
  714. wait 1 second
  715. if {furnace1.loopStopped} is true:
  716. set {furnace1.looping} to true
  717. set {furnace1.loopStopped} to false
  718. #requires: SkQuery, SkRayFall, Skellett, SkBee, TuSKe
  719.  
  720.  
  721. options:
  722. logo: &6&lBS&8:&7
  723. tier1Furnace: "&8Furnace I"
  724.  
  725. command /blacksmith [<text>] [<text>]:
  726. aliases: /bs
  727. trigger:
  728. if player has permission "blacksmith":
  729. if arg-1 is not set:
  730. send "{@logo} Incorrect usage! &e/blacksmith advanced <true | false>&7."
  731. else if arg-1 is "advanced":
  732. if arg-2 is "true" or "enable":
  733. if {blacksmith.advancedMode} is true:
  734. send "{@logo} The &eadvanced mode &7is already enabled."
  735. else:
  736. set {blacksmith.advancedMode} to true
  737. send "{@logo} You have enabled the &eadvanced mode&7!"
  738. else if arg-2 is "false" or "enable":
  739. if {blacksmith.advancedMode} is false:
  740. send "{@logo} The &eadvanced mode &7is already disabled."
  741. else:
  742. set {blacksmith.advancedMode} to false
  743. send "{@logo} You have disabled the &eadvanced mode&7!"
  744. else:
  745. send "{@logo} Incorrect usage! &e/blacksmith advanced <true | false>&7."
  746. else:
  747. send "{@logo} You do not have enough permissions to do this!"
  748.  
  749.  
  750.  
  751.  
  752.  
  753.  
  754. function outlineGui(p: Player):
  755. loop 9 times:
  756. set slot loop-value - 1 of {_p}'s current inventory to gray stained glass pane named "&8"
  757. set slot 54-loop-value of {_p}'s current inventory to gray stained glass pane named "&8"
  758.  
  759. loop 5 times:
  760. set slot loop-value * 9 of {_p}'s current inventory to gray stained glass pane named "&8"
  761. set slot loop-value * 9-1 of {_p}'s current inventory to gray stained glass pane named "&8"
  762.  
  763. function openGuiOutlined(p: Player, loc: Location, rows: integer, name: String):
  764. open chest with {_rows} rows named {_name} to {_p}
  765. set {inventory.%{_p}%.name} to uncolored {_name}
  766. set {inventory.%{_p}%.current} to {_loc}
  767. add {_p} to {inventoryList.%{_loc}%.%{inventory.%{_p}%.name}%::*}
  768. wait 2 ticks
  769. outlineGui({_p})
  770.  
  771. function openAnvilGui(p: Player):
  772. if {anvil.current.%{_p}%} is 1:
  773. open chest with 6 rows named "Anvil Tier I" to {_p}
  774. wait 2 ticks
  775. outlineGui({_p})
  776.  
  777. set slot 12 of {_p}'s current inventory to golden helmet named "&6Golden Helmet" with lore "&8" and "&7Cost&8: &e5 Gold Ingot" without any NBT
  778. set slot 21 of {_p}'s current inventory to golden chestplate named "&6Golden Chestplate" with lore "&8" and "&7Cost&8: &e8 Gold Ingot" without any NBT
  779. set slot 30 of {_p}'s current inventory to golden leggings named "&6Golden Leggings" with lore "&8" and "&7Cost&8: &e7 Gold Ingot" without any NBT
  780. set slot 39 of {_p}'s current inventory to golden boots named "&6Golden Boots" with lore "&8" and "&7Cost&8: &e4 Gold Ingot" without any NBT
  781.  
  782. set slot 14 of {_p}'s current inventory to chainmail helmet named "&fChain Helmet" with lore "&8" and "&7Cost&8: &75 Iron Nugget" without any NBT
  783. set slot 23 of {_p}'s current inventory to chainmail chestplate named "&fChain Chestplate" with lore "&8" and "&7Cost&8: &78 Iron Nugget" without any NBT
  784. set slot 32 of {_p}'s current inventory to chainmail leggings named "&fChain Leggings" with lore "&8" and "&7Cost&8: &77 Iron Nugget" without any NBT
  785. set slot 41 of {_p}'s current inventory to chainmail boots named "&fChain Boots" with lore "&8" and "&7Cost&8: &74 Iron Nugget" without any NBT
  786.  
  787. #else if {anvil.curent.%{_p}%} is 2:
  788.  
  789. #else if {anvil.current.%{_p}%} is 3:
  790.  
  791. #advanced mode = short minigame / extra work to do whilst smithing weapons / tools
  792.  
  793.  
  794.  
  795. # U T I L I T I E S
  796.  
  797. function getNextNumber(base: number, addToDefault: number, max: number) :: number:
  798. set {_value} to {_base} + {_addToDefault}
  799. if {_value} > {_max}:
  800. set {_value} to {_addToDefault} - ({_max} - {_base})
  801.  
  802. return {_value}
  803.  
  804. function detectStair(facing: number, loc: Location, startValue: String) :: boolean:
  805. set {_list::*} to "westward red brick stair", "red brick stair", "eastward red brick stair" and "southward red brick stair"
  806. set {_dir} to {_facing}/2 + 1
  807.  
  808. if {_dir} > 4:
  809. remove 4 from {_dir}
  810.  
  811. if "%block at location of {_loc}%" is "%{_startValue}%%{_list::%{_dir}%}%":
  812. return true
  813. return false
  814.  
  815. function setItemInSlot(p: Player, type: String, slot: number, clickedItem: Item, item: Item, startLoop: Boolean, leftClick: Boolean):
  816. if {_type} is "Ore" or "Fuel" or "Ingot":
  817. set {_typeLower} to {_type} in lower case
  818. if {_leftClick} is false:
  819. if {furnace1.%{inventory.%{_p}%.current}%.contents.%{_typeLower}%} >= 64:
  820. stop
  821. add 1 to {furnace1.%{inventory.%{_p}%.current}%.contents.%{_typeLower}%}
  822. set {furnace1.%{inventory.%{_p}%.current}%.contents.%{_typeLower}%Type} to "%type of {_item}%"
  823. set {_item} to "%item amount of {_item}-1% %type of {_item}%"
  824. else:
  825. if {furnace1.%{inventory.%{_p}%.current}%.contents.%{_typeLower}%} >= 64:
  826. stop
  827. if {furnace1.%{inventory.%{_p}%.current}%.contents.%{_typeLower}%} + item amount of {_item} > 64:
  828. set {_item} to "%(item amount of {_item} - (64 - {furnace1.%{inventory.%{_p}%.current}%.contents.%{_typeLower}%}))% %type of {_item}%"
  829. set {furnace1.%{inventory.%{_p}%.current}%.contents.%{_typeLower}%} to 64
  830. set {_p}'s cursor to ("%{_item}%" parsed as an item)
  831. else:
  832. add item amount of {_item} to {furnace1.%{inventory.%{_p}%.current}%.contents.%{_typeLower}%}
  833. set {furnace1.%{inventory.%{_p}%.current}%.contents.%{_typeLower}%Type} to "%type of {_item}%"
  834. set {_item} to air
  835.  
  836. set {_typeId} to 2
  837. set {_typeString} to " II"
  838. if {inventory.%{_p}%.name} is uncolored {@tier1Furnace}:
  839. set {_typeId} to 1
  840. set {_typeString} to " I"
  841.  
  842. set {_p}'s cursor to ("%{_item}%" parsed as an item)
  843. updateItemInSlot({inventory.%{_p}%.current}, {_type}, {_slot}, {_typeString}, {_typeId})
  844. if {_startLoop}:
  845. if {furnace.%{inventory.%{_p}%.current}%.isAddedToLoop} is not true:
  846. add {inventory.%{_p}%.current} to {furnace1.loopList::*}
  847. loop_furnace1()
  848.  
  849. # F U R N A C E D E T E C T S
  850.  
  851. function isFurnace1(below: Location) :: boolean:
  852. if block at {_below} is campfire:
  853. set {_xAdjust::*} to 1, 1, 1, 0, 0, -1, -1 and -1
  854. set {_zAdjust::*} to 1, 0, -1, 1, -1, 1, 0 and -1
  855. loop 8 times:
  856. 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}
  857. if block at {_checkLoc} is not red brick block:
  858. return false
  859. else:
  860. return false
  861. return true
  862.  
  863.  
  864. function isFurnace2(loc: Location) :: boolean:
  865. if block at {_loc} is not blast furnace:
  866. return false
  867.  
  868. set {_layer1::*} to air, brick slab, red brick block, air, red brick block, air, red brick block and brick slab
  869. set {_layer2::*} to air, red brick stair, eastward red brick stair and southward red brick stair
  870. set {_x::*} to 1, 1, 0, -1, -1, -1, 0 and 1
  871. set {_z::*} to 0, 1, 1, 1, 0, -1, -1 and -1
  872.  
  873. set {_base} to -2
  874. 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}:
  875. set {_base} to 0
  876.  
  877. 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}:
  878. set {_base} to 2
  879.  
  880. 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}:
  881. set {_base} to 4
  882.  
  883. 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}:
  884. set {_base} to 6
  885.  
  886. set {_size} to size of {_x::*}
  887. if {_base} is not -2:
  888. loop 7 times:
  889. set {_value} to getNextNumber({_base}, loop-value, {_size})
  890. 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%}:
  891. return false
  892.  
  893.  
  894. set {_facingAdjust::*} to 0, 4, 6 and 8
  895. if detectStair({_base}, location 1 meters above {_loc}, "top "):
  896. loop 4 times:
  897. set {_value} to getNextNumber({_base}, loop-value*2, {_size}) - 1
  898. 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}
  899. set {_facing} to {_base}
  900. if {_facing} - {_facingAdjust::%loop-value%} >= 2:
  901. remove {_facingAdjust::%loop-value%} from {_facing}
  902. else:
  903. add {_facingAdjust::%loop-value%} to {_facing}
  904.  
  905. if loop-value is 1:
  906. if block at {_check} is not {_layer2::%loop-value%}:
  907. return false
  908. else if detectStair({_facing} - 2, {_check}, "") is false:
  909. return false
  910.  
  911. if block at location 2 meters above {_loc} is not red brick block:
  912. return false
  913. else:
  914. return false
  915. else:
  916. return false
  917. return true
  918.  
  919. function getRecipeItemFromType(type: String) :: item:
  920. if {_type} is "chain":
  921. return "iron nugget" parsed as an item
  922. else if {_type} is "diamond":
  923. return "diamond" parsed as an item
  924. return "%{_type}% ingot" parsed as an item
  925.  
  926. function tryCraftArmour(player: Player, type: String, piece: String):
  927. set {_result} to "%{_type}% %{_piece}%" parsed as an item
  928. set {_recipeItem} to "air" parsed as an item
  929. set {_recipeAmount} to 0
  930. if {_player}'s gamemode is survival or adventure:
  931. set {_recipeItem} to getRecipeItemFromType({_type})
  932. set {_recipeAmount} to {blacksmith.cost.%{_piece}%}
  933. set {_recipeAmountFromPlayer} to amount of {_recipeItem} in {_player}'s inventory
  934. if {_recipeAmountFromPlayer} < {_recipeAmount}:
  935. play "ENTITY_ITEM_BREAK" to {_player} at volume 10
  936. stop
  937.  
  938. else if {_player}'s gamemode is spectator:
  939. stop
  940. if {blacksmith.advancedMode} is false:
  941. give {_result} to {_player}
  942. remove {_recipeAmount} of {_recipeItem} from {_player}'s inventory
  943. play sound "block.anvil.use" with volume 10 and pitch 1 to {_player}
  944. else:
  945. playBlacksmithMinigame({_player}, {_recipeItem}, {_recipeAmount}, {_result})
  946.  
  947. function playBlacksmithMinigame(player: Player, costItem: Item, cost: Number, result: Item):
  948. set {blacksmith.smithing.%{_player}%.costItem} to {_costItem}
  949. set {blacksmith.smithing.%{_player}%.cost} to {_cost}
  950. set {blacksmith.smithing.%{_player}%.result} to {_result}
  951. set {blacksmith.smithing.%{_player}%.chainmail} to false
  952. set {blacksmith.smithing.%{_player}%.stage} to 0
  953.  
  954. open chest with 6 rows named "Smithing" to {_player}
  955. outlineGui({_player})
  956. set {_result1} to "%type of {_result}%"
  957. if {_result1} contains "chain":
  958. set {inventory.%{_player}%.name} to uncolored "Smithing"
  959. set {blacksmith.smithing.%{_player}%.chainmail} to true
  960. set {_random::*} to 39 and 41
  961. set {_slot} to random element out of {_random::*}
  962. remove {_slot} from {_random::*}
  963. set {_slot1} to random element out of {_random::*}
  964.  
  965. set slot {_slot} of {_player}'s current inventory to iron nugget named "&fCreate Rings"
  966. set slot {_slot1} of {_player}'s current inventory to iron hoe named "&fJoin Rings" without any NBT
  967. set slot 22 of {_player}'s current inventory to iron nugget named "&a&lCreate Rings" with lore "&7", "&7Click the corresponding item" and "&7to continue crafting."
  968. set slot 13 of {_player}'s current inventory to {_result} named "&f&n%first character of {_result1} in upper case%%last (length of {_result1}-1) characters of {_result1} in lower case%" without any NBT
  969. else:
  970. setSmithingGui({_player})
  971.  
  972. function setSmithingGui(player: Player):
  973. set {blacksmith.smithing.%{_player}%.chainmail} to false
  974. set {blacksmith.smithing.%{_player}%.stage} to 0
  975. set {inventory.%{_player}%.name} to uncolored "Smithing II"
  976.  
  977. open chest with 6 rows named "Smithing" to {_player}
  978. outlineGui({_player})
  979. set {_result1} to "%type of {blacksmith.smithing.%{_player}%.result}%"
  980. set slot 22 of {_player}'s current inventory to iron ingot named "&a&lHammer" with lore "&7", "&7Click the corresponding item" and "&7to continue crafting."
  981. set slot 13 of {_player}'s current inventory to {blacksmith.smithing.%{_player}%.result} named "&f&n%first character of {_result1} in upper case%%last (length of {_result1}-1) characters of {_result1} in lower case%" without any NBT
  982.  
  983. set {_random::*} to 38, 40 and 42
  984. set {_slot} to random element out of {_random::*}
  985. remove {_slot} from {_random::*}
  986. set {_slot1} to random element out of {_random::*}
  987. remove {_slot1} from {_random::*}
  988. set {_slot2} to random element out of {_random::*}
  989.  
  990. set slot {_slot} of {_player}'s current inventory to iron ingot named "&a&lBend" without any NBT
  991. set slot {_slot1} of {_player}'s current inventory to iron axe named "&a&lHammer" without any NBT
  992. set slot {_slot2} of {_player}'s current inventory to water bucket named "&a&lCool" without any NBT
  993.  
  994.  
  995. function removeItemFromPlayer(player: Player, item: Item, amount: Number):
  996. if {_amount} > 0:
  997. if {_item} is set:
  998. if gamemode of {_player} is survival or adventure:
  999. remove "%{_amount}% %{_item}%" parsed as an item from {_player}'s inventory
  1000.  
  1001.  
  1002.  
  1003. # C L I C K E V E N T S
  1004.  
  1005. on rightclick on smooth stone:
  1006. if player is not sneaking:
  1007. if {anvil.%location of clicked block%} is true:
  1008. set {anvil.current.%player%} to 1
  1009. openAnvilGui(player)
  1010. cancel event
  1011.  
  1012. on rightclick on cauldron:
  1013. if {furnace.%location of event-block%} is true:
  1014. if isFurnace1(location 1 meters below clicked block):
  1015. cancel event
  1016. guiFurnace1(player, location of clicked block)
  1017.  
  1018. else:
  1019. delete {furnace1.%location of clicked block%.contents.fuel}
  1020. delete {furnace1.%location of clicked block%.contents.ore}
  1021. delete {furnace1.%location of clicked block%.contents.ingot}
  1022. delete {furnace.%location of event-block%}
  1023.  
  1024. on rightclick on blast furnace:
  1025. if {furnace2.%location of event-block%} is true:
  1026. if isFurnace2(location of clicked block):
  1027. cancel event
  1028. send "WIP"
  1029. else:
  1030. delete {furnace2.%location of event-block%}
  1031.  
  1032. on rightclick holding stone axe:
  1033. if clicked block is smooth stone or iron block or diamond block:
  1034. if {anvil.%location of event-block%} is not true:
  1035. set {anvil.%location of event-block%} to true
  1036. set {_tier} to "Tier I"
  1037. if clicked block is smooth stone:
  1038. set {anvil.%location of event-block%.tier} to 1
  1039. else if clicked block is iron block:
  1040. set {anvil.%location of event-block%.tier} to 2
  1041. set {_tier} to "Tier II"
  1042. else:
  1043. set {anvil.%location of event-block%.tier} to 3
  1044. set {_tier} to "Tier III"
  1045.  
  1046. set {_s} to 6
  1047. loop all players in radius 6 around event-block:
  1048. set {_v} to ({_s} - distance between loop-player and event-block)
  1049. play sound "block.anvil.place" with volume {_v} and pitch 0 to loop-player
  1050.  
  1051. send "{@logo} Successfully created an anvil of %{_tier}%."
  1052. summon armor stand at location 0.6 meters below event-block
  1053. set name of last spawned armor stand to "&7Anvil"
  1054. add "{Invisible:1b,NoGravity:1b,NoAI:1b,CustomNameVisible:1}" to NBT of last spawned armor stand
  1055.  
  1056. summon armor stand at location 0.9 meters below event-block
  1057. set name of last spawned armor stand to "&7%{_tier}%"
  1058. add "{Invisible:1b,NoGravity:1b,NoAI:1b,CustomNameVisible:1}" to NBT of last spawned armor stand
  1059.  
  1060. else if clicked block is cauldron:
  1061. if {furnace.%location of event-block%} is not true:
  1062. if isFurnace1(location 1 meters below clicked block):
  1063. set {furnace.%location of event-block%} to true
  1064. cancel event
  1065.  
  1066. else if clicked block is blast furnace:
  1067. if {furnace.%location of event-block%} is not true:
  1068. if isFurnace2(location of clicked block):
  1069. set {furnace2.%location of event-block%} to true
  1070. cancel event
  1071. send "WIP"
  1072.  
  1073. on break of smooth stone or iron block or diamond block:
  1074. if {anvil.%location of event-block%} is true:
  1075. set {_s} to 6
  1076. loop all players in radius 6 around event-block:
  1077. set {_v} to ({_s} - distance between loop-player and event-block)
  1078. play sound "block.anvil.place" with volume {_v} and pitch 0 to loop-player
  1079. delete {anvil.%location of event-block%}
  1080. delete {anvil.%location of event-block%.tier}
  1081. loop entities in radius 1 around event-block:
  1082. if type of loop-entity is armor stand:
  1083. kill loop-entity
  1084.  
  1085.  
  1086. on inventory click:
  1087. if type of clicked inventory is chest inventory:
  1088. if inventory name of player's current inventory is {@tier1Furnace}:
  1089. cancel event
  1090. if clicked slot is set:
  1091. if clicked item is not air:
  1092. set {_item} to player's cursor slot
  1093. set {_leftClick} to false
  1094. if click type is left mouse button:
  1095. set {_leftClick} to true
  1096. if {_item} is not air:
  1097. if name of clicked item is "&a&lOre":
  1098. if canSmelt({_item}, 1):
  1099. if canSmeltInFurnace(player, {_item}):
  1100. setItemInSlot(player, "Ore", clicked slot, clicked item, {_item}, true, {_leftClick})
  1101. else if name of clicked item is "&a&lFuel":
  1102. if getFuelingTime({_item}) > 0:
  1103. setItemInSlot(player, "Fuel", clicked slot, clicked item, {_item}, true, {_leftClick})
  1104. else if getFuelingTime(clicked item) > 0:
  1105. if getFuelingTime({_item}) > 0:
  1106. setItemInSlot(player, "Fuel", clicked slot, clicked item, {_item}, false, {_leftClick})
  1107. else if canSmelt(clicked item, 1) is true:
  1108. if canSmelt({_item}, 1):
  1109. if canSmeltInFurnace(player, {_item}):
  1110. setItemInSlot(player, "Ore", clicked slot, clicked item, {_item}, false, {_leftClick})
  1111. else if clicked slot is 42:
  1112. if type of clicked item is not lime stained glass pane:
  1113. updateItemAndRemoveFromLoop(player, clicked item, clicked slot, 1, " I", "Ingot", {_leftClick})
  1114. else if getFuelingTime(clicked item) > 0:
  1115. updateItemAndRemoveFromLoop(player, clicked item, clicked slot, 1, " I", "Fuel", {_leftClick})
  1116. else if canSmelt(clicked item, 1) is true:
  1117. updateItemAndRemoveFromLoop(player, clicked item, clicked slot, 1, " I", "Ore", {_leftClick})
  1118.  
  1119. else if inventory name of player's current inventory is "Anvil Tier I":
  1120. cancel event
  1121. if clicked slot is set:
  1122. if clicked item is any helmet, any chestplate, any leggings or any boots:
  1123. set {_item::*} to ("%type of clicked item%") split at " "
  1124. tryCraftArmour(player, {_item::1}, {_item::2})
  1125.  
  1126. else if inventory name of player's current inventory is "Smithing":
  1127. cancel event
  1128. if clicked slot is set:
  1129. if {blacksmith.smithing.%{_player}%.chainmail} is true:
  1130. if clicked item is iron nugget:
  1131. if {blacksmith.smithing.%player%.stage} is 0:
  1132. add 1 to {blacksmith.smithing.%player%.stage}
  1133. set slot 22 of player's current inventory to iron hoe named "&a&lJoin Rings" with lore "&7", "&7Click the corresponding item" and "&7to continue crafting." without any NBT
  1134. play sound "entity.item.pickup" with volume 12 and pitch 2 to player
  1135. else:
  1136. removeItemFromPlayer(player, iron nugget, {blacksmith.smithing.%player%.cost})
  1137. play sound "entity.item.break" with volume 10 and pitch 1 to player
  1138. close player's inventory
  1139.  
  1140. else if clicked item is iron hoe:
  1141. if {blacksmith.smithing.%player%.stage} is 1:
  1142. add 1 to {blacksmith.smithing.%player%.stage}
  1143. play sound "block.anvil.land" with volume 10 and pitch 1 to player
  1144. setSmithingGui(player)
  1145. else:
  1146. removeItemFromPlayer(player, iron nugget, {blacksmith.smithing.%player%.cost})
  1147. play sound "entity.item.break" with volume 10 and pitch 1 to player
  1148. close player's inventory
  1149. else:
  1150. if clicked item is iron ingot:
  1151. if {blacksmith.smithing.%player%.stage} is 0 or 2:
  1152. play sound "block.anvil.use" with volume 12 and pitch 2 to player
  1153. if {blacksmith.smithing.%player%.stage} is 0:
  1154. set slot 22 of player's current inventory to iron axe named "&a&lBend" with lore "&7", "&7Click the corresponding item" and "&7to continue crafting."
  1155. else:
  1156. set slot 22 of player's current inventory to water bucket named "&a&lCool" with lore "&7", "&7Click the corresponding item" and "&7to continue crafting."
  1157. add 1 to {blacksmith.smithing.%player%.stage}
  1158.  
  1159.  
  1160. else if clicked item is iron axe:
  1161. if {blacksmith.smithing.%player%.stage} is 1:
  1162. add 1 to {blacksmith.smithing.%player%.stage}
  1163. play sound "block.anvil.use" with volume 12 and pitch 2 to player
  1164. set slot 22 of player's current inventory to iron axe named "&a&lHammer" with lore "&7", "&7Click the corresponding item" and "&7to continue crafting." without any NBT
  1165. else if clicked item is water bucket:
  1166. if {blacksmith.smithing.%player%.stage} is 3:
  1167. play sound "block.anvil.land" with volume 12 and pitch 2 to player
  1168.  
  1169.  
  1170. on inventory close:
  1171. if {inventory.%player%.name} is set:
  1172. remove player from {inventoryList.%{inventory.%player%.current}%.%{inventory.%player%.name}%::*}
  1173. delete {inventory.%player%.name}
  1174. delete {inventory.%player%.current}
  1175. else if {anvil.current.%player%} is set:
  1176. delete {anvil.current.%player%}
  1177.  
  1178. on inventory drag:
  1179. set {_tier1} to uncolored {@tier1Furnace}
  1180. if {inventory.%player%.name} is "Anvil" or "%{_tier1}%" or "Furnace II":
  1181. cancel event
  1182. else if {anvil.current.%player%} is set:
  1183. cancel event
  1184.  
  1185. on craft:
  1186. if event-item is any helmet, any chestplate, any leggings or any boots:
  1187. if "%event-item%" doesn't start with "leather":
  1188. send "{@logo} You cannot craft this item in a crafting table!"
  1189. cancel event
  1190.  
  1191. #|=============================================================|
  1192. #| ______ _ _ _____ _ _ _____ ______ |
  1193. #| | ____| | | | __ \| \ | | /\ / ____| ____| |
  1194. #| | |__ | | | | |__) | \| | / \ | | | |__ |
  1195. #| | __| | | | | _ /| . ` | / /\ \| | | __| |
  1196. #| | | | |__| | | \ \| |\ |/ ____ \ |____| |____ |
  1197. #| |_| \____/|_| \_\_| \_/_/ \_\_____|______| |
  1198. #| |
  1199. #|=============================================================|
  1200.  
  1201. function guiFurnace1(p: Player, loc: Location):
  1202. openGuiOutlined({_p}, {_loc}, 6, {@tier1Furnace})
  1203.  
  1204. if {furnace1.%{_loc}%.contents.fuel} is not set:
  1205. set {furnace1.%{_loc}%.contents.fuel} to 0
  1206. if {furnace1.%{_loc}%.contents.ore} is not set:
  1207. set {furnace1.%{_loc}%.contents.ore} to 0
  1208. if {furnace1.%{_loc}%.contents.ingot} is not set:
  1209. set {furnace1.%{_loc}%.contents.ingot} to 0
  1210.  
  1211. if {furnace1.%{_loc}%.contents.ingotType} is not set:
  1212. set {furnace1.%{_loc}%.contents.ingot} to 0
  1213. if {furnace1.%{_loc}%.contents.oreType} is not set:
  1214. set {furnace1.%{_loc}%.contents.ore} to 0
  1215. if {furnace1.%{_loc}%.contents.fuelType} is not set:
  1216. set {furnace1.%{_loc}%.contents.fuel} to 0
  1217.  
  1218. set {furnace1.%{_loc}%.fuelingTimeMax} to 0
  1219. if {furnace1.%{_loc}%.contents.fuelType} is set:
  1220. set {furnace1.%{_loc}%.fuelingTimeMax} to getFuelingTime({furnace1.%{_loc}%.contents.fuelType}) / 20
  1221.  
  1222. set slot 38 of {_p}'s current inventory to lime stained glass pane named "&a&lOre"
  1223. set slot 40 of {_p}'s current inventory to lime stained glass pane named "&a&lFuel"
  1224. set slot 42 of {_p}'s current inventory to lime stained glass pane named "&a&lIngot"
  1225.  
  1226. if {furnace1.%{_loc}%.contents.ore} > 0:
  1227. set slot 38 of {_p}'s current inventory to ("%{furnace1.%{_loc}%.contents.ore}% %{furnace1.%{_loc}%.contents.oreType}%" parsed as an item)
  1228.  
  1229. if {furnace1.%{_loc}%.contents.fuel} > 0:
  1230. set slot 40 of {_p}'s current inventory to ("%{furnace1.%{_loc}%.contents.fuel}% %{furnace1.%{_loc}%.contents.fuelType}%" parsed as an item)
  1231.  
  1232. if {furnace1.%{_loc}%.contents.ingot} > 0:
  1233. set slot 42 of {_p}'s current inventory to ("%{furnace1.%{_loc}%.contents.ingot}% %{furnace1.%{_loc}%.contents.ingotType}%" parsed as an item)
  1234.  
  1235. loop 5 times:
  1236. set slot 19 + loop-value of {_p}'s current inventory to gray stained glass pane named "&f%20*loop-value%%%"
  1237.  
  1238. set {_progressBar} to "%{furnace1.%{_loc}%.smeltTime}/2.0%"
  1239. if {_progressBar} contains ".":
  1240. set {_progressBar::*} to {_progressBar} split at "."
  1241. set {_progressBar} to {_progressBar::1}
  1242.  
  1243. loop ({_progressBar} parsed as an integer) times:
  1244. set slot 20+loop-value -1 of {_p}'s current inventory to lime stained glass pane named "&f%20*loop-value%%%"
  1245.  
  1246. function updateItemInSlot(furnaceId: Location, type: String, slot: Number, furnaceTier: String, typeId: integer):
  1247. set {_typeLower} to {_type} in lower case
  1248. loop {inventoryList.%{_furnaceId}%.furnace%{_furnaceTier}%::*}:
  1249. 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)
  1250. if {furnace%{_typeId}%.%{_furnaceId}%.contents.%{_typeLower}%} <= 0:
  1251. set slot {_slot} of loop-value's current inventory to lime stained glass pane named "&a&l%{_type}%"
  1252.  
  1253. function updateItemAndRemoveFromLoop(p: Player, item: Item, slot: Number, furnaceTier: Integer, furnaceTierString: String, itemName: String, leftClick: Boolean):
  1254. set {_nameLower} to {_itemName} in lower case
  1255. set {_amount} to {furnace1.%{inventory.%{_p}%.current}%.contents.%{_nameLower}%}
  1256. set {_removedAmount} to {_amount}
  1257. if {_leftClick} is false:
  1258. set {_removedAmount} to "%{_amount} / 2%" parsed as an integer
  1259. if {_removedAmount} is {_amount}:
  1260. set {_removedAmount} to 1
  1261. add "%({_amount}-1) / 2%" parsed as an integer to {_removedAmount}
  1262. set {_item} to "%{_amount} - {_removedAmount} + 1% %type of {_item}%" parsed as an item
  1263. else:
  1264. set {_item} to "%{_amount} - {_removedAmount}% %type of {_item}%" parsed as an item
  1265.  
  1266. set {_p}'s cursor slot to {_item}
  1267. set {furnace1.%{inventory.%{_p}%.current}%.contents.%{_nameLower}%} to {_amount}-{_removedAmount}
  1268. if {_amount}-{_removedAmount} <= 0:
  1269. delete {furnace1.%{inventory.%{_p}%.current}%.contents.%{_nameLower}%Type}
  1270. set slot ({_slot}) of {_p}'s current inventory to lime stained glass pane named "&a&l%{_itemName}%"
  1271. if {_nameLower} is "ore" or "fuel":
  1272. resetFuelIndicator({inventory.%{_p}%.current}, {_furnaceTierString})
  1273. else:
  1274. set slot ({_slot}) of {_p}'s current inventory to "%{_amount}-{_removedAmount}% %{furnace1.%{inventory.%{_p}%.current}%.contents.%{_nameLower}%Type}%" parsed as an item
  1275.  
  1276.  
  1277. function updateInventoryFuelIndicator(furnaceId: Location, progressBar: Integer, furnaceTier: String):
  1278. if {_progressBar} <= 4:
  1279. if {_progressBar} >= 0:
  1280. loop {inventoryList.%{_furnaceId}%.furnace%{_furnaceTier}%::*}:
  1281. set slot 20+{_progressBar} of loop-value's current inventory to gray stained glass pane named "&f%20*({_progressBar}+1)%%%"
  1282. if {_progressBar} > 0:
  1283. set slot 20+{_progressBar}-1 of loop-value's current inventory to lime stained glass pane named "&f%20*{_progressBar}%%%"
  1284. loop 4-{_progressBar} times:
  1285. 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)%%%"
  1286.  
  1287. function resetFuelIndicator(furnaceId: Location, furnaceTier: String):
  1288. set {furnace1.%{_furnaceId}%.smeltTime} to 0
  1289. loop {inventoryList.%{_furnaceId}%.furnace%{_furnaceTier}%::*}:
  1290. loop 5 times:
  1291. set slot 19 + loop-value-2 of loop-value-1's current inventory to gray stained glass pane named "&f%20*loop-value-2%%%"
  1292. if {_furnaceTier} is " I":
  1293. removeFurnaceFromLoop({_furnaceId}, 1)
  1294. else:
  1295. removeFurnaceFromLoop({_furnaceId}, 2)
  1296.  
  1297. function setIngotType(furnaceId: Location, tier: Number):
  1298. delete {furnace%{_tier}%.%{_furnaceId}%.contents.ingotType}
  1299. if {furnace%{_tier}%.%{_furnaceId}%.contents.ingotType} is set:
  1300. stop
  1301. set {_type} to "%{furnace%{_tier}%.%{_furnaceId}%.contents.oreType}%"
  1302. if {_tier} is 2:
  1303. if {_type} is "diamond ore", "emerald ore" or "nether quartz ore":
  1304. replace all " ore" in {_type} with " ingot"
  1305. {furnace%{_tier}%.%{_furnaceId}%.contents.ingotType}
  1306. stop
  1307. if "%{_type}%" is "iron ore", "gold ore", "lapis ore" or "redstone ore":
  1308. replace "ore" in {_type} with "ingot"
  1309. set {furnace%{_tier}%.%{_furnaceId}%.contents.ingotType} to {_type} parsed as an item
  1310. else if {_type} is "coal ore":
  1311. set {furnace%{_tier}%.%{_furnaceId}%.contents.ingotType} to coal
  1312.  
  1313. function removeFurnaceFromLoop(furnaceId: Location, typeId: integer):
  1314. delete {furnace.%{_furnaceId}%.isAddedToLoop}
  1315. remove {_furnaceId} from {furnace%{_typeId}%.loopList::*}
  1316.  
  1317.  
  1318. function loop_furnace1():
  1319. set {furnace1.looping} to false
  1320. if {furnace1.looping} is not true:
  1321. set {furnace1.looping} to true
  1322. while {furnace1.looping} is true:
  1323. if size of {furnace1.loopList::*} is 0:
  1324. set {furnace1.looping} to false
  1325. stop loop
  1326. else:
  1327. loop {furnace1.loopList::*}:
  1328. if {furnace1.%loop-value%.contents.ore} < 1:
  1329. updateInventoryFuelIndicator(loop-value, 0, " I")
  1330. removeFurnaceFromLoop(loop-value, 1)
  1331.  
  1332. else:
  1333. if {furnace1.%loop-value%.contents.fuelingTime} is not set:
  1334. remove 1 from {furnace1.%loop-value%.contents.fuel}
  1335. updateItemInSlot(loop-value, "Fuel", 40, " I", 1)
  1336.  
  1337. add 1 to {furnace1.%loop-value%.smeltTime}
  1338. add 1 to {furnace1.%loop-value%.fuelingTime}
  1339. if "%{furnace1.%loop-value%.smeltTime}/2.0%" doesn't contain ".":
  1340. if {furnace1.%loop-value%.smeltTime}/2 > 4:
  1341. updateInventoryFuelIndicator(loop-value, 0, " I")
  1342. else:
  1343. updateInventoryFuelIndicator(loop-value, "%{furnace1.%loop-value%.smeltTime}/2%" parsed as an integer, " I")
  1344. if {furnace1.%loop-value%.smeltTime} > 9:
  1345. delete {furnace1.%loop-value%.smeltTime}
  1346. remove 1 from {furnace1.%loop-value%.contents.ore}
  1347. add 1 to {furnace1.%loop-value%.contents.ingot}
  1348. setIngotType(loop-value, 1)
  1349. updateItemInSlot(loop-value, "Ore", 38, " I", 1)
  1350. updateItemInSlot(loop-value, "Ingot", 42, " I", 1)
  1351. updateInventoryFuelIndicator(loop-value, 0, " I")
  1352.  
  1353.  
  1354. if {furnace1.%loop-value%.fuelingTime} >= {furnace1.%Loop-value%.fuelingTimeMax}:
  1355. if {furnace1.%loop-value%.contents.fuel} <= 0:
  1356. delete {furnace1.%loop-value%.smeltTime}
  1357. removeFurnaceFromLoop(loop-value, 1)
  1358. updateInventoryFuelIndicator(loop-value, 0, " I")
  1359. else:
  1360. delete {furnace1.%loop-value%.fuelingTime}
  1361. wait 1 second
  1362.  
  1363. # Returns how many ticks an item gives fuel
  1364. function getFuelingTime(type: Item) :: integer:
  1365. if {_type} is lava:
  1366. return 20000
  1367. else if {_type} is block of coal:
  1368. return 16000
  1369. else if {_type} is dried kelp block:
  1370. return 4000
  1371. else if {_type} is blaze rod:
  1372. return 2400
  1373. else if {_type} is coal or charcoal:
  1374. return 1600
  1375. else if {_type} is any boat or scaffolding:
  1376. return 1200
  1377. 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:
  1378. return 300
  1379. 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:
  1380. return 200
  1381. else if {_type} is bowl or any sapling or stick or any wool:
  1382. return 100
  1383. else if {_type} is any carpet:
  1384. return 67
  1385. else if {_type} is bamboo:
  1386. return 50
  1387. return 0
  1388.  
  1389. # Returns if the item can be smelted in the furnace, every smelt takes 10 seconds in a normal furnace
  1390. function canSmelt(type: Item, tier: Integer) :: boolean:
  1391. if {_type} is iron ore or gold ore or lapis ore or redstone ore or coal ore:
  1392. return true
  1393. else if {_tier} is 2:
  1394. if {_type} is diamond ore or emerald ore or nether quartz ore:
  1395. return true
  1396.  
  1397. return false
  1398.  
  1399. function canSmeltInFurnace(p: Player, item: Item) :: boolean:
  1400. set {_furnaceId} to {inventory.%{_p}%.current}
  1401. if {furnace1.%{_furnaceId}%.contents.oreType} is set:
  1402. if "%type of {_item}%" is not "%{furnace1.%{_furnaceId}%.contents.oreType}%":
  1403. return false
  1404. if {furnace1.%{_furnaceId}%.contents.ingotType} is set:
  1405. send "true" to {_p}
  1406. if type of {_item} is coal ore:
  1407. if type of {furnace1.%{_furnaceId}%.contents.ingotType} is coal:
  1408. return true
  1409. set {_item} to "%type of {_item}%"
  1410. replace all " ore" in {_item} with " ingot"
  1411. if {_item} is not "%{furnace1.%{_furnaceId}%.contents.ingotType}%":
  1412. return false
  1413. return true
  1414.  
  1415.  
  1416.  
  1417.  
  1418.  
  1419. on disable:
  1420. if {furnace1.looping} is true:
  1421. set {furnace1.looping} to false
  1422. set {furnace1.loopStopped} to true
  1423.  
  1424. on enable:
  1425. set {blacksmith.cost.helmet} to 5
  1426. set {blacksmith.cost.chestplate} to 8
  1427. set {blacksmith.cost.leggings} to 7
  1428. set {blacksmith.cost.boots} to 4
  1429. if {blacksmith.advancedMode} is not set:
  1430. set {blacksmith.advancedMode} to true
  1431. wait 1 second
  1432. if {furnace1.loopStopped} is true:
  1433. set {furnace1.looping} to true
  1434. set {furnace1.loopStopped} to false
  1435.  
Add Comment
Please, Sign In to add comment