Zeldaboy111

Bugfixing ]|[ Skript #387

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