Zeldaboy111

Advanced Mode Werkt! ]|[ Skript #372

Dec 13th, 2020
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 32.59 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&lBend" 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. function userFailedMinigame(player: Player):
  278. removeItemFromPlayer({_player}, {blacksmith.smithing.%{_player}%.costItem}, {blacksmith.smithing.%{_player}%.cost})
  279. play sound "entity.item.break" with volume 10 and pitch 1 to {_player}
  280. close {_player}'s inventory
  281.  
  282. function removeItemFromPlayer(player: Player, item: Item, amount: Number):
  283. if {_amount} > 0:
  284. if {_item} is set:
  285. if gamemode of {_player} is survival or adventure:
  286. remove "%{_amount}% %{_item}%" parsed as an item from {_player}'s inventory
  287.  
  288.  
  289.  
  290. # C L I C K E V E N T S
  291.  
  292. on rightclick on smooth stone:
  293. if player is not sneaking:
  294. if {anvil.%location of clicked block%} is true:
  295. set {anvil.current.%player%} to 1
  296. openAnvilGui(player)
  297. cancel event
  298.  
  299. on rightclick on cauldron:
  300. if {furnace.%location of event-block%} is true:
  301. if isFurnace1(location 1 meters below clicked block):
  302. cancel event
  303. guiFurnace1(player, location of clicked block)
  304.  
  305. else:
  306. delete {furnace1.%location of clicked block%.contents.fuel}
  307. delete {furnace1.%location of clicked block%.contents.ore}
  308. delete {furnace1.%location of clicked block%.contents.ingot}
  309. delete {furnace.%location of event-block%}
  310.  
  311. on rightclick on blast furnace:
  312. if {furnace2.%location of event-block%} is true:
  313. if isFurnace2(location of clicked block):
  314. cancel event
  315. send "WIP"
  316. else:
  317. delete {furnace2.%location of event-block%}
  318.  
  319. on rightclick holding stone axe:
  320. if clicked block is smooth stone or iron block or diamond block:
  321. if {anvil.%location of event-block%} is not true:
  322. set {anvil.%location of event-block%} to true
  323. set {_tier} to "Tier I"
  324. if clicked block is smooth stone:
  325. set {anvil.%location of event-block%.tier} to 1
  326. else if clicked block is iron block:
  327. set {anvil.%location of event-block%.tier} to 2
  328. set {_tier} to "Tier II"
  329. else:
  330. set {anvil.%location of event-block%.tier} to 3
  331. set {_tier} to "Tier III"
  332.  
  333. set {_s} to 6
  334. loop all players in radius 6 around event-block:
  335. set {_v} to ({_s} - distance between loop-player and event-block)
  336. play sound "block.anvil.place" with volume {_v} and pitch 0 to loop-player
  337.  
  338. send "{@logo} Successfully created an anvil of %{_tier}%."
  339. summon armor stand at location 0.6 meters below event-block
  340. set name of last spawned armor stand to "&7Anvil"
  341. add "{Invisible:1b,NoGravity:1b,NoAI:1b,CustomNameVisible:1}" to NBT of last spawned armor stand
  342.  
  343. summon armor stand at location 0.9 meters below event-block
  344. set name of last spawned armor stand to "&7%{_tier}%"
  345. add "{Invisible:1b,NoGravity:1b,NoAI:1b,CustomNameVisible:1}" to NBT of last spawned armor stand
  346.  
  347. else if clicked block is cauldron:
  348. if {furnace.%location of event-block%} is not true:
  349. if isFurnace1(location 1 meters below clicked block):
  350. set {furnace.%location of event-block%} to true
  351. cancel event
  352.  
  353. else if clicked block is blast furnace:
  354. if {furnace.%location of event-block%} is not true:
  355. if isFurnace2(location of clicked block):
  356. set {furnace2.%location of event-block%} to true
  357. cancel event
  358. send "WIP"
  359.  
  360. on break of smooth stone or iron block or diamond block:
  361. if {anvil.%location of event-block%} is true:
  362. set {_s} to 6
  363. loop all players in radius 6 around event-block:
  364. set {_v} to ({_s} - distance between loop-player and event-block)
  365. play sound "block.anvil.place" with volume {_v} and pitch 0 to loop-player
  366. delete {anvil.%location of event-block%}
  367. delete {anvil.%location of event-block%.tier}
  368. loop entities in radius 1 around event-block:
  369. if type of loop-entity is armor stand:
  370. kill loop-entity
  371.  
  372.  
  373. on inventory click:
  374. if type of clicked inventory is chest inventory:
  375. if inventory name of player's current inventory is {@tier1Furnace}:
  376. cancel event
  377. if clicked slot is set:
  378. if clicked item is not air:
  379. set {_item} to player's cursor slot
  380. set {_leftClick} to false
  381. if click type is left mouse button:
  382. set {_leftClick} to true
  383. if {_item} is not air:
  384. if name of clicked item is "&a&lOre":
  385. if canSmelt({_item}, 1):
  386. if canSmeltInFurnace(player, {_item}):
  387. setItemInSlot(player, "Ore", clicked slot, clicked item, {_item}, true, {_leftClick})
  388. else if name of clicked item is "&a&lFuel":
  389. if getFuelingTime({_item}) > 0:
  390. setItemInSlot(player, "Fuel", clicked slot, clicked item, {_item}, true, {_leftClick})
  391. else if getFuelingTime(clicked item) > 0:
  392. if getFuelingTime({_item}) > 0:
  393. setItemInSlot(player, "Fuel", clicked slot, clicked item, {_item}, false, {_leftClick})
  394. else if canSmelt(clicked item, 1) is true:
  395. if canSmelt({_item}, 1):
  396. if canSmeltInFurnace(player, {_item}):
  397. setItemInSlot(player, "Ore", clicked slot, clicked item, {_item}, false, {_leftClick})
  398. else if clicked slot is 42:
  399. if type of clicked item is not lime stained glass pane:
  400. updateItemAndRemoveFromLoop(player, clicked item, clicked slot, 1, " I", "Ingot", {_leftClick})
  401. else if getFuelingTime(clicked item) > 0:
  402. updateItemAndRemoveFromLoop(player, clicked item, clicked slot, 1, " I", "Fuel", {_leftClick})
  403. else if canSmelt(clicked item, 1) is true:
  404. updateItemAndRemoveFromLoop(player, clicked item, clicked slot, 1, " I", "Ore", {_leftClick})
  405.  
  406. else if inventory name of player's current inventory is "Anvil Tier I":
  407. cancel event
  408. if clicked slot is set:
  409. if clicked item is any helmet, any chestplate, any leggings or any boots:
  410. set {_item::*} to ("%type of clicked item%") split at " "
  411. tryCraftArmour(player, {_item::1}, {_item::2})
  412.  
  413. else if inventory name of player's current inventory is "Smithing":
  414. cancel event
  415. if clicked slot is set:
  416. if {blacksmith.smithing.%player%.chainmail} is true:
  417. if clicked item is iron nugget:
  418. if {blacksmith.smithing.%player%.stage} is 0:
  419. add 1 to {blacksmith.smithing.%player%.stage}
  420. 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
  421. play sound "entity.item.pickup" with volume 12 and pitch 2 to player
  422. else:
  423. userFailedMinigame(player)
  424.  
  425. else if clicked item is iron hoe:
  426. if {blacksmith.smithing.%player%.stage} is 1:
  427. add 1 to {blacksmith.smithing.%player%.stage}
  428. play sound "block.anvil.land" with volume 10 and pitch 1 to player
  429. setSmithingGui(player)
  430. else:
  431. userFailedMinigame(player)
  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&lHammer" with lore "&7", "&7Click the corresponding item" and "&7to continue crafting." without any NBT
  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. else:
  442. userFailedMinigame(player)
  443.  
  444.  
  445. else if clicked item is iron axe:
  446. if {blacksmith.smithing.%player%.stage} is 1:
  447. add 1 to {blacksmith.smithing.%player%.stage}
  448. play sound "block.anvil.use" with volume 12 and pitch 2 to player
  449. set slot 22 of player's current inventory to iron ingot named "&a&lBend" with lore "&7", "&7Click the corresponding item" and "&7to continue crafting."
  450. else:
  451. userFailedMinigame(player)
  452. else if clicked item is water bucket:
  453. if {blacksmith.smithing.%player%.stage} is 3:
  454. play sound "block.anvil.land" with volume 12 and pitch 2 to player
  455. give {blacksmith.smithing.%player%.result} to player
  456. close player's inventory
  457. else:
  458. userFailedMinigame(player)
  459.  
  460. on inventory close:
  461. if {inventory.%player%.name} is set:
  462. remove player from {inventoryList.%{inventory.%player%.current}%.%{inventory.%player%.name}%::*}
  463. delete {inventory.%player%.name}
  464. delete {inventory.%player%.current}
  465. else if {anvil.current.%player%} is set:
  466. delete {anvil.current.%player%}
  467.  
  468. on inventory drag:
  469. set {_tier1} to uncolored {@tier1Furnace}
  470. if {inventory.%player%.name} is "Anvil" or "%{_tier1}%" or "Furnace II":
  471. cancel event
  472. else if {anvil.current.%player%} is set:
  473. cancel event
  474.  
  475. on craft:
  476. if event-item is any helmet, any chestplate, any leggings or any boots:
  477. if "%event-item%" doesn't start with "leather":
  478. send "{@logo} You cannot craft this item in a crafting table!"
  479. cancel event
  480.  
  481. #|=============================================================|
  482. #| ______ _ _ _____ _ _ _____ ______ |
  483. #| | ____| | | | __ \| \ | | /\ / ____| ____| |
  484. #| | |__ | | | | |__) | \| | / \ | | | |__ |
  485. #| | __| | | | | _ /| . ` | / /\ \| | | __| |
  486. #| | | | |__| | | \ \| |\ |/ ____ \ |____| |____ |
  487. #| |_| \____/|_| \_\_| \_/_/ \_\_____|______| |
  488. #| |
  489. #|=============================================================|
  490.  
  491. function guiFurnace1(p: Player, loc: Location):
  492. openGuiOutlined({_p}, {_loc}, 6, {@tier1Furnace})
  493.  
  494. if {furnace1.%{_loc}%.contents.fuel} is not set:
  495. set {furnace1.%{_loc}%.contents.fuel} to 0
  496. if {furnace1.%{_loc}%.contents.ore} is not set:
  497. set {furnace1.%{_loc}%.contents.ore} to 0
  498. if {furnace1.%{_loc}%.contents.ingot} is not set:
  499. set {furnace1.%{_loc}%.contents.ingot} to 0
  500.  
  501. if {furnace1.%{_loc}%.contents.ingotType} is not set:
  502. set {furnace1.%{_loc}%.contents.ingot} to 0
  503. if {furnace1.%{_loc}%.contents.oreType} is not set:
  504. set {furnace1.%{_loc}%.contents.ore} to 0
  505. if {furnace1.%{_loc}%.contents.fuelType} is not set:
  506. set {furnace1.%{_loc}%.contents.fuel} to 0
  507.  
  508. set {furnace1.%{_loc}%.fuelingTimeMax} to 0
  509. if {furnace1.%{_loc}%.contents.fuelType} is set:
  510. set {furnace1.%{_loc}%.fuelingTimeMax} to getFuelingTime({furnace1.%{_loc}%.contents.fuelType}) / 20
  511.  
  512. set slot 38 of {_p}'s current inventory to lime stained glass pane named "&a&lOre"
  513. set slot 40 of {_p}'s current inventory to lime stained glass pane named "&a&lFuel"
  514. set slot 42 of {_p}'s current inventory to lime stained glass pane named "&a&lIngot"
  515.  
  516. if {furnace1.%{_loc}%.contents.ore} > 0:
  517. set slot 38 of {_p}'s current inventory to ("%{furnace1.%{_loc}%.contents.ore}% %{furnace1.%{_loc}%.contents.oreType}%" parsed as an item)
  518.  
  519. if {furnace1.%{_loc}%.contents.fuel} > 0:
  520. set slot 40 of {_p}'s current inventory to ("%{furnace1.%{_loc}%.contents.fuel}% %{furnace1.%{_loc}%.contents.fuelType}%" parsed as an item)
  521.  
  522. if {furnace1.%{_loc}%.contents.ingot} > 0:
  523. set slot 42 of {_p}'s current inventory to ("%{furnace1.%{_loc}%.contents.ingot}% %{furnace1.%{_loc}%.contents.ingotType}%" parsed as an item)
  524.  
  525. loop 5 times:
  526. set slot 19 + loop-value of {_p}'s current inventory to gray stained glass pane named "&f%20*loop-value%%%"
  527.  
  528. set {_progressBar} to "%{furnace1.%{_loc}%.smeltTime}/2.0%"
  529. if {_progressBar} contains ".":
  530. set {_progressBar::*} to {_progressBar} split at "."
  531. set {_progressBar} to {_progressBar::1}
  532.  
  533. loop ({_progressBar} parsed as an integer) times:
  534. set slot 20+loop-value -1 of {_p}'s current inventory to lime stained glass pane named "&f%20*loop-value%%%"
  535.  
  536. function updateItemInSlot(furnaceId: Location, type: String, slot: Number, furnaceTier: String, typeId: integer):
  537. set {_typeLower} to {_type} in lower case
  538. loop {inventoryList.%{_furnaceId}%.furnace%{_furnaceTier}%::*}:
  539. 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)
  540. if {furnace%{_typeId}%.%{_furnaceId}%.contents.%{_typeLower}%} <= 0:
  541. set slot {_slot} of loop-value's current inventory to lime stained glass pane named "&a&l%{_type}%"
  542.  
  543. function updateItemAndRemoveFromLoop(p: Player, item: Item, slot: Number, furnaceTier: Integer, furnaceTierString: String, itemName: String, leftClick: Boolean):
  544. set {_nameLower} to {_itemName} in lower case
  545. set {_amount} to {furnace1.%{inventory.%{_p}%.current}%.contents.%{_nameLower}%}
  546. set {_removedAmount} to {_amount}
  547. if {_leftClick} is false:
  548. set {_removedAmount} to "%{_amount} / 2%" parsed as an integer
  549. if {_removedAmount} is {_amount}:
  550. set {_removedAmount} to 1
  551. add "%({_amount}-1) / 2%" parsed as an integer to {_removedAmount}
  552. set {_item} to "%{_amount} - {_removedAmount} + 1% %type of {_item}%" parsed as an item
  553. else:
  554. set {_item} to "%{_amount} - {_removedAmount}% %type of {_item}%" parsed as an item
  555.  
  556. set {_p}'s cursor slot to {_item}
  557. set {furnace1.%{inventory.%{_p}%.current}%.contents.%{_nameLower}%} to {_amount}-{_removedAmount}
  558. if {_amount}-{_removedAmount} <= 0:
  559. delete {furnace1.%{inventory.%{_p}%.current}%.contents.%{_nameLower}%Type}
  560. set slot ({_slot}) of {_p}'s current inventory to lime stained glass pane named "&a&l%{_itemName}%"
  561. if {_nameLower} is "ore" or "fuel":
  562. resetFuelIndicator({inventory.%{_p}%.current}, {_furnaceTierString})
  563. else:
  564. set slot ({_slot}) of {_p}'s current inventory to "%{_amount}-{_removedAmount}% %{furnace1.%{inventory.%{_p}%.current}%.contents.%{_nameLower}%Type}%" parsed as an item
  565.  
  566.  
  567. function updateInventoryFuelIndicator(furnaceId: Location, progressBar: Integer, furnaceTier: String):
  568. if {_progressBar} <= 4:
  569. if {_progressBar} >= 0:
  570. loop {inventoryList.%{_furnaceId}%.furnace%{_furnaceTier}%::*}:
  571. set slot 20+{_progressBar} of loop-value's current inventory to gray stained glass pane named "&f%20*({_progressBar}+1)%%%"
  572. if {_progressBar} > 0:
  573. set slot 20+{_progressBar}-1 of loop-value's current inventory to lime stained glass pane named "&f%20*{_progressBar}%%%"
  574. loop 4-{_progressBar} times:
  575. 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)%%%"
  576.  
  577. function resetFuelIndicator(furnaceId: Location, furnaceTier: String):
  578. set {furnace1.%{_furnaceId}%.smeltTime} to 0
  579. loop {inventoryList.%{_furnaceId}%.furnace%{_furnaceTier}%::*}:
  580. loop 5 times:
  581. set slot 19 + loop-value-2 of loop-value-1's current inventory to gray stained glass pane named "&f%20*loop-value-2%%%"
  582. if {_furnaceTier} is " I":
  583. removeFurnaceFromLoop({_furnaceId}, 1)
  584. else:
  585. removeFurnaceFromLoop({_furnaceId}, 2)
  586.  
  587. function setIngotType(furnaceId: Location, tier: Number):
  588. delete {furnace%{_tier}%.%{_furnaceId}%.contents.ingotType}
  589. if {furnace%{_tier}%.%{_furnaceId}%.contents.ingotType} is set:
  590. stop
  591. set {_type} to "%{furnace%{_tier}%.%{_furnaceId}%.contents.oreType}%"
  592. if {_tier} is 2:
  593. if {_type} is "diamond ore", "emerald ore" or "nether quartz ore":
  594. replace all " ore" in {_type} with " ingot"
  595. {furnace%{_tier}%.%{_furnaceId}%.contents.ingotType}
  596. stop
  597. if "%{_type}%" is "iron ore", "gold ore", "lapis ore" or "redstone ore":
  598. replace "ore" in {_type} with "ingot"
  599. set {furnace%{_tier}%.%{_furnaceId}%.contents.ingotType} to {_type} parsed as an item
  600. else if {_type} is "coal ore":
  601. set {furnace%{_tier}%.%{_furnaceId}%.contents.ingotType} to coal
  602.  
  603. function removeFurnaceFromLoop(furnaceId: Location, typeId: integer):
  604. delete {furnace.%{_furnaceId}%.isAddedToLoop}
  605. remove {_furnaceId} from {furnace%{_typeId}%.loopList::*}
  606.  
  607.  
  608. function loop_furnace1():
  609. set {furnace1.looping} to false
  610. if {furnace1.looping} is not true:
  611. set {furnace1.looping} to true
  612. while {furnace1.looping} is true:
  613. if size of {furnace1.loopList::*} is 0:
  614. set {furnace1.looping} to false
  615. stop loop
  616. else:
  617. loop {furnace1.loopList::*}:
  618. if {furnace1.%loop-value%.contents.ore} < 1:
  619. updateInventoryFuelIndicator(loop-value, 0, " I")
  620. removeFurnaceFromLoop(loop-value, 1)
  621.  
  622. else:
  623. if {furnace1.%loop-value%.contents.fuelingTime} is not set:
  624. remove 1 from {furnace1.%loop-value%.contents.fuel}
  625. updateItemInSlot(loop-value, "Fuel", 40, " I", 1)
  626.  
  627. add 1 to {furnace1.%loop-value%.smeltTime}
  628. add 1 to {furnace1.%loop-value%.fuelingTime}
  629. if "%{furnace1.%loop-value%.smeltTime}/2.0%" doesn't contain ".":
  630. if {furnace1.%loop-value%.smeltTime}/2 > 4:
  631. updateInventoryFuelIndicator(loop-value, 0, " I")
  632. else:
  633. updateInventoryFuelIndicator(loop-value, "%{furnace1.%loop-value%.smeltTime}/2%" parsed as an integer, " I")
  634. if {furnace1.%loop-value%.smeltTime} > 9:
  635. delete {furnace1.%loop-value%.smeltTime}
  636. remove 1 from {furnace1.%loop-value%.contents.ore}
  637. add 1 to {furnace1.%loop-value%.contents.ingot}
  638. setIngotType(loop-value, 1)
  639. updateItemInSlot(loop-value, "Ore", 38, " I", 1)
  640. updateItemInSlot(loop-value, "Ingot", 42, " I", 1)
  641. updateInventoryFuelIndicator(loop-value, 0, " I")
  642.  
  643.  
  644. if {furnace1.%loop-value%.fuelingTime} >= {furnace1.%Loop-value%.fuelingTimeMax}:
  645. if {furnace1.%loop-value%.contents.fuel} <= 0:
  646. delete {furnace1.%loop-value%.smeltTime}
  647. removeFurnaceFromLoop(loop-value, 1)
  648. updateInventoryFuelIndicator(loop-value, 0, " I")
  649. else:
  650. delete {furnace1.%loop-value%.fuelingTime}
  651. wait 1 second
  652.  
  653. # Returns how many ticks an item gives fuel
  654. function getFuelingTime(type: Item) :: integer:
  655. if {_type} is lava:
  656. return 20000
  657. else if {_type} is block of coal:
  658. return 16000
  659. else if {_type} is dried kelp block:
  660. return 4000
  661. else if {_type} is blaze rod:
  662. return 2400
  663. else if {_type} is coal or charcoal:
  664. return 1600
  665. else if {_type} is any boat or scaffolding:
  666. return 1200
  667. 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:
  668. return 300
  669. 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:
  670. return 200
  671. else if {_type} is bowl or any sapling or stick or any wool:
  672. return 100
  673. else if {_type} is any carpet:
  674. return 67
  675. else if {_type} is bamboo:
  676. return 50
  677. return 0
  678.  
  679. # Returns if the item can be smelted in the furnace, every smelt takes 10 seconds in a normal furnace
  680. function canSmelt(type: Item, tier: Integer) :: boolean:
  681. if {_type} is iron ore or gold ore or lapis ore or redstone ore or coal ore:
  682. return true
  683. else if {_tier} is 2:
  684. if {_type} is diamond ore or emerald ore or nether quartz ore:
  685. return true
  686.  
  687. return false
  688.  
  689. function canSmeltInFurnace(p: Player, item: Item) :: boolean:
  690. set {_furnaceId} to {inventory.%{_p}%.current}
  691. if {furnace1.%{_furnaceId}%.contents.oreType} is set:
  692. if "%type of {_item}%" is not "%{furnace1.%{_furnaceId}%.contents.oreType}%":
  693. return false
  694. if {furnace1.%{_furnaceId}%.contents.ingotType} is set:
  695. send "true" to {_p}
  696. if type of {_item} is coal ore:
  697. if type of {furnace1.%{_furnaceId}%.contents.ingotType} is coal:
  698. return true
  699. set {_item} to "%type of {_item}%"
  700. replace all " ore" in {_item} with " ingot"
  701. if {_item} is not "%{furnace1.%{_furnaceId}%.contents.ingotType}%":
  702. return false
  703. return true
  704.  
  705.  
  706.  
  707.  
  708.  
  709. on disable:
  710. if {furnace1.looping} is true:
  711. set {furnace1.looping} to false
  712. set {furnace1.loopStopped} to true
  713.  
  714. on enable:
  715. set {blacksmith.cost.helmet} to 5
  716. set {blacksmith.cost.chestplate} to 8
  717. set {blacksmith.cost.leggings} to 7
  718. set {blacksmith.cost.boots} to 4
  719. if {blacksmith.advancedMode} is not set:
  720. set {blacksmith.advancedMode} to true
  721. wait 1 second
  722. if {furnace1.loopStopped} is true:
  723. set {furnace1.looping} to true
  724. set {furnace1.loopStopped} to false
  725.  
Add Comment
Please, Sign In to add comment