Zeldaboy111

Furnace Tier II optimizen (2/2) ]|[ Skript #376

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