Zeldaboy111

Furnace loop ]|[ Skript #384

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