Zeldaboy111

Optimizen ]|[ Skript #374

Dec 20th, 2020
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 35.84 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.  
  280. function isFurnace2(loc: Location) :: boolean:
  281. if block at {_loc} is not blast furnace:
  282. return false
  283.  
  284. set {_layer1::*} to air, brick slab, red brick block, air, red brick block, air, red brick block and brick slab
  285. set {_layer2::*} to air, red brick stair, eastward red brick stair and southward red brick stair
  286. set {_x::*} to 1, 1, 0, -1, -1, -1, 0 and 1
  287. set {_z::*} to 0, 1, 1, 1, 0, -1, -1 and -1
  288.  
  289. set {_base} to -2
  290. if block at location at x-coordinate of {_loc} + {_x::1}, y-coordinate of {_loc}, z-coordinate of {_loc} + {_z::1} in world of {_loc} is {_layer1::1}:
  291. set {_base} to 0
  292.  
  293. else if block at location at x-coordinate of {_loc} + {_x::3}, y-coordinate of {_loc}, z-coordinate of {_loc} + {_z::3} in world of {_loc} is {_layer1::1}:
  294. set {_base} to 2
  295.  
  296. else if block at location at x-coordinate of {_loc} + {_x::5}, y-coordinate of {_loc}, z-coordinate of {_loc} + {_z::5} in world of {_loc} is {_layer1::1}:
  297. set {_base} to 4
  298.  
  299. else if block at location at x-coordinate of {_loc} + {_x::7}, y-coordinate of {_loc}, z-coordinate of {_loc} + {_z::7} in world of {_loc} is {_layer1::1}:
  300. set {_base} to 6
  301.  
  302. set {_size} to size of {_x::*}
  303. if {_base} is not -2:
  304. loop 7 times:
  305. set {_value} to getNextNumber({_base}, loop-value, {_size})
  306. if block at location at x-coordinate of {_loc} + {_x::%{_value}%}, y-coordinate of {_loc}, z-coordinate of {_loc} + {_z::%{_value}%} in world of {_loc} is not {_layer1::%loop-value%}:
  307. return false
  308.  
  309.  
  310. set {_facingAdjust::*} to 0, 4, 6 and 8
  311. if checkIfBlockIsStair({_base}, location 1 meters above {_loc}, "top "):
  312. loop 4 times:
  313. set {_value} to getNextNumber({_base}, loop-value*2, {_size}) - 1
  314. 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}
  315. set {_facing} to {_base}
  316. if {_facing} - {_facingAdjust::%loop-value%} >= 2:
  317. remove {_facingAdjust::%loop-value%} from {_facing}
  318. else:
  319. add {_facingAdjust::%loop-value%} to {_facing}
  320.  
  321. if loop-value is 1:
  322. if block at {_check} is not {_layer2::%loop-value%}:
  323. return false
  324. else if checkIfBlockIsStair({_facing} - 2, {_check}, "") is false:
  325. return false
  326.  
  327. if block at location 2 meters above {_loc} is not red brick block:
  328. return false
  329. else:
  330. return false
  331. else:
  332. return false
  333. return true
  334.  
  335. function guiFurnace1(p: Player, loc: Location):
  336. openGuiWithOutline({_p}, {_loc}, 6, {@tier1Furnace})
  337.  
  338. if {furnace1.%{_loc}%.contents.fuel} is not set:
  339. set {furnace1.%{_loc}%.contents.fuel} to 0
  340. if {furnace1.%{_loc}%.contents.ore} is not set:
  341. set {furnace1.%{_loc}%.contents.ore} to 0
  342. if {furnace1.%{_loc}%.contents.ingot} is not set:
  343. set {furnace1.%{_loc}%.contents.ingot} to 0
  344.  
  345. if {furnace1.%{_loc}%.contents.ingotType} is not set:
  346. set {furnace1.%{_loc}%.contents.ingot} to 0
  347. if {furnace1.%{_loc}%.contents.oreType} is not set:
  348. set {furnace1.%{_loc}%.contents.ore} to 0
  349. if {furnace1.%{_loc}%.contents.fuelType} is not set:
  350. set {furnace1.%{_loc}%.contents.fuel} to 0
  351.  
  352. set {furnace1.%{_loc}%.fuelingTimeMax} to 0
  353. if {furnace1.%{_loc}%.contents.fuelType} is set:
  354. set {furnace1.%{_loc}%.fuelingTimeMax} to getFuelingTime({furnace1.%{_loc}%.contents.fuelType}) / 20
  355.  
  356. set slot 38 of {_p}'s current inventory to lime stained glass pane named "&a&lOre"
  357. set slot 40 of {_p}'s current inventory to lime stained glass pane named "&a&lFuel"
  358. set slot 42 of {_p}'s current inventory to lime stained glass pane named "&a&lIngot"
  359.  
  360. if {furnace1.%{_loc}%.contents.ore} > 0:
  361. set slot 38 of {_p}'s current inventory to ("%{furnace1.%{_loc}%.contents.ore}% %{furnace1.%{_loc}%.contents.oreType}%" parsed as an item)
  362.  
  363. if {furnace1.%{_loc}%.contents.fuel} > 0:
  364. set slot 40 of {_p}'s current inventory to ("%{furnace1.%{_loc}%.contents.fuel}% %{furnace1.%{_loc}%.contents.fuelType}%" parsed as an item)
  365.  
  366. if {furnace1.%{_loc}%.contents.ingot} > 0:
  367. set slot 42 of {_p}'s current inventory to ("%{furnace1.%{_loc}%.contents.ingot}% %{furnace1.%{_loc}%.contents.ingotType}%" parsed as an item)
  368.  
  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.  
  372. set {_progressBar} to "%{furnace1.%{_loc}%.smeltTime}/2.0%"
  373. if {_progressBar} contains ".":
  374. set {_progressBar::*} to {_progressBar} split at "."
  375. set {_progressBar} to {_progressBar::1}
  376.  
  377. loop ({_progressBar} parsed as an integer) times:
  378. set slot 20+loop-value -1 of {_p}'s current inventory to lime stained glass pane named "&f%20*loop-value%%%"
  379.  
  380.  
  381. function getNextNumber(base: Number, addToDefault: Number, max: Number) :: number:
  382. set {_value} to {_base}+{_addToDefault} > {_max} ? {_addToDefault} - ({_max}-{_base}) : {_base} + {_addToDefault}
  383. return {_value}
  384.  
  385. function checkIfBlockIsStair(direction: Number, loc: Location, startValue: String) :: boolean:
  386. set {_list::*} to "westward red brick stair", "red brick stair", "eastward red brick stair" and "southward red brick stair"
  387. set {_dir} to {_facing}/2+1 > 4 ? ({_facing}/2+1)-4 : {_facing}/2+1
  388. if "%block at location of {_loc}%" is "%{_startValue}%%{_list::%{_dir}%}%":
  389. return true
  390. return false
  391.  
  392. function setItemInSlot(player: Player, type: String, slot: Number, clickedItem: Item, item: Item, startLoop: Boolean, leftClick: Boolean):
  393. if {_type} is not "Ore" or "Fuel" or "Ingot":
  394. stop
  395. set {_typeLower} to {_type} in lower case
  396. if {_leftClick} is false:
  397. if {furnace1.%{inventory.%{_p}%.current}%.contents.%{_typeLower}%} >= 64:
  398. stop
  399. add 1 to {furnace1.%{inventory.%{_p}%.current}%.contents.%{_typeLower}%}
  400. set {furnace1.%{inventory.%{_p}%.current}%.contents.%{_typeLower}%Type} to "%type of {_item}%"
  401. set {_item} to "%item amount of {_item}-1% %type of {_item}%"
  402. else:
  403. if {furnace1.%{inventory.%{_p}%.current}%.contents.%{_typeLower}%} >= 64:
  404. stop
  405. if {furnace1.%{inventory.%{_p}%.current}%.contents.%{_typeLower}%} + item amount of {_item} > 64:
  406. set {_item} to "%(item amount of {_item} - (64 - {furnace1.%{inventory.%{_p}%.current}%.contents.%{_typeLower}%}))% %type of {_item}%"
  407. set {furnace1.%{inventory.%{_p}%.current}%.contents.%{_typeLower}%} to 64
  408. set {_p}'s cursor to ("%{_item}%" parsed as an item)
  409. else:
  410. add item amount of {_item} to {furnace1.%{inventory.%{_p}%.current}%.contents.%{_typeLower}%}
  411. set {furnace1.%{inventory.%{_p}%.current}%.contents.%{_typeLower}%Type} to "%type of {_item}%"
  412. set {_item} to air
  413. set {_typeId} to 2
  414. set {_typeString} to " II"
  415. if {inventory.%{_p}%.name} is uncolored {@tier1Furnace}:
  416. set {_typeId} to 1
  417. set {_typeString} to " I"
  418.  
  419. set {_p}'s cursor to ("%{_item}%" parsed as an item)
  420. updateItemInSlot({inventory.%{_p}%.current}, {_type}, {_slot}, {_typeString}, {_typeId})
  421. if {_startLoop}:
  422. if {furnace.%{inventory.%{_p}%.current}%.isAddedToLoop} is not true:
  423. add {inventory.%{_p}%.current} to {furnace1.loopList::*}
  424. loop_furnace1()
  425.  
  426. function updateItemInSlot(furnaceId: Location, type: String, slot: Number, furnaceTier: String, typeId: integer):
  427. set {_typeLower} to {_type} in lower case
  428. loop {inventoryList.%{_furnaceId}%.furnace%{_furnaceTier}%::*}:
  429. 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)
  430. if {furnace%{_typeId}%.%{_furnaceId}%.contents.%{_typeLower}%} <= 0:
  431. set slot {_slot} of loop-value's current inventory to lime stained glass pane named "&a&l%{_type}%"
  432.  
  433. function updateItemAndRemoveFromLoop(p: Player, item: Item, slot: Number, furnaceTier: Integer, furnaceTierString: String, itemName: String, leftClick: Boolean):
  434. set {_nameLower} to {_itemName} in lower case
  435. set {_amount} to {furnace1.%{inventory.%{_p}%.current}%.contents.%{_nameLower}%}
  436. set {_removedAmount} to {_amount}
  437. if {_leftClick} is false:
  438. set {_removedAmount} to "%{_amount} / 2%" parsed as an integer
  439. if {_removedAmount} is {_amount}:
  440. set {_removedAmount} to 1
  441. add "%({_amount}-1) / 2%" parsed as an integer to {_removedAmount}
  442. set {_item} to "%{_amount} - {_removedAmount} + 1% %type of {_item}%" parsed as an item
  443. else:
  444. set {_item} to "%{_amount} - {_removedAmount}% %type of {_item}%" parsed as an item
  445.  
  446. set {_p}'s cursor slot to {_item}
  447. set {furnace1.%{inventory.%{_p}%.current}%.contents.%{_nameLower}%} to {_amount}-{_removedAmount}
  448. if {_amount}-{_removedAmount} <= 0:
  449. delete {furnace1.%{inventory.%{_p}%.current}%.contents.%{_nameLower}%Type}
  450. set slot ({_slot}) of {_p}'s current inventory to lime stained glass pane named "&a&l%{_itemName}%"
  451. if {_nameLower} is "ore" or "fuel":
  452. resetFuelIndicator({inventory.%{_p}%.current}, {_furnaceTierString})
  453. else:
  454. set slot ({_slot}) of {_p}'s current inventory to "%{_amount}-{_removedAmount}% %{furnace1.%{inventory.%{_p}%.current}%.contents.%{_nameLower}%Type}%" parsed as an item
  455.  
  456. function updateInventoryFuelIndicator(furnaceId: Location, progressBar: Integer, furnaceTier: String):
  457. if {_progressBar} <= 4:
  458. if {_progressBar} >= 0:
  459. loop {inventoryList.%{_furnaceId}%.furnace%{_furnaceTier}%::*}:
  460. set slot 20+{_progressBar} of loop-value's current inventory to gray stained glass pane named "&f%20*({_progressBar}+1)%%%"
  461. if {_progressBar} > 0:
  462. set slot 20+{_progressBar}-1 of loop-value's current inventory to lime stained glass pane named "&f%20*{_progressBar}%%%"
  463. loop 4-{_progressBar} times:
  464. 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)%%%"
  465.  
  466. function resetFuelIndicator(furnaceId: Location, furnaceTier: String):
  467. set {furnace1.%{_furnaceId}%.smeltTime} to 0
  468. loop {inventoryList.%{_furnaceId}%.furnace%{_furnaceTier}%::*}:
  469. loop 5 times:
  470. set slot 19 + loop-value-2 of loop-value-1's current inventory to gray stained glass pane named "&f%20*loop-value-2%%%"
  471. if {_furnaceTier} is " I":
  472. removeFurnaceFromLoop({_furnaceId}, 1)
  473. else:
  474. removeFurnaceFromLoop({_furnaceId}, 2)
  475.  
  476. function setIngotType(furnaceId: Location, tier: Number):
  477. delete {furnace%{_tier}%.%{_furnaceId}%.contents.ingotType}
  478. if {furnace%{_tier}%.%{_furnaceId}%.contents.ingotType} is set:
  479. stop
  480. set {_type} to "%{furnace%{_tier}%.%{_furnaceId}%.contents.oreType}%"
  481. if {_tier} is 2:
  482. if {_type} is "diamond ore", "emerald ore" or "nether quartz ore":
  483. replace all " ore" in {_type} with " ingot"
  484. {furnace%{_tier}%.%{_furnaceId}%.contents.ingotType}
  485. stop
  486. if "%{_type}%" is "iron ore", "gold ore", "lapis ore" or "redstone ore":
  487. replace "ore" in {_type} with "ingot"
  488. set {furnace%{_tier}%.%{_furnaceId}%.contents.ingotType} to {_type} parsed as an item
  489. else if {_type} is "coal ore":
  490. set {furnace%{_tier}%.%{_furnaceId}%.contents.ingotType} to coal
  491.  
  492. function removeFurnaceFromLoop(furnaceId: Location, typeId: integer):
  493. delete {furnace.%{_furnaceId}%.isAddedToLoop}
  494. remove {_furnaceId} from {furnace%{_typeId}%.loopList::*}
  495.  
  496.  
  497.  
  498.  
  499. function loop_furnace1():
  500. set {furnace1.looping} to false
  501. if {furnace1.looping} is not true:
  502. set {furnace1.looping} to true
  503. while {furnace1.looping} is true:
  504. if size of {furnace1.loopList::*} is 0:
  505. set {furnace1.looping} to false
  506. stop loop
  507. else:
  508. loop {furnace1.loopList::*}:
  509. if {furnace1.%loop-value%.contents.ore} < 1:
  510. updateInventoryFuelIndicator(loop-value, 0, " I")
  511. removeFurnaceFromLoop(loop-value, 1)
  512.  
  513. else:
  514. if {furnace1.%loop-value%.contents.fuelingTime} is not set:
  515. remove 1 from {furnace1.%loop-value%.contents.fuel}
  516. updateItemInSlot(loop-value, "Fuel", 40, " I", 1)
  517.  
  518. add 1 to {furnace1.%loop-value%.smeltTime}
  519. add 1 to {furnace1.%loop-value%.fuelingTime}
  520. if "%{furnace1.%loop-value%.smeltTime}/2.0%" doesn't contain ".":
  521. if {furnace1.%loop-value%.smeltTime}/2 > 4:
  522. updateInventoryFuelIndicator(loop-value, 0, " I")
  523. else:
  524. updateInventoryFuelIndicator(loop-value, "%{furnace1.%loop-value%.smeltTime}/2%" parsed as an integer, " I")
  525. if {furnace1.%loop-value%.smeltTime} > 9:
  526. delete {furnace1.%loop-value%.smeltTime}
  527. remove 1 from {furnace1.%loop-value%.contents.ore}
  528. add 1 to {furnace1.%loop-value%.contents.ingot}
  529. setIngotType(loop-value, 1)
  530. updateItemInSlot(loop-value, "Ore", 38, " I", 1)
  531. updateItemInSlot(loop-value, "Ingot", 42, " I", 1)
  532. updateInventoryFuelIndicator(loop-value, 0, " I")
  533.  
  534.  
  535. if {furnace1.%loop-value%.fuelingTime} >= {furnace1.%Loop-value%.fuelingTimeMax}:
  536. if {furnace1.%loop-value%.contents.fuel} <= 0:
  537. delete {furnace1.%loop-value%.smeltTime}
  538. removeFurnaceFromLoop(loop-value, 1)
  539. updateInventoryFuelIndicator(loop-value, 0, " I")
  540. else:
  541. delete {furnace1.%loop-value%.fuelingTime}
  542. wait 1 second
  543.  
  544.  
  545. #||======================================================||
  546. #|| ________ ________ _ _ _______ _____ ||
  547. #|| | ____\ \ / / ____| \ | |__ __/ ____| ||
  548. #|| | |__ \ \ / /| |__ | \| | | | | (___ ||
  549. #|| | __| \ \/ / | __| | . ` | | | \___ \ ||
  550. #|| | |____ \ / | |____| |\ | | | ____) | ||
  551. #|| |______| \/ |______|_| \_| |_| |_____/ ||
  552. #|| ||
  553. #||======================================================||
  554.  
  555. on disable:
  556. if {furnace1.looping} is true:
  557. set {furnace1.looping} to false
  558. set {furnace1.loopStopped} to true
  559.  
  560. on enable:
  561. set {blacksmith.cost.helmet} to 5
  562. set {blacksmith.cost.chestplate} to 8
  563. set {blacksmith.cost.leggings} to 7
  564. set {blacksmith.cost.boots} to 4
  565. if {blacksmith.advancedMode} is not set:
  566. set {blacksmith.advancedMode} to true
  567. wait 1 second
  568. if {furnace1.loopStopped} is true:
  569. set {furnace1.looping} to true
  570. set {furnace1.loopStopped} to false
  571.  
  572. on rightclick on smooth stone:
  573. if player is not sneaking:
  574. if {anvil.%location of clicked block%} is true:
  575. set {anvil.current.%player%} to 1
  576. openAnvilGui(player)
  577. cancel event
  578.  
  579. on rightclick on iron block:
  580. if player is not sneaking:
  581. if {anvil.%location of clicked block%} is true:
  582. set {anvil.current.%player%} to 2
  583. openAnvilGui(player)
  584. cancel event
  585.  
  586. on rightclick on diamond block:
  587. if player is not sneaking:
  588. if {anvil.%location of clicked block%} is true:
  589. set {anvil.current.%player%} to 3
  590. openAnvilGui(player)
  591. cancel event
  592.  
  593. on rightclick on cauldron:
  594. if {furnace.%location of event-block%} is true:
  595. if isFurnace1(location 1 meters below clicked block):
  596. cancel event
  597. guiFurnace1(player, location of clicked block)
  598.  
  599. else:
  600. delete {furnace1.%location of clicked block%.contents.fuel}
  601. delete {furnace1.%location of clicked block%.contents.ore}
  602. delete {furnace1.%location of clicked block%.contents.ingot}
  603. delete {furnace.%location of event-block%}
  604.  
  605. on rightclick on blast furnace:
  606. if {furnace2.%location of event-block%} is true:
  607. if isFurnace2(location of clicked block):
  608. cancel event
  609. send "WIP"
  610. else:
  611. delete {furnace2.%location of event-block%}
  612.  
  613. on rightclick holding stone axe:
  614. if clicked block is smooth stone or iron block or diamond block:
  615. if {anvil.%location of event-block%} is not true:
  616. set {anvil.%location of event-block%} to true
  617. set {_tier} to "Tier I"
  618. if clicked block is smooth stone:
  619. set {anvil.%location of event-block%.tier} to 1
  620. else if clicked block is iron block:
  621. set {anvil.%location of event-block%.tier} to 2
  622. set {_tier} to "Tier II"
  623. else:
  624. set {anvil.%location of event-block%.tier} to 3
  625. set {_tier} to "Tier III"
  626.  
  627. set {_s} to 6
  628. loop all players in radius 6 around event-block:
  629. set {_v} to ({_s} - distance between loop-player and event-block)
  630. play sound "block.anvil.place" with volume {_v} and pitch 0 to loop-player
  631.  
  632. send "{@logo} Successfully created an anvil of %{_tier}%."
  633. summon armor stand at location 0.6 meters below event-block
  634. set name of last spawned armor stand to "&7Anvil"
  635. add "{Invisible:1b,NoGravity:1b,NoAI:1b,CustomNameVisible:1}" to NBT of last spawned armor stand
  636.  
  637. summon armor stand at location 0.9 meters below event-block
  638. set name of last spawned armor stand to "&7%{_tier}%"
  639. add "{Invisible:1b,NoGravity:1b,NoAI:1b,CustomNameVisible:1}" to NBT of last spawned armor stand
  640.  
  641. else if clicked block is cauldron:
  642. if {furnace.%location of event-block%} is not true:
  643. if isFurnace1(location 1 meters below clicked block):
  644. set {furnace.%location of event-block%} to true
  645. cancel event
  646.  
  647. else if clicked block is blast furnace:
  648. if {furnace.%location of event-block%} is not true:
  649. if isFurnace2(location of clicked block):
  650. set {furnace2.%location of event-block%} to true
  651. cancel event
  652. send "WIP"
  653.  
  654. on break of smooth stone or iron block or diamond block:
  655. if {anvil.%location of event-block%} is true:
  656. set {_s} to 6
  657. loop all players in radius 6 around event-block:
  658. set {_v} to ({_s} - distance between loop-player and event-block)
  659. play sound "block.anvil.place" with volume {_v} and pitch 0 to loop-player
  660. delete {anvil.%location of event-block%}
  661. delete {anvil.%location of event-block%.tier}
  662. loop entities in radius 1 around event-block:
  663. if type of loop-entity is armor stand:
  664. kill loop-entity
  665.  
  666.  
  667. on inventory click:
  668. if type of clicked inventory is chest inventory:
  669. if inventory name of player's current inventory is {@tier1Furnace}:
  670. cancel event
  671. if clicked slot is set:
  672. if clicked item is not air:
  673. set {_item} to player's cursor slot
  674. set {_leftClick} to false
  675. if click type is left mouse button:
  676. set {_leftClick} to true
  677. if {_item} is not air:
  678. if name of clicked item is "&a&lOre":
  679. if canSmelt({_item}, 1):
  680. if canSmeltInFurnace(player, {_item}):
  681. setItemInSlot(player, "Ore", clicked slot, clicked item, {_item}, true, {_leftClick})
  682. else if name of clicked item is "&a&lFuel":
  683. if getFuelingTime({_item}) > 0:
  684. setItemInSlot(player, "Fuel", clicked slot, clicked item, {_item}, true, {_leftClick})
  685. else if getFuelingTime(clicked item) > 0:
  686. if getFuelingTime({_item}) > 0:
  687. setItemInSlot(player, "Fuel", clicked slot, clicked item, {_item}, false, {_leftClick})
  688. else if canSmelt(clicked item, 1) is true:
  689. if canSmelt({_item}, 1):
  690. if canSmeltInFurnace(player, {_item}):
  691. setItemInSlot(player, "Ore", clicked slot, clicked item, {_item}, false, {_leftClick})
  692. else if clicked slot is 42:
  693. if type of clicked item is not lime stained glass pane:
  694. updateItemAndRemoveFromLoop(player, clicked item, clicked slot, 1, " I", "Ingot", {_leftClick})
  695. else if getFuelingTime(clicked item) > 0:
  696. updateItemAndRemoveFromLoop(player, clicked item, clicked slot, 1, " I", "Fuel", {_leftClick})
  697. else if canSmelt(clicked item, 1) is true:
  698. updateItemAndRemoveFromLoop(player, clicked item, clicked slot, 1, " I", "Ore", {_leftClick})
  699.  
  700. else if inventory name of player's current inventory starts with "Anvil Tier ":
  701. cancel event
  702. if clicked slot is set:
  703. if clicked item is any helmet, any chestplate, any leggings or any boots:
  704. set {_item::*} to ("%type of clicked item%") split at " "
  705. tryCraftArmour(player, {_item::1}, {_item::2})
  706.  
  707. else if inventory name of player's current inventory is "Smithing":
  708. cancel event
  709. if clicked slot is set:
  710. if {blacksmith.smithing.%player%.chainmail} is true:
  711. if clicked item is iron nugget:
  712. if {blacksmith.smithing.%player%.stage} is 0:
  713. add 1 to {blacksmith.smithing.%player%.stage}
  714. 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
  715. play sound "entity.item.pickup" with volume 12 and pitch 2 to player
  716. else:
  717. userFailedMinigame(player)
  718.  
  719. else if clicked item is iron hoe:
  720. if {blacksmith.smithing.%player%.stage} is 1:
  721. add 1 to {blacksmith.smithing.%player%.stage}
  722. play sound "block.anvil.land" with volume 10 and pitch 1 to player
  723. setSmithingGui(player)
  724. else:
  725. userFailedMinigame(player)
  726. else:
  727. if clicked item is iron ingot:
  728. if {blacksmith.smithing.%player%.stage} is 0 or 2:
  729. play sound "block.anvil.use" with volume 12 and pitch 2 to player
  730. if {blacksmith.smithing.%player%.stage} is 0:
  731. 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
  732. else:
  733. 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."
  734. add 1 to {blacksmith.smithing.%player%.stage}
  735. else:
  736. userFailedMinigame(player)
  737.  
  738.  
  739. else if clicked item is iron axe:
  740. if {blacksmith.smithing.%player%.stage} is 1:
  741. add 1 to {blacksmith.smithing.%player%.stage}
  742. play sound "block.anvil.use" with volume 12 and pitch 2 to player
  743. 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."
  744. else:
  745. userFailedMinigame(player)
  746. else if clicked item is water bucket:
  747. if {blacksmith.smithing.%player%.stage} is 3:
  748. play sound "block.anvil.land" with volume 12 and pitch 2 to player
  749. give {blacksmith.smithing.%player%.result} to player
  750. close player's inventory
  751. else:
  752. userFailedMinigame(player)
  753.  
  754. on inventory close:
  755. if {inventory.%player%.name} is set:
  756. remove player from {inventoryList.%{inventory.%player%.current}%.%{inventory.%player%.name}%::*}
  757. delete {inventory.%player%.name}
  758. delete {inventory.%player%.current}
  759. else if {anvil.current.%player%} is set:
  760. delete {anvil.current.%player%}
  761.  
  762. on inventory drag:
  763. set {_tier1} to uncolored {@tier1Furnace}
  764. if {inventory.%player%.name} is "Anvil" or "%{_tier1}%" or "Furnace II":
  765. cancel event
  766. else if {anvil.current.%player%} is set:
  767. cancel event
  768.  
  769. on craft:
  770. if event-item is any helmet, any chestplate, any leggings or any boots:
  771. if "%event-item%" doesn't start with "leather":
  772. send "{@logo} You cannot craft this item in a crafting table!"
  773. cancel event
  774.  
  775. on right click on armor stand:
  776. if name of event-entity contains "Anvil" or "Tier I":
  777. cancel event
  778.  
Advertisement
Add Comment
Please, Sign In to add comment