Zeldaboy111

Anvil Tier II en III ]|[ Skript #373

Dec 17th, 2020 (edited)
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 35.91 KB | None | 0 0
  1. #requires: SkQuery, SkRayFall, Skellett, SkBee, TuSKe
  2. options:
  3. logo: &6&lBS&8:&7
  4. tier1Furnace: "&8Furnace I"
  5. permission: "blacksmith"
  6.  
  7. # ||=============================================================||
  8. # || _____ ____ __ __ __ __ _ _ _____ ||
  9. # || / ____/ __ \| \/ | \/ | /\ | \ | | __ \ ||
  10. # || | | | | | | \ / | \ / | / \ | \| | | | | ||
  11. # || | | | | | | |\/| | |\/| | / /\ \ | . ` | | | | ||
  12. # || | |___| |__| | | | | | | |/ ____ \| |\ | |__| | ||
  13. # || \_____\____/|_| |_|_| |_/_/ \_\_| \_|_____/ ||
  14. # || ||
  15. # ||=============================================================||
  16.  
  17. command /blacksmith [<text>] [<text>]:
  18. aliases: /bs
  19. trigger:
  20. if player doesn't have permission {@permission}:
  21. send "{@logo} You do not have enough permissions to do this!"
  22. else:
  23. if arg-1 is "advanced":
  24. if arg-2 is "true" or "enable":
  25. if {blacksmith.advancedMode} is true:
  26. send "{@logo} The &eadvanced mode &7is already enabled."
  27. else:
  28. set {blacksmith.advancedMode} to true
  29. send "{@logo} You have enabled the &eadvanced mode&7."
  30. else if arg-2 is "false" or "disable":
  31. if {blacksmith.advancedMode} is false:
  32. send "{@logo} The &eadvanced mode &7is already disabled."
  33. else:
  34. set {blacksmith.advancedMode} to false
  35. send "{@logo} You have disabled the &eadvanced mode&7."
  36. else:
  37. send "{@logo} Incorrect usage! &e/blacksmith advanced <true | false>&7."
  38. else:
  39. send "{@logo} Incorrect usage! &e/blacksmith advanced <true | false>&7."
  40.  
  41.  
  42.  
  43. #||==============================================================||
  44. #|| _____ ______ _ _ ______ _____ _ ||
  45. #|| / ____| ____| \ | | ____| __ \ /\ | | ||
  46. #|| | | __| |__ | \| | |__ | |__) | / \ | | ||
  47. #|| | | |_ | __| | . ` | __| | _ / / /\ \ | | ||
  48. #|| | |__| | |____| |\ | |____| | \ \ / ____ \| |____ ||
  49. #|| \_____|______|_| \_|______|_| \_\/_/ \_\______| ||
  50. #|| ||
  51. #||==============================================================||
  52. function outlineGui(player: Player):
  53. loop 9 times:
  54. set slot loop-value - 1 of {_player}'s current inventory to gray stained glass pane named "&7"
  55. set slot 54 - loop-value of {_player}'s current inventory to gray stained glass pane named "&7"
  56. loop 5 times:
  57. set slot loop-value * 9 of {_player}'s current inventory to gray stained glass pane named "&7"
  58. set slot loop-value * 9 -1 of {_player}'s current inventory to gray stained glass pane named "&7"
  59.  
  60. function openGuiWithOutline(player: Player, loc: Location, rows: Number, name: String):
  61. open chest with {_rows} rows named {_name} to {_player}
  62. # make seperate function called "openFurnaceGui", init variables there
  63. set {inventory.%{_player}%.name} to uncolored {_name}
  64. set {inventory.%{_player}%.current} to {_loc}
  65. add {_p} to {inventoryList.%{_loc}%.%{_name}%::*}
  66. wait 2 ticks
  67. outlineGui({_player})
  68.  
  69. function openAnvilGui(player: Player):
  70. if {anvil.current.%{_player}%} is 1:
  71. openAnvilGui_1({_player})
  72. else if {anvil.current.%{_player}%} is 2:
  73. openAnvilGui_2({_player})
  74. else:
  75. openAnvilGui_3({_player})
  76.  
  77. function openAnvilGui_1(player: Player):
  78. open chest with 6 rows named "Anvil Tier I" to {_player}
  79. wait 2 ticks
  80. outlineGui({_player})
  81. setArmorSetInSlot({_player}, 12, "golden", "&6Golden", "&e", "Gold Ingot")
  82. setArmorSetInSlot({_player}, 14, "chainmail", "&fChain", "&7", "Iron Nugget")
  83.  
  84. function openAnvilGui_2(player: Player):
  85. open chest with 6 rows named "Anvil Tier II" to {_player}
  86. wait 2 ticks
  87. outlineGui({_player})
  88. setArmorSetInSlot({_player}, 11, "golden", "&6Golden", "&e", "Gold Ingot")
  89. setArmorSetInSlot({_player}, 13, "chainmail", "&fChain", "&7", "Iron Nugget")
  90. setArmorSetInSlot({_player}, 15, "iron", "&fIron", "&7", "Iron Ingot")
  91.  
  92. function openAnvilGui_3(player: Player):
  93. open chest with 6 rows named "Anvil Tier III" to {_player}
  94. wait 2 ticks
  95. outlineGui({_player})
  96. setArmorSetInSlot({_player}, 11, "golden", "&6Golden", "&e", "Gold Ingot")
  97. setArmorSetInSlot({_player}, 12, "chainmail", "&fChain", "&7", "Iron Nugget")
  98. setArmorSetInSlot({_player}, 14, "iron", "&fIron", "&7", "Iron Ingot")
  99. setArmorSetInSlot({_player}, 15, "diamond", "&3Diamond", "&b", "Diamond")
  100.  
  101. function setArmorSetInSlot(player: Player, startValue: Number, type: String, typeName: String, costColor: String, cost: String):
  102. set slot {_startValue} of {_player}'s current inventory to ("%{_type}% helmet" parsed as an item) named "%{_typeName}% Helmet" with lore "&8" and "&7Cost&8: %{_costColor}%5 %{_cost}%" without any NBT
  103. set slot {_startValue}+9 of {_player}'s current inventory to ("%{_type}% chestplate" parsed as an item) named "%{_typeName}% Chestplate" with lore "&8" and "&7Cost&8: %{_costColor}%8 %{_cost}%" without any NBT
  104. set slot {_startValue}+18 of {_player}'s current inventory to ("%{_type}% leggings" parsed as an item) named "%{_typeName}% Leggings" with lore "&8" and "&7Cost&8: %{_costColor}%7 %{_cost}%" without any NBT
  105. set slot {_startValue}+27 of {_player}'s current inventory to ("%{_type}% boots" parsed as an item) named "%{_typeName}% Boots" with lore "&8" and "&7Cost&8: %{_costColor}%4 %{_cost}%" without any NBT
  106.  
  107.  
  108. function removeItemFromPlayer(player: Player, item: Item, amount: Number):
  109. if {_amount} > 0:
  110. if {_item} is set:
  111. if gamemode of {_player} is survival or adventure:
  112. remove "%{_amount}% %{_item}%" parsed as an item from {_player}'s inventory
  113.  
  114.  
  115. #||===============================================||
  116. #|| _ ___ _______ _ ||
  117. #|| /\ | \ | \ \ / /_ _| | ||
  118. #|| / \ | \| |\ \ / / | | | | ||
  119. #|| / /\ \ | . ` | \ \/ / | | | | ||
  120. #|| / ____ \| |\ | \ / _| |_| |____ ||
  121. #|| /_/ \_\_| \_| \/ |_____|______| ||
  122. #|| ||
  123. #||===============================================||
  124.  
  125. function getRecipeItemFromType(type: String) :: item:
  126. if {_type} is "chain":
  127. return "iron nugget" parsed as an item
  128. else if {_type} is "diamond":
  129. return "diamond" parsed as an item
  130. return "%{_type}% ingot" parsed as an item
  131.  
  132. function tryCraftArmour(player: Player, type: String, piece: String):
  133. set {_result} to "%{_type}% %{_piece}%" parsed as an item
  134. set {_recipeItem} to "air" parsed as an item
  135. set {_recipeAmount} to 0
  136. if {_player}'s gamemode is survival or adventure:
  137. set {_recipeItem} to getRecipeItemFromType({_type})
  138. set {_recipeAmount} to {blacksmith.cost.%{_piece}%}
  139. set {_recipeAmountFromPlayer} to amount of {_recipeItem} in {_player}'s inventory
  140. if {_recipeAmountFromPlayer} < {_recipeAmount}:
  141. play "ENTITY_ITEM_BREAK" to {_player} at volume 10
  142. stop
  143.  
  144. else if {_player}'s gamemode is spectator:
  145. stop
  146. if {blacksmith.advancedMode} is false:
  147. give {_result} to {_player}
  148. remove {_recipeAmount} of {_recipeItem} from {_player}'s inventory
  149. play sound "block.anvil.use" with volume 10 and pitch 1 to {_player}
  150. else:
  151. playBlacksmithMinigame({_player}, {_recipeItem}, {_recipeAmount}, {_result})
  152.  
  153. function playBlacksmithMinigame(player: Player, costItem: Item, cost: Number, result: Item):
  154. set {blacksmith.smithing.%{_player}%.costItem} to {_costItem}
  155. set {blacksmith.smithing.%{_player}%.cost} to {_cost}
  156. set {blacksmith.smithing.%{_player}%.result} to {_result}
  157. set {blacksmith.smithing.%{_player}%.chainmail} to false
  158. set {blacksmith.smithing.%{_player}%.stage} to 0
  159.  
  160. open chest with 6 rows named "Smithing" to {_player}
  161. outlineGui({_player})
  162. set {_result1} to "%type of {_result}%"
  163. if {_result1} contains "chain":
  164. set {inventory.%{_player}%.name} to uncolored "Smithing"
  165. set {blacksmith.smithing.%{_player}%.chainmail} to true
  166. set {_random::*} to 39 and 41
  167. set {_slot} to random element out of {_random::*}
  168. remove {_slot} from {_random::*}
  169. set {_slot1} to random element out of {_random::*}
  170.  
  171. set slot {_slot} of {_player}'s current inventory to iron nugget named "&fCreate Rings"
  172. set slot {_slot1} of {_player}'s current inventory to iron hoe named "&fJoin Rings" without any NBT
  173. 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."
  174. 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
  175. else:
  176. setSmithingGui({_player})
  177.  
  178. function setSmithingGui(player: Player):
  179. set {blacksmith.smithing.%{_player}%.chainmail} to false
  180. set {blacksmith.smithing.%{_player}%.stage} to 0
  181. set {inventory.%{_player}%.name} to uncolored "Smithing II"
  182.  
  183. open chest with 6 rows named "Smithing" to {_player}
  184. outlineGui({_player})
  185. set {_result1} to "%type of {blacksmith.smithing.%{_player}%.result}%"
  186. 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."
  187. 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
  188.  
  189. set {_random::*} to 38, 40 and 42
  190. set {_slot} to random element out of {_random::*}
  191. remove {_slot} from {_random::*}
  192. set {_slot1} to random element out of {_random::*}
  193. remove {_slot1} from {_random::*}
  194. set {_slot2} to random element out of {_random::*}
  195.  
  196. set slot {_slot} of {_player}'s current inventory to iron ingot named "&a&lBend" without any NBT
  197. set slot {_slot1} of {_player}'s current inventory to iron axe named "&a&lHammer" without any NBT
  198. set slot {_slot2} of {_player}'s current inventory to water bucket named "&a&lCool" without any NBT
  199.  
  200. function userFailedMinigame(player: Player):
  201. removeItemFromPlayer({_player}, {blacksmith.smithing.%{_player}%.costItem}, {blacksmith.smithing.%{_player}%.cost})
  202. play sound "entity.item.break" with volume 10 and pitch 1 to {_player}
  203. close {_player}'s inventory
  204.  
  205.  
  206.  
  207. #||=============================================================||
  208. #|| ______ _ _ _____ _ _ _____ ______ ||
  209. #|| | ____| | | | __ \| \ | | /\ / ____| ____| ||
  210. #|| | |__ | | | | |__) | \| | / \ | | | |__ ||
  211. #|| | __| | | | | _ /| . ` | / /\ \| | | __| ||
  212. #|| | | | |__| | | \ \| |\ |/ ____ \ |____| |____ ||
  213. #|| |_| \____/|_| \_\_| \_/_/ \_\_____|______| ||
  214. #|| ||
  215. #||=============================================================||
  216. function getFuelingTime(type: Item) :: integer:
  217. if {_type} is lava:
  218. return 20000
  219. else if {_type} is block of coal:
  220. return 16000
  221. else if {_type} is dried kelp block:
  222. return 4000
  223. else if {_type} is blaze rod:
  224. return 2400
  225. else if {_type} is coal or charcoal:
  226. return 1600
  227. else if {_type} is any boat or scaffolding:
  228. return 1200
  229. 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:
  230. return 300
  231. 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:
  232. return 200
  233. else if {_type} is bowl or any sapling or stick or any wool:
  234. return 100
  235. else if {_type} is any carpet:
  236. return 67
  237. else if {_type} is bamboo:
  238. return 50
  239. return 0
  240.  
  241. # Returns if the item can be smelted in the furnace, every smelt takes 10 seconds in a normal furnace
  242. function canSmelt(type: Item, tier: Integer) :: boolean:
  243. if {_type} is iron ore or gold ore or lapis ore or redstone ore or coal ore:
  244. return true
  245. else if {_tier} is 2:
  246. if {_type} is diamond ore or emerald ore or nether quartz ore:
  247. return true
  248.  
  249. return false
  250.  
  251. function canSmeltInFurnace(p: Player, item: Item) :: boolean:
  252. set {_furnaceId} to {inventory.%{_p}%.current}
  253. if {furnace1.%{_furnaceId}%.contents.oreType} is set:
  254. if "%type of {_item}%" is not "%{furnace1.%{_furnaceId}%.contents.oreType}%":
  255. return false
  256. if {furnace1.%{_furnaceId}%.contents.ingotType} is set:
  257. send "true" to {_p}
  258. if type of {_item} is coal ore:
  259. if type of {furnace1.%{_furnaceId}%.contents.ingotType} is coal:
  260. return true
  261. set {_item} to "%type of {_item}%"
  262. replace all " ore" in {_item} with " ingot"
  263. if {_item} is not "%{furnace1.%{_furnaceId}%.contents.ingotType}%":
  264. return false
  265. return true
  266.  
  267.  
  268. function isFurnace1(below: Location) :: boolean:
  269. if block at {_below} is campfire:
  270. set {_xAdjust::*} to 1, 1, 1, 0, 0, -1, -1 and -1
  271. set {_zAdjust::*} to 1, 0, -1, 1, -1, 1, 0 and -1
  272. loop 8 times:
  273. 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}
  274. if block at {_checkLoc} is not red brick block:
  275. return false
  276. else:
  277. return false
  278. return true
  279.  
  280.  
  281. function isFurnace2(loc: Location) :: boolean:
  282. if block at {_loc} is not blast furnace:
  283. return false
  284.  
  285. set {_layer1::*} to air, brick slab, red brick block, air, red brick block, air, red brick block and brick slab
  286. set {_layer2::*} to air, red brick stair, eastward red brick stair and southward red brick stair
  287. set {_x::*} to 1, 1, 0, -1, -1, -1, 0 and 1
  288. set {_z::*} to 0, 1, 1, 1, 0, -1, -1 and -1
  289.  
  290. set {_base} to -2
  291. 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}:
  292. set {_base} to 0
  293.  
  294. 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}:
  295. set {_base} to 2
  296.  
  297. 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}:
  298. set {_base} to 4
  299.  
  300. 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}:
  301. set {_base} to 6
  302.  
  303. set {_size} to size of {_x::*}
  304. if {_base} is not -2:
  305. loop 7 times:
  306. set {_value} to getNextNumber({_base}, loop-value, {_size})
  307. 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%}:
  308. return false
  309.  
  310.  
  311. set {_facingAdjust::*} to 0, 4, 6 and 8
  312. if checkIfBlockIsStair({_base}, location 1 meters above {_loc}, "top "):
  313. loop 4 times:
  314. set {_value} to getNextNumber({_base}, loop-value*2, {_size}) - 1
  315. 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}
  316. set {_facing} to {_base}
  317. if {_facing} - {_facingAdjust::%loop-value%} >= 2:
  318. remove {_facingAdjust::%loop-value%} from {_facing}
  319. else:
  320. add {_facingAdjust::%loop-value%} to {_facing}
  321.  
  322. if loop-value is 1:
  323. if block at {_check} is not {_layer2::%loop-value%}:
  324. return false
  325. else if checkIfBlockIsStair({_facing} - 2, {_check}, "") is false:
  326. return false
  327.  
  328. if block at location 2 meters above {_loc} is not red brick block:
  329. return false
  330. else:
  331. return false
  332. else:
  333. return false
  334. return true
  335.  
  336. function guiFurnace1(p: Player, loc: Location):
  337. openGuiWithOutline({_p}, {_loc}, 6, {@tier1Furnace})
  338.  
  339. if {furnace1.%{_loc}%.contents.fuel} is not set:
  340. set {furnace1.%{_loc}%.contents.fuel} to 0
  341. if {furnace1.%{_loc}%.contents.ore} is not set:
  342. set {furnace1.%{_loc}%.contents.ore} to 0
  343. if {furnace1.%{_loc}%.contents.ingot} is not set:
  344. set {furnace1.%{_loc}%.contents.ingot} to 0
  345.  
  346. if {furnace1.%{_loc}%.contents.ingotType} is not set:
  347. set {furnace1.%{_loc}%.contents.ingot} to 0
  348. if {furnace1.%{_loc}%.contents.oreType} is not set:
  349. set {furnace1.%{_loc}%.contents.ore} to 0
  350. if {furnace1.%{_loc}%.contents.fuelType} is not set:
  351. set {furnace1.%{_loc}%.contents.fuel} to 0
  352.  
  353. set {furnace1.%{_loc}%.fuelingTimeMax} to 0
  354. if {furnace1.%{_loc}%.contents.fuelType} is set:
  355. set {furnace1.%{_loc}%.fuelingTimeMax} to getFuelingTime({furnace1.%{_loc}%.contents.fuelType}) / 20
  356.  
  357. set slot 38 of {_p}'s current inventory to lime stained glass pane named "&a&lOre"
  358. set slot 40 of {_p}'s current inventory to lime stained glass pane named "&a&lFuel"
  359. set slot 42 of {_p}'s current inventory to lime stained glass pane named "&a&lIngot"
  360.  
  361. if {furnace1.%{_loc}%.contents.ore} > 0:
  362. set slot 38 of {_p}'s current inventory to ("%{furnace1.%{_loc}%.contents.ore}% %{furnace1.%{_loc}%.contents.oreType}%" parsed as an item)
  363.  
  364. if {furnace1.%{_loc}%.contents.fuel} > 0:
  365. set slot 40 of {_p}'s current inventory to ("%{furnace1.%{_loc}%.contents.fuel}% %{furnace1.%{_loc}%.contents.fuelType}%" parsed as an item)
  366.  
  367. if {furnace1.%{_loc}%.contents.ingot} > 0:
  368. set slot 42 of {_p}'s current inventory to ("%{furnace1.%{_loc}%.contents.ingot}% %{furnace1.%{_loc}%.contents.ingotType}%" parsed as an item)
  369.  
  370. loop 5 times:
  371. set slot 19 + loop-value of {_p}'s current inventory to gray stained glass pane named "&f%20*loop-value%%%"
  372.  
  373. set {_progressBar} to "%{furnace1.%{_loc}%.smeltTime}/2.0%"
  374. if {_progressBar} contains ".":
  375. set {_progressBar::*} to {_progressBar} split at "."
  376. set {_progressBar} to {_progressBar::1}
  377.  
  378. loop ({_progressBar} parsed as an integer) times:
  379. set slot 20+loop-value -1 of {_p}'s current inventory to lime stained glass pane named "&f%20*loop-value%%%"
  380.  
  381.  
  382. function getNextNumber(base: Number, addToDefault: Number, max: Number) :: number:
  383. set {_value} to {_base}+{_addToDefault} > {_max} ? {_addToDefault} - ({_max}-{_base}) : {_base} + {_addToDefault}
  384. return {_value}
  385.  
  386. function checkIfBlockIsStair(direction: Number, loc: Location, startValue: String) :: boolean:
  387. set {_list::*} to "westward red brick stair", "red brick stair", "eastward red brick stair" and "southward red brick stair"
  388. set {_dir} to {_facing}/2+1 > 4 ? ({_facing}/2+1)-4 : {_facing}/2+1
  389. if "%block at location of {_loc}%" is "%{_startValue}%%{_list::%{_dir}%}%":
  390. return true
  391. return false
  392.  
  393. function setItemInSlot(player: Player, type: String, slot: Number, clickedItem: Item, item: Item, startLoop: Boolean, leftClick: Boolean):
  394. if {_type} is not "Ore" or "Fuel" or "Ingot":
  395. stop
  396. set {_typeLower} to {_type} in lower case
  397. if {_leftClick} is false:
  398. if {furnace1.%{inventory.%{_p}%.current}%.contents.%{_typeLower}%} >= 64:
  399. stop
  400. add 1 to {furnace1.%{inventory.%{_p}%.current}%.contents.%{_typeLower}%}
  401. set {furnace1.%{inventory.%{_p}%.current}%.contents.%{_typeLower}%Type} to "%type of {_item}%"
  402. set {_item} to "%item amount of {_item}-1% %type of {_item}%"
  403. else:
  404. if {furnace1.%{inventory.%{_p}%.current}%.contents.%{_typeLower}%} >= 64:
  405. stop
  406. if {furnace1.%{inventory.%{_p}%.current}%.contents.%{_typeLower}%} + item amount of {_item} > 64:
  407. set {_item} to "%(item amount of {_item} - (64 - {furnace1.%{inventory.%{_p}%.current}%.contents.%{_typeLower}%}))% %type of {_item}%"
  408. set {furnace1.%{inventory.%{_p}%.current}%.contents.%{_typeLower}%} to 64
  409. set {_p}'s cursor to ("%{_item}%" parsed as an item)
  410. else:
  411. add item amount of {_item} to {furnace1.%{inventory.%{_p}%.current}%.contents.%{_typeLower}%}
  412. set {furnace1.%{inventory.%{_p}%.current}%.contents.%{_typeLower}%Type} to "%type of {_item}%"
  413. set {_item} to air
  414. set {_typeId} to 2
  415. set {_typeString} to " II"
  416. if {inventory.%{_p}%.name} is uncolored {@tier1Furnace}:
  417. set {_typeId} to 1
  418. set {_typeString} to " I"
  419.  
  420. set {_p}'s cursor to ("%{_item}%" parsed as an item)
  421. updateItemInSlot({inventory.%{_p}%.current}, {_type}, {_slot}, {_typeString}, {_typeId})
  422. if {_startLoop}:
  423. if {furnace.%{inventory.%{_p}%.current}%.isAddedToLoop} is not true:
  424. add {inventory.%{_p}%.current} to {furnace1.loopList::*}
  425. loop_furnace1()
  426.  
  427. function updateItemInSlot(furnaceId: Location, type: String, slot: Number, furnaceTier: String, typeId: integer):
  428. set {_typeLower} to {_type} in lower case
  429. loop {inventoryList.%{_furnaceId}%.furnace%{_furnaceTier}%::*}:
  430. 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)
  431. if {furnace%{_typeId}%.%{_furnaceId}%.contents.%{_typeLower}%} <= 0:
  432. set slot {_slot} of loop-value's current inventory to lime stained glass pane named "&a&l%{_type}%"
  433.  
  434. function updateItemAndRemoveFromLoop(p: Player, item: Item, slot: Number, furnaceTier: Integer, furnaceTierString: String, itemName: String, leftClick: Boolean):
  435. set {_nameLower} to {_itemName} in lower case
  436. set {_amount} to {furnace1.%{inventory.%{_p}%.current}%.contents.%{_nameLower}%}
  437. set {_removedAmount} to {_amount}
  438. if {_leftClick} is false:
  439. set {_removedAmount} to "%{_amount} / 2%" parsed as an integer
  440. if {_removedAmount} is {_amount}:
  441. set {_removedAmount} to 1
  442. add "%({_amount}-1) / 2%" parsed as an integer to {_removedAmount}
  443. set {_item} to "%{_amount} - {_removedAmount} + 1% %type of {_item}%" parsed as an item
  444. else:
  445. set {_item} to "%{_amount} - {_removedAmount}% %type of {_item}%" parsed as an item
  446.  
  447. set {_p}'s cursor slot to {_item}
  448. set {furnace1.%{inventory.%{_p}%.current}%.contents.%{_nameLower}%} to {_amount}-{_removedAmount}
  449. if {_amount}-{_removedAmount} <= 0:
  450. delete {furnace1.%{inventory.%{_p}%.current}%.contents.%{_nameLower}%Type}
  451. set slot ({_slot}) of {_p}'s current inventory to lime stained glass pane named "&a&l%{_itemName}%"
  452. if {_nameLower} is "ore" or "fuel":
  453. resetFuelIndicator({inventory.%{_p}%.current}, {_furnaceTierString})
  454. else:
  455. set slot ({_slot}) of {_p}'s current inventory to "%{_amount}-{_removedAmount}% %{furnace1.%{inventory.%{_p}%.current}%.contents.%{_nameLower}%Type}%" parsed as an item
  456.  
  457. function updateInventoryFuelIndicator(furnaceId: Location, progressBar: Integer, furnaceTier: String):
  458. if {_progressBar} <= 4:
  459. if {_progressBar} >= 0:
  460. loop {inventoryList.%{_furnaceId}%.furnace%{_furnaceTier}%::*}:
  461. set slot 20+{_progressBar} of loop-value's current inventory to gray stained glass pane named "&f%20*({_progressBar}+1)%%%"
  462. if {_progressBar} > 0:
  463. set slot 20+{_progressBar}-1 of loop-value's current inventory to lime stained glass pane named "&f%20*{_progressBar}%%%"
  464. loop 4-{_progressBar} times:
  465. 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)%%%"
  466.  
  467. function resetFuelIndicator(furnaceId: Location, furnaceTier: String):
  468. set {furnace1.%{_furnaceId}%.smeltTime} to 0
  469. loop {inventoryList.%{_furnaceId}%.furnace%{_furnaceTier}%::*}:
  470. loop 5 times:
  471. set slot 19 + loop-value-2 of loop-value-1's current inventory to gray stained glass pane named "&f%20*loop-value-2%%%"
  472. if {_furnaceTier} is " I":
  473. removeFurnaceFromLoop({_furnaceId}, 1)
  474. else:
  475. removeFurnaceFromLoop({_furnaceId}, 2)
  476.  
  477. function setIngotType(furnaceId: Location, tier: Number):
  478. delete {furnace%{_tier}%.%{_furnaceId}%.contents.ingotType}
  479. if {furnace%{_tier}%.%{_furnaceId}%.contents.ingotType} is set:
  480. stop
  481. set {_type} to "%{furnace%{_tier}%.%{_furnaceId}%.contents.oreType}%"
  482. if {_tier} is 2:
  483. if {_type} is "diamond ore", "emerald ore" or "nether quartz ore":
  484. replace all " ore" in {_type} with " ingot"
  485. {furnace%{_tier}%.%{_furnaceId}%.contents.ingotType}
  486. stop
  487. if "%{_type}%" is "iron ore", "gold ore", "lapis ore" or "redstone ore":
  488. replace "ore" in {_type} with "ingot"
  489. set {furnace%{_tier}%.%{_furnaceId}%.contents.ingotType} to {_type} parsed as an item
  490. else if {_type} is "coal ore":
  491. set {furnace%{_tier}%.%{_furnaceId}%.contents.ingotType} to coal
  492.  
  493. function removeFurnaceFromLoop(furnaceId: Location, typeId: integer):
  494. delete {furnace.%{_furnaceId}%.isAddedToLoop}
  495. remove {_furnaceId} from {furnace%{_typeId}%.loopList::*}
  496.  
  497.  
  498.  
  499.  
  500. function loop_furnace1():
  501. set {furnace1.looping} to false
  502. if {furnace1.looping} is not true:
  503. set {furnace1.looping} to true
  504. while {furnace1.looping} is true:
  505. if size of {furnace1.loopList::*} is 0:
  506. set {furnace1.looping} to false
  507. stop loop
  508. else:
  509. loop {furnace1.loopList::*}:
  510. if {furnace1.%loop-value%.contents.ore} < 1:
  511. updateInventoryFuelIndicator(loop-value, 0, " I")
  512. removeFurnaceFromLoop(loop-value, 1)
  513.  
  514. else:
  515. if {furnace1.%loop-value%.contents.fuelingTime} is not set:
  516. remove 1 from {furnace1.%loop-value%.contents.fuel}
  517. updateItemInSlot(loop-value, "Fuel", 40, " I", 1)
  518.  
  519. add 1 to {furnace1.%loop-value%.smeltTime}
  520. add 1 to {furnace1.%loop-value%.fuelingTime}
  521. if "%{furnace1.%loop-value%.smeltTime}/2.0%" doesn't contain ".":
  522. if {furnace1.%loop-value%.smeltTime}/2 > 4:
  523. updateInventoryFuelIndicator(loop-value, 0, " I")
  524. else:
  525. updateInventoryFuelIndicator(loop-value, "%{furnace1.%loop-value%.smeltTime}/2%" parsed as an integer, " I")
  526. if {furnace1.%loop-value%.smeltTime} > 9:
  527. delete {furnace1.%loop-value%.smeltTime}
  528. remove 1 from {furnace1.%loop-value%.contents.ore}
  529. add 1 to {furnace1.%loop-value%.contents.ingot}
  530. setIngotType(loop-value, 1)
  531. updateItemInSlot(loop-value, "Ore", 38, " I", 1)
  532. updateItemInSlot(loop-value, "Ingot", 42, " I", 1)
  533. updateInventoryFuelIndicator(loop-value, 0, " I")
  534.  
  535.  
  536. if {furnace1.%loop-value%.fuelingTime} >= {furnace1.%Loop-value%.fuelingTimeMax}:
  537. if {furnace1.%loop-value%.contents.fuel} <= 0:
  538. delete {furnace1.%loop-value%.smeltTime}
  539. removeFurnaceFromLoop(loop-value, 1)
  540. updateInventoryFuelIndicator(loop-value, 0, " I")
  541. else:
  542. delete {furnace1.%loop-value%.fuelingTime}
  543. wait 1 second
  544.  
  545.  
  546. #||======================================================||
  547. #|| ________ ________ _ _ _______ _____ ||
  548. #|| | ____\ \ / / ____| \ | |__ __/ ____| ||
  549. #|| | |__ \ \ / /| |__ | \| | | | | (___ ||
  550. #|| | __| \ \/ / | __| | . ` | | | \___ \ ||
  551. #|| | |____ \ / | |____| |\ | | | ____) | ||
  552. #|| |______| \/ |______|_| \_| |_| |_____/ ||
  553. #|| ||
  554. #||======================================================||
  555.  
  556. on disable:
  557. if {furnace1.looping} is true:
  558. set {furnace1.looping} to false
  559. set {furnace1.loopStopped} to true
  560.  
  561. on enable:
  562. set {blacksmith.cost.helmet} to 5
  563. set {blacksmith.cost.chestplate} to 8
  564. set {blacksmith.cost.leggings} to 7
  565. set {blacksmith.cost.boots} to 4
  566. if {blacksmith.advancedMode} is not set:
  567. set {blacksmith.advancedMode} to true
  568. wait 1 second
  569. if {furnace1.loopStopped} is true:
  570. set {furnace1.looping} to true
  571. set {furnace1.loopStopped} to false
  572.  
  573. on rightclick on smooth stone:
  574. if player is not sneaking:
  575. if {anvil.%location of clicked block%} is true:
  576. set {anvil.current.%player%} to 1
  577. openAnvilGui(player)
  578. cancel event
  579.  
  580. on rightclick on iron block:
  581. if player is not sneaking:
  582. if {anvil.%location of clicked block%} is true:
  583. set {anvil.current.%player%} to 2
  584. openAnvilGui(player)
  585. cancel event
  586.  
  587. on rightclick on diamond block:
  588. if player is not sneaking:
  589. if {anvil.%location of clicked block%} is true:
  590. set {anvil.current.%player%} to 3
  591. openAnvilGui(player)
  592. cancel event
  593.  
  594. on rightclick on cauldron:
  595. if {furnace.%location of event-block%} is true:
  596. if isFurnace1(location 1 meters below clicked block):
  597. cancel event
  598. guiFurnace1(player, location of clicked block)
  599.  
  600. else:
  601. delete {furnace1.%location of clicked block%.contents.fuel}
  602. delete {furnace1.%location of clicked block%.contents.ore}
  603. delete {furnace1.%location of clicked block%.contents.ingot}
  604. delete {furnace.%location of event-block%}
  605.  
  606. on rightclick on blast furnace:
  607. if {furnace2.%location of event-block%} is true:
  608. if isFurnace2(location of clicked block):
  609. cancel event
  610. send "WIP"
  611. else:
  612. delete {furnace2.%location of event-block%}
  613.  
  614. on rightclick holding stone axe:
  615. if clicked block is smooth stone or iron block or diamond block:
  616. if {anvil.%location of event-block%} is not true:
  617. set {anvil.%location of event-block%} to true
  618. set {_tier} to "Tier I"
  619. if clicked block is smooth stone:
  620. set {anvil.%location of event-block%.tier} to 1
  621. else if clicked block is iron block:
  622. set {anvil.%location of event-block%.tier} to 2
  623. set {_tier} to "Tier II"
  624. else:
  625. set {anvil.%location of event-block%.tier} to 3
  626. set {_tier} to "Tier III"
  627.  
  628. set {_s} to 6
  629. loop all players in radius 6 around event-block:
  630. set {_v} to ({_s} - distance between loop-player and event-block)
  631. play sound "block.anvil.place" with volume {_v} and pitch 0 to loop-player
  632.  
  633. send "{@logo} Successfully created an anvil of %{_tier}%."
  634. summon armor stand at location 0.6 meters below event-block
  635. set name of last spawned armor stand to "&7Anvil"
  636. add "{Invisible:1b,NoGravity:1b,NoAI:1b,CustomNameVisible:1}" to NBT of last spawned armor stand
  637.  
  638. summon armor stand at location 0.9 meters below event-block
  639. set name of last spawned armor stand to "&7%{_tier}%"
  640. add "{Invisible:1b,NoGravity:1b,NoAI:1b,CustomNameVisible:1}" to NBT of last spawned armor stand
  641.  
  642. else if clicked block is cauldron:
  643. if {furnace.%location of event-block%} is not true:
  644. if isFurnace1(location 1 meters below clicked block):
  645. set {furnace.%location of event-block%} to true
  646. cancel event
  647.  
  648. else if clicked block is blast furnace:
  649. if {furnace.%location of event-block%} is not true:
  650. if isFurnace2(location of clicked block):
  651. set {furnace2.%location of event-block%} to true
  652. cancel event
  653. send "WIP"
  654.  
  655. on break of smooth stone or iron block or diamond block:
  656. if {anvil.%location of event-block%} is true:
  657. set {_s} to 6
  658. loop all players in radius 6 around event-block:
  659. set {_v} to ({_s} - distance between loop-player and event-block)
  660. play sound "block.anvil.place" with volume {_v} and pitch 0 to loop-player
  661. delete {anvil.%location of event-block%}
  662. delete {anvil.%location of event-block%.tier}
  663. loop entities in radius 1 around event-block:
  664. if type of loop-entity is armor stand:
  665. kill loop-entity
  666.  
  667.  
  668. on inventory click:
  669. if type of clicked inventory is chest inventory:
  670. if inventory name of player's current inventory is {@tier1Furnace}:
  671. cancel event
  672. if clicked slot is set:
  673. if clicked item is not air:
  674. set {_item} to player's cursor slot
  675. set {_leftClick} to false
  676. if click type is left mouse button:
  677. set {_leftClick} to true
  678. if {_item} is not air:
  679. if name of clicked item is "&a&lOre":
  680. if canSmelt({_item}, 1):
  681. if canSmeltInFurnace(player, {_item}):
  682. setItemInSlot(player, "Ore", clicked slot, clicked item, {_item}, true, {_leftClick})
  683. else if name of clicked item is "&a&lFuel":
  684. if getFuelingTime({_item}) > 0:
  685. setItemInSlot(player, "Fuel", clicked slot, clicked item, {_item}, true, {_leftClick})
  686. else if getFuelingTime(clicked item) > 0:
  687. if getFuelingTime({_item}) > 0:
  688. setItemInSlot(player, "Fuel", clicked slot, clicked item, {_item}, false, {_leftClick})
  689. else if canSmelt(clicked item, 1) is true:
  690. if canSmelt({_item}, 1):
  691. if canSmeltInFurnace(player, {_item}):
  692. setItemInSlot(player, "Ore", clicked slot, clicked item, {_item}, false, {_leftClick})
  693. else if clicked slot is 42:
  694. if type of clicked item is not lime stained glass pane:
  695. updateItemAndRemoveFromLoop(player, clicked item, clicked slot, 1, " I", "Ingot", {_leftClick})
  696. else if getFuelingTime(clicked item) > 0:
  697. updateItemAndRemoveFromLoop(player, clicked item, clicked slot, 1, " I", "Fuel", {_leftClick})
  698. else if canSmelt(clicked item, 1) is true:
  699. updateItemAndRemoveFromLoop(player, clicked item, clicked slot, 1, " I", "Ore", {_leftClick})
  700.  
  701. else if inventory name of player's current inventory starts with "Anvil Tier ":
  702. #Iron armour crafting does not work? And Armorstand interact cancel
  703. cancel event
  704. if clicked slot is set:
  705. if clicked item is any helmet, any chestplate, any leggings or any boots:
  706. set {_item::*} to ("%type of clicked item%") split at " "
  707. tryCraftArmour(player, {_item::1}, {_item::2})
  708.  
  709. else if inventory name of player's current inventory is "Smithing":
  710. cancel event
  711. if clicked slot is set:
  712. if {blacksmith.smithing.%player%.chainmail} is true:
  713. if clicked item is iron nugget:
  714. if {blacksmith.smithing.%player%.stage} is 0:
  715. add 1 to {blacksmith.smithing.%player%.stage}
  716. 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
  717. play sound "entity.item.pickup" with volume 12 and pitch 2 to player
  718. else:
  719. userFailedMinigame(player)
  720.  
  721. else if clicked item is iron hoe:
  722. if {blacksmith.smithing.%player%.stage} is 1:
  723. add 1 to {blacksmith.smithing.%player%.stage}
  724. play sound "block.anvil.land" with volume 10 and pitch 1 to player
  725. setSmithingGui(player)
  726. else:
  727. userFailedMinigame(player)
  728. else:
  729. if clicked item is iron ingot:
  730. if {blacksmith.smithing.%player%.stage} is 0 or 2:
  731. play sound "block.anvil.use" with volume 12 and pitch 2 to player
  732. if {blacksmith.smithing.%player%.stage} is 0:
  733. 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
  734. else:
  735. 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."
  736. add 1 to {blacksmith.smithing.%player%.stage}
  737. else:
  738. userFailedMinigame(player)
  739.  
  740.  
  741. else if clicked item is iron axe:
  742. if {blacksmith.smithing.%player%.stage} is 1:
  743. add 1 to {blacksmith.smithing.%player%.stage}
  744. play sound "block.anvil.use" with volume 12 and pitch 2 to player
  745. 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."
  746. else:
  747. userFailedMinigame(player)
  748. else if clicked item is water bucket:
  749. if {blacksmith.smithing.%player%.stage} is 3:
  750. play sound "block.anvil.land" with volume 12 and pitch 2 to player
  751. give {blacksmith.smithing.%player%.result} to player
  752. close player's inventory
  753. else:
  754. userFailedMinigame(player)
  755.  
  756. on inventory close:
  757. if {inventory.%player%.name} is set:
  758. remove player from {inventoryList.%{inventory.%player%.current}%.%{inventory.%player%.name}%::*}
  759. delete {inventory.%player%.name}
  760. delete {inventory.%player%.current}
  761. else if {anvil.current.%player%} is set:
  762. delete {anvil.current.%player%}
  763.  
  764. on inventory drag:
  765. set {_tier1} to uncolored {@tier1Furnace}
  766. if {inventory.%player%.name} is "Anvil" or "%{_tier1}%" or "Furnace II":
  767. cancel event
  768. else if {anvil.current.%player%} is set:
  769. cancel event
  770.  
  771. on craft:
  772. if event-item is any helmet, any chestplate, any leggings or any boots:
  773. if "%event-item%" doesn't start with "leather":
  774. send "{@logo} You cannot craft this item in a crafting table!"
  775. cancel event
  776.  
  777.  
Add Comment
Please, Sign In to add comment