Zeldaboy111

Furnace loop ]|[ Skript #383

Jan 21st, 2021
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 37.17 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}*0.95
  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},"I")
  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. if {_progressBar} <= 4:
  456. if {_progressBar} >= 0:
  457. loop {inventoryList.%{_furnaceId}%.furnace%{_furnaceTier}%::*}:
  458. set slot 20+{_progressBar} of loop-value's current inventory to gray stained glass pane named "&f%20*({_progressBar}+1)%%%"
  459. if {_progressBar} > 0:
  460. set slot 20+{_progressBar}-1 of loop-value's current inventory to lime stained glass pane named "&f%20*{_progressBar}%%%"
  461. loop 4-{_progressBar} times:
  462. 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)%%%"
  463.  
  464. function resetFuelIndicator(furnaceId: Location, furnaceTier: String):
  465. set {furnace1.%{_furnaceId}%.smeltTime} to 0
  466. loop {inventoryList.%{_furnaceId}%.furnace%{_furnaceTier}%::*}:
  467. loop 5 times:
  468. set slot 19 + loop-value-2 of loop-value-1's current inventory to gray stained glass pane named "&f%20*loop-value-2%%%"
  469. if {_furnaceTier} is " I":
  470. removeFurnaceFromLoop({_furnaceId})
  471. else:
  472. removeFurnaceFromLoop({_furnaceId})
  473.  
  474. function setIngotType(furnaceId: Location, tier: Number):
  475. if {furnace%{_tier}%.%{_furnaceId}%.contents.ingotType} is set:
  476. stop
  477. set {_type} to "%{furnace%{_tier}%.%{_furnaceId}%.contents.oreType}%"
  478. if {_tier} is 2:
  479. if {_type} is "diamond ore", "emerald ore" or "nether quartz ore":
  480. replace all " ore" in {_type} with " ingot"
  481. {furnace%{_tier}%.%{_furnaceId}%.contents.ingotType}
  482. stop
  483. if "%{_type}%" is "iron ore", "gold ore", "lapis ore" or "redstone ore":
  484. replace "ore" in {_type} with "ingot"
  485. set {furnace%{_tier}%.%{_furnaceId}%.contents.ingotType} to {_type} parsed as an item
  486. else if {_type} is "coal ore":
  487. set {furnace%{_tier}%.%{_furnaceId}%.contents.ingotType} to coal
  488.  
  489. function removeFurnaceFromLoop(furnaceId: Location):
  490. delete {furnace.%{_furnaceId}%.isAddedToLoop}
  491. delete {furnace.idList::%{furnace.idBinds::%{_furnaceId}%}%}
  492. delete {furnace.idBinds::%{_furnaceId}%}
  493. remove {_furnaceId} from {furnace%{_typeId}%.loopList::*}
  494.  
  495.  
  496. function loop_furnace1():
  497. if {furnace1.looping} is not true:
  498. set {furnace1.looping} to true
  499. while {furnace1.looping} is true:
  500. if size of {furnace1.loopList::*} is 0:
  501. set {furnace1.looping} to false
  502. stop loop
  503. else:
  504. set {_current} to 0
  505. loop {furnace1.loopList::*}:
  506. add 1 to {_current}
  507. set {_type} to {furnace.idList::%{_current}%}
  508. set {_tier} to getTierNumber({_type})
  509. broadcast "%{_type}% -> %{_tier}%"
  510. if {furnace%{_tier}%.%loop-value%.contents.ore} < 1:
  511. updateInventoryFuelIndicator(loop-value, 0, {_type})
  512. removeFurnaceFromLoop(loop-value)
  513.  
  514. else:
  515. if {furnace%{_tier}%.%loop-value%.contents.fuelingTime} is not set:
  516. remove 1 from {furnace%{_tier}%.%loop-value%.contents.fuel}
  517. updateItemInSlot(loop-value, "Fuel", 40, {_type}, 1)
  518.  
  519. add 1 to {furnace%{_tier}%.%loop-value%.smeltTime}
  520. add 1 to {furnace%{_tier}%.%loop-value%.fuelingTime}
  521. if "%{furnace%{_tier}%.%loop-value%.smeltTime}/2.0%" doesn't contain ".":
  522. if {furnace%{_tier}%.%loop-value%.smeltTime}/2 > 4:
  523. updateInventoryFuelIndicator(loop-value, 0, {_type})
  524. else:
  525. updateInventoryFuelIndicator(loop-value, "%{furnace%{_tier}%.%loop-value%.smeltTime}/2%" parsed as an integer, " I")
  526. if {furnace%{_tier}%.%loop-value%.smeltTime} > 9:
  527. delete {furnace%{_tier}%.%loop-value%.smeltTime}
  528. remove 1 from {furnace%{_tier}%.%loop-value%.contents.ore}
  529. add 1 to {furnace%{_tier}%.%loop-value%.contents.ingot}
  530. setIngotType(loop-value, 1)
  531. updateItemInSlot(loop-value, "Ore", 38, {_type}, 1)
  532. updateItemInSlot(loop-value, "Ingot", 42, {_type}, 1)
  533. updateInventoryFuelIndicator(loop-value, 0, {_type})
  534.  
  535.  
  536. if {furnace%{_tier}%.%loop-value%.fuelingTime} >= {furnace%{_tier}%.%Loop-value%.fuelingTimeMax}:
  537. if {furnace%{_tier}%.%loop-value%.contents.fuel} <= 0:
  538. delete {furnace%{_tier}%.%loop-value%.smeltTime}
  539. removeFurnaceFromLoop(loop-value)
  540. updateInventoryFuelIndicator(loop-value, 0, {_type})
  541. else:
  542. delete {furnace%{_tier}%.%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. guiFurnace2(player, location of clicked block)
  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. show 5 dust of anvil at location 0.0 meters above location of event-block
  642.  
  643.  
  644. else if clicked block is cauldron:
  645. if {furnace.%location of event-block%} is not true:
  646. if isFurnace1(location 1 meters below clicked block):
  647. set {furnace.%location of event-block%} to true
  648. show 5 dust of anvil at location 0.0 meters above location of event-block
  649. cancel event
  650.  
  651. else if clicked block is blast furnace:
  652. if {furnace.%location of event-block%} is not true:
  653. if isFurnace2(location of clicked block):
  654. set {furnace2.%location of event-block%} to true
  655. show 5 dust of anvil at location 0.0 meters above location of event-block
  656. cancel event
  657. send "WIP"
  658.  
  659. on break of smooth stone or iron block or diamond block:
  660. if {anvil.%location of event-block%} is true:
  661. set {_s} to 6
  662. loop all players in radius 6 around event-block:
  663. set {_v} to ({_s} - distance between loop-player and event-block)
  664. play sound "block.anvil.place" with volume {_v} and pitch 0 to loop-player
  665. delete {anvil.%location of event-block%}
  666. delete {anvil.%location of event-block%.tier}
  667. loop entities in radius 1 around event-block:
  668. if type of loop-entity is armor stand:
  669. kill loop-entity
  670.  
  671.  
  672. on inventory click:
  673. if type of clicked inventory is chest inventory:
  674. if inventory name of player's current inventory is {@tier1Furnace} or {@tier2Furnace}:
  675. cancel event
  676. if clicked slot is set:
  677. if clicked item is not air:
  678. set {_item} to player's cursor slot
  679. set {_leftClick} to false
  680. if click type is left mouse button:
  681. set {_leftClick} to true
  682. if {_item} is not air:
  683. if name of clicked item is "&a&lOre":
  684. if canSmelt({_item}, 1):
  685. if canSmeltInFurnace(player, {_item}):
  686. setItemInSlot(player, "Ore", clicked slot, clicked item, {_item}, true, {_leftClick})
  687. else if name of clicked item is "&a&lFuel":
  688. if getFuelingTime({_item}) > 0:
  689. setItemInSlot(player, "Fuel", clicked slot, clicked item, {_item}, true, {_leftClick})
  690. else if getFuelingTime(clicked item) > 0:
  691. if getFuelingTime({_item}) > 0:
  692. setItemInSlot(player, "Fuel", clicked slot, clicked item, {_item}, false, {_leftClick})
  693. else if canSmelt(clicked item, 1) is true:
  694. if canSmelt({_item}, 1):
  695. if canSmeltInFurnace(player, {_item}):
  696. setItemInSlot(player, "Ore", clicked slot, clicked item, {_item}, false, {_leftClick})
  697. else if clicked slot is 42:
  698. if type of clicked item is not lime stained glass pane:
  699. updateItemAndRemoveFromLoop(player, clicked item, clicked slot, 1, " %{inventory.%player%.tier}%", "Ingot", {_leftClick})
  700. else if getFuelingTime(clicked item) > 0:
  701. updateItemAndRemoveFromLoop(player, clicked item, clicked slot, 1, " %{inventory.%player%.tier}%", "Fuel", {_leftClick})
  702. else if canSmelt(clicked item, 1) is true:
  703. updateItemAndRemoveFromLoop(player, clicked item, clicked slot, 1, " %{inventory.%player%.tier}%", "Ore", {_leftClick})
  704.  
  705. else if inventory name of player's current inventory starts with "Anvil Tier ":
  706. cancel event
  707. if clicked slot is set:
  708. if clicked item is any helmet, any chestplate, any leggings or any boots:
  709. set {_item::*} to ("%type of clicked item%") split at " "
  710. tryCraftArmour(player, {_item::1}, {_item::2})
  711.  
  712. else if inventory name of player's current inventory is "Smithing":
  713. cancel event
  714. if clicked slot is set:
  715. if {blacksmith.smithing.%player%.chainmail} is true:
  716. if clicked item is iron nugget:
  717. if {blacksmith.smithing.%player%.stage} is 0:
  718. add 1 to {blacksmith.smithing.%player%.stage}
  719. 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
  720. play sound "entity.item.pickup" with volume 12 and pitch 2 to player
  721. else:
  722. userFailedMinigame(player)
  723.  
  724. else if clicked item is iron hoe:
  725. if {blacksmith.smithing.%player%.stage} is 1:
  726. add 1 to {blacksmith.smithing.%player%.stage}
  727. play sound "block.anvil.land" with volume 10 and pitch 1 to player
  728. setSmithingGui(player)
  729. else:
  730. userFailedMinigame(player)
  731. else:
  732. if clicked item is iron ingot:
  733. if {blacksmith.smithing.%player%.stage} is 0 or 2:
  734. play sound "block.anvil.use" with volume 12 and pitch 2 to player
  735. if {blacksmith.smithing.%player%.stage} is 0:
  736. 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
  737. else:
  738. 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."
  739. add 1 to {blacksmith.smithing.%player%.stage}
  740. else:
  741. userFailedMinigame(player)
  742.  
  743.  
  744. else if clicked item is iron axe:
  745. if {blacksmith.smithing.%player%.stage} is 1:
  746. add 1 to {blacksmith.smithing.%player%.stage}
  747. play sound "block.anvil.use" with volume 12 and pitch 2 to player
  748. 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."
  749. else:
  750. userFailedMinigame(player)
  751. else if clicked item is water bucket:
  752. if {blacksmith.smithing.%player%.stage} is 3:
  753. play sound "block.anvil.land" with volume 12 and pitch 2 to player
  754. give {blacksmith.smithing.%player%.result} to player
  755. close player's inventory
  756. else:
  757. userFailedMinigame(player)
  758.  
  759. on inventory close:
  760. if {inventory.%player%.name} is set:
  761. remove player from {inventoryList.%{inventory.%player%.current}%.%{inventory.%player%.name}%::*}
  762. delete {inventory.%player%.name}
  763. delete {inventory.%player%.current}
  764. else if {anvil.current.%player%} is set:
  765. delete {anvil.current.%player%}
  766.  
  767. on inventory drag:
  768. set {_tier1} to uncolored {@tier1Furnace}
  769. if {inventory.%player%.name} is "Anvil" or "%{_tier1}%" or "Furnace II":
  770. cancel event
  771. else if {anvil.current.%player%} is set:
  772. cancel event
  773.  
  774. on craft:
  775. if event-item is any helmet, any chestplate, any leggings or any boots:
  776. if "%event-item%" doesn't start with "leather":
  777. send "{@logo} You cannot craft this item in a crafting table!"
  778. cancel event
  779.  
  780. on right click on armor stand:
  781. if name of event-entity contains "Anvil" or "Tier I":
  782. cancel event
  783.  
  784.  
Advertisement
Add Comment
Please, Sign In to add comment