Zeldaboy111

Furnace klaar! ]|[ Skript #391

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