Zeldaboy111

Bugfixing ]|[ Skript #390

Feb 14th, 2021
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 38.42 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.  
  19. command /blacksmith [<text>] [<text>]:
  20. aliases: /bs
  21. trigger:
  22. if player doesn't have permission {@permission}:
  23. send "{@logo} You do not have enough permissions to do this!"
  24. else:
  25. if arg-1 is "advanced":
  26. if arg-2 is "true" or "enable":
  27. if {blacksmith.advancedMode} is true:
  28. send "{@logo} The &eadvanced mode &7is already enabled."
  29. else:
  30. set {blacksmith.advancedMode} to true
  31. send "{@logo} You have enabled the &eadvanced mode&7."
  32. else if arg-2 is "false" or "disable":
  33. if {blacksmith.advancedMode} is false:
  34. send "{@logo} The &eadvanced mode &7is already disabled."
  35. else:
  36. set {blacksmith.advancedMode} to false
  37. send "{@logo} You have disabled the &eadvanced mode&7."
  38. else:
  39. send "{@logo} Incorrect usage! &e/blacksmith advanced <true | false>&7."
  40. else:
  41. send "{@logo} Incorrect usage! &e/blacksmith advanced <true | false>&7."
  42.  
  43.  
  44.  
  45. #||==============================================================||
  46. #|| _____ ______ _ _ ______ _____ _ ||
  47. #|| / ____| ____| \ | | ____| __ \ /\ | | ||
  48. #|| | | __| |__ | \| | |__ | |__) | / \ | | ||
  49. #|| | | |_ | __| | . ` | __| | _ / / /\ \ | | ||
  50. #|| | |__| | |____| |\ | |____| | \ \ / ____ \| |____ ||
  51. #|| \_____|______|_| \_|______|_| \_\/_/ \_\______| ||
  52. #|| ||
  53. #||==============================================================||
  54. function outlineGui(player: Player):
  55. loop 9 times:
  56. set slot loop-value - 1 of {_player}'s current inventory to gray stained glass pane named "&7"
  57. set slot 54 - loop-value of {_player}'s current inventory to gray stained glass pane named "&7"
  58. loop 5 times:
  59. set slot loop-value * 9 of {_player}'s current inventory to gray stained glass pane named "&7"
  60. set slot loop-value * 9 -1 of {_player}'s current inventory to gray stained glass pane named "&7"
  61.  
  62. function openGuiWithOutline(player: Player, loc: Location, rows: Number, name: String):
  63. open chest with {_rows} rows named {_name} to {_player}
  64. set {inventory.%{_player}%.name} to uncolored {_name}
  65. set {inventory.%{_player}%.current} to {_loc}
  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 of {_type} = lava bucket:
  218. return 20000
  219. else if type of {_type} = coal block:
  220. return 16000
  221. else if type of {_type} = dried kelp block:
  222. return 4000
  223. else if type of {_type} = blaze rod:
  224. return 2400
  225. else if type of {_type} = coal or charcoal:
  226. return 1600
  227. else if type of {_type} = any boat or scaffolding:
  228. return 1200
  229. else if type of {_type} = 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} = 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} = bowl or any sapling or stick or any wool:
  234. return 100
  235. else if type of {_type} = any carpet:
  236. return 67
  237. else if type of {_type} = 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 of {_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 of {_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 {inventory.%{_p}%.tier} to {_tier}
  360. set {inventory.%{_p}%.tierNumber} to {_tierNumber}
  361. if {furnace%{_tierNumber}%.%{_loc}%.contents.fuelType} is set:
  362. if {furnace%{_tierNumber}%.%{_loc}%.fuelingTimeMax} is not 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}%.%{inventory.%{_player}%.current}%.fuelingTimeMax} to getFuelingTime({furnace%{inventory.%{_player}%.tierNumber}%.%{inventory.%{_player}%.current}%.contents.fuelType} parsed as an item) / 20
  419. if {_typeString} is " II":
  420. set {furnace%{inventory.%{_player}%.tierNumber}%.%{inventory.%{_player}%.current}%.fuelingTimeMax} to {furnace%{inventory.%{_player}%.tierNumber}%.%{inventory.%{_player}%.current}%.fuelingTimeMax}*1.05
  421. #else if {_type} is "Ingot":
  422. # if {_tier} is "II": #tier is not a valid var
  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. # ingots and items are not updating
  436. set {_typeLower} to {_type} in lower case
  437. loop {inventoryList.%{_furnaceId}%.furnace%{_furnaceTier}%::*}:
  438. 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)
  439. if {furnace%{_typeId}%.%{_furnaceId}%.contents.%{_typeLower}%} <= 0:
  440. set slot {_slot} of loop-value's current inventory to lime stained glass pane named "&a&l%{_type}%"
  441.  
  442. function updateItemAndRemoveFromLoop(p: Player, item: Item, slot: Number, furnaceTier: Integer, furnaceTierString: String, itemName: String, leftClick: Boolean):
  443. set {_nameLower} to {_itemName} in lower case
  444. set {_amount} to {furnace%{inventory.%{_p}%.tierNumber}%.%{inventory.%{_p}%.current}%.contents.%{_nameLower}%}
  445. set {_removedAmount} to {_amount}
  446. if {_leftClick} is false:
  447. set {_removedAmount} to getAmountToRemove({_amount}, {_amount} / 2)
  448.  
  449. set {_p}'s cursor slot to ("%{_removedAmount}% %{furnace%{inventory.%{_p}%.tierNumber}%.%{inventory.%{_p}%.current}%.contents.%{_nameLower}%Type}%" parsed as an item)
  450. set {furnace%{inventory.%{_p}%.tierNumber}%.%{inventory.%{_p}%.current}%.contents.%{_nameLower}%} to {_amount}-{_removedAmount}
  451. if {_amount}-{_removedAmount} <= 0:
  452. delete {furnace%{inventory.%{_p}%.tierNumber}%.%{inventory.%{_p}%.current}%.contents.%{_nameLower}%Type}
  453. set slot ({_slot}) of {_p}'s current inventory to lime stained glass pane named "&a&l%{_itemName}%"
  454. if {_nameLower} is "ore" or "fuel":
  455. resetFuelIndicator({inventory.%{_p}%.current}, {_furnaceTierString})
  456. else:
  457. 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
  458.  
  459. function getAmountToRemove(total: Number, amount: Number) :: Number:
  460. if {_amount} is {_total}:
  461. set {_amount} to 1
  462. add "%({_total}-1) / 2%" parsed as an integer to {_amount}
  463. set {_item} to "%{_total} - {_amount} + 1% %type of {_item}%" parsed as an item
  464. else:
  465. set {_item} to "%{_total} - {_amount}% %type of {_item}%" parsed as an item
  466. return {_amount}
  467.  
  468. function updateInventoryFuelIndicator(furnaceId: Location, progressBar: Integer, furnaceTier: String):
  469. if {_progressBar} <= 4:
  470. if {_progressBar} >= 0:
  471. loop {inventoryList.%{_furnaceId}%.furnace%{_furnaceTier}%::*}:
  472. loop {_progressBar} times:
  473. set slot 19 + loop-value-2 of loop-value-1's current inventory to lime stained glass pane named "&f%20*loop-value-2%%%"
  474. loop 5-{_progressBar} times:
  475. 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)%%%"
  476.  
  477. function resetFuelIndicator(furnaceId: Location, furnaceTier: String):
  478. set {furnace1.%{_furnaceId}%.smeltTime} to 0
  479. loop {inventoryList.%{_furnaceId}%.furnace%{_furnaceTier}%::*}:
  480. loop 5 times:
  481. set slot 19 + loop-value-2 of loop-value-1's current inventory to gray stained glass pane named "&f%20*loop-value-2%%%"
  482. if {_furnaceTier} is " I":
  483. removeFurnaceFromLoop({_furnaceId})
  484. else:
  485. removeFurnaceFromLoop({_furnaceId})
  486.  
  487. function setIngotType(furnaceId: Location, tier: Number):
  488. if {furnace%{_tier}%.%{_furnaceId}%.contents.ingotType} is set:
  489. stop
  490. set {_type} to "%{furnace%{_tier}%.%{_furnaceId}%.contents.oreType}%"
  491. if {_tier} is 2:
  492. if {_type} is "diamond ore", "emerald ore" or "nether quartz ore":
  493. replace all " ore" in {_type} with " ingot"
  494. {furnace%{_tier}%.%{_furnaceId}%.contents.ingotType}
  495. stop
  496. if "%{_type}%" is "iron ore", "gold ore", "lapis ore" or "redstone ore":
  497. replace "ore" in {_type} with "ingot"
  498. set {furnace%{_tier}%.%{_furnaceId}%.contents.ingotType} to {_type} parsed as an item
  499. else if {_type} is "coal ore":
  500. set {furnace%{_tier}%.%{_furnaceId}%.contents.ingotType} to coal
  501.  
  502. function removeFurnaceFromLoop(furnaceId: Location):
  503. delete {furnace.%{_furnaceId}%.isAddedToLoop}
  504. delete {furnace.idList::%{furnace.idBinds::%{_furnaceId}%}%}
  505. delete {furnace.idBinds::%{_furnaceId}%}
  506. remove {_furnaceId} from {furnace1.loopList::*}
  507. if size of {furnace1.loopList::*} is 0:
  508. set {furnace1.looping} to false
  509.  
  510. function loop_furnace1():
  511. if {furnace1.looping} is not true:
  512. set {furnace1.looping} to true
  513. while {furnace1.looping} is true:
  514. if size of {furnace1.loopList::*} is 0:
  515. set {furnace1.looping} to false
  516. stop loop
  517. else:
  518. set {_current} to 0
  519. loop {furnace1.loopList::*}:
  520. add 1 to {_current}
  521. set {_type} to {furnace.idList::%{_current}%}
  522. set {_tier} to getTierNumber({_type})
  523. if {furnace%{_tier}%.%loop-value%.contents.ore} < 1:
  524. updateInventoryFuelIndicator(loop-value, 0, {_type})
  525. removeFurnaceFromLoop(loop-value)
  526.  
  527. else:
  528. if {furnace%{_tier}%.%loop-value%.fuelingTime} is not set:
  529. remove 1 from {furnace%{_tier}%.%loop-value%.contents.fuel}
  530. set {furnace%{_tier}%.%loop-value%.fuelingTime} to 0
  531. updateItemInSlot(loop-value, "Fuel", 40, {_type}, 1)
  532.  
  533. add 1 to {furnace%{_tier}%.%loop-value%.smeltTime}
  534. add 1 to {furnace%{_tier}%.%loop-value%.fuelingTime}
  535. if "%{furnace%{_tier}%.%loop-value%.smeltTime}/2.0%" doesn't contain ".":
  536. if {furnace%{_tier}%.%loop-value%.smeltTime}/2 > 4:
  537. updateInventoryFuelIndicator(loop-value, 0, {_type})
  538. else:
  539. updateInventoryFuelIndicator(loop-value, "%{furnace%{_tier}%.%loop-value%.smeltTime}/2%" parsed as an integer, {_type})
  540. if {furnace%{_tier}%.%loop-value%.smeltTime} > 9:
  541. delete {furnace%{_tier}%.%loop-value%.smeltTime}
  542. remove 1 from {furnace%{_tier}%.%loop-value%.contents.ore}
  543. add 1 to {furnace%{_tier}%.%loop-value%.contents.ingot}
  544. setIngotType(loop-value, 1)
  545. updateItemInSlot(loop-value, "Ore", 38, {_type}, 1)
  546. updateItemInSlot(loop-value, "Ingot", 42, {_type}, 1)
  547. updateInventoryFuelIndicator(loop-value, 0, {_type})
  548.  
  549.  
  550. if {furnace%{_tier}%.%loop-value%.fuelingTime} >= {furnace%{_tier}%.%Loop-value%.fuelingTimeMax}:
  551. if {furnace%{_tier}%.%loop-value%.contents.fuel} <= 0:
  552. delete {furnace%{_tier}%.%loop-value%.smeltTime}
  553. removeFurnaceFromLoop(loop-value)
  554. updateInventoryFuelIndicator(loop-value, 0, {_type})
  555. else:
  556. delete {furnace%{_tier}%.%loop-value%.fuelingTime}
  557. wait 1 second
  558.  
  559.  
  560. #||======================================================||
  561. #|| ________ ________ _ _ _______ _____ ||
  562. #|| | ____\ \ / / ____| \ | |__ __/ ____| ||
  563. #|| | |__ \ \ / /| |__ | \| | | | | (___ ||
  564. #|| | __| \ \/ / | __| | . ` | | | \___ \ ||
  565. #|| | |____ \ / | |____| |\ | | | ____) | ||
  566. #|| |______| \/ |______|_| \_| |_| |_____/ ||
  567. #|| ||
  568. #||======================================================||
  569.  
  570. on disable:
  571. if {furnace1.looping} is true:
  572. set {furnace1.looping} to false
  573. set {furnace1.loopStopped} to true
  574.  
  575. on enable:
  576. set {blacksmith.cost.helmet} to 5
  577. set {blacksmith.cost.chestplate} to 8
  578. set {blacksmith.cost.leggings} to 7
  579. set {blacksmith.cost.boots} to 4
  580. if {blacksmith.advancedMode} is not set:
  581. set {blacksmith.advancedMode} to true
  582. wait 1 second
  583. if {furnace1.loopStopped} is true:
  584. set {furnace1.looping} to true
  585. loop_furnace1()
  586. set {furnace1.loopStopped} to false
  587.  
  588. on rightclick on smooth stone:
  589. if player is not sneaking:
  590. if {anvil.%location of clicked block%} is true:
  591. set {anvil.current.%player%} to 1
  592. openAnvilGui(player)
  593. cancel event
  594.  
  595. on rightclick on iron block:
  596. if player is not sneaking:
  597. if {anvil.%location of clicked block%} is true:
  598. set {anvil.current.%player%} to 2
  599. openAnvilGui(player)
  600. cancel event
  601.  
  602. on rightclick on diamond block:
  603. if player is not sneaking:
  604. if {anvil.%location of clicked block%} is true:
  605. set {anvil.current.%player%} to 3
  606. openAnvilGui(player)
  607. cancel event
  608.  
  609. on rightclick on cauldron:
  610. if {furnace.%location of event-block%} is true:
  611. if isFurnace1(location 1 meters below clicked block):
  612. cancel event
  613. guiFurnace1(player, location of clicked block)
  614.  
  615. else:
  616. delete {furnace1.%location of clicked block%.contents.fuel}
  617. delete {furnace1.%location of clicked block%.contents.ore}
  618. delete {furnace1.%location of clicked block%.contents.ingot}
  619. delete {furnace.%location of event-block%}
  620.  
  621. on rightclick on blast furnace:
  622. if {furnace2.%location of event-block%} is true:
  623. if isFurnace2(location of clicked block):
  624. cancel event
  625. guiFurnace2(player, location of clicked block)
  626. else:
  627. delete {furnace2.%location of event-block%}
  628.  
  629. on rightclick holding stone axe:
  630. if clicked block is smooth stone or iron block or diamond block:
  631. if {anvil.%location of event-block%} is not true:
  632. set {anvil.%location of event-block%} to true
  633. set {_tier} to "Tier I"
  634. if clicked block is smooth stone:
  635. set {anvil.%location of event-block%.tier} to 1
  636. else if clicked block is iron block:
  637. set {anvil.%location of event-block%.tier} to 2
  638. set {_tier} to "Tier II"
  639. else:
  640. set {anvil.%location of event-block%.tier} to 3
  641. set {_tier} to "Tier III"
  642.  
  643. set {_s} to 6
  644. loop all players in radius 6 around event-block:
  645. set {_v} to ({_s} - distance between loop-player and event-block)
  646. play sound "block.anvil.place" with volume {_v} and pitch 0 to loop-player
  647.  
  648. send "{@logo} Successfully created an anvil of %{_tier}%."
  649. summon armor stand at location 0.6 meters below event-block
  650. set name of last spawned armor stand to "&7Anvil"
  651. add "{Invisible:1b,NoGravity:1b,NoAI:1b,CustomNameVisible:1}" to NBT of last spawned armor stand
  652.  
  653. summon armor stand at location 0.9 meters below event-block
  654. set name of last spawned armor stand to "&7%{_tier}%"
  655. add "{Invisible:1b,NoGravity:1b,NoAI:1b,CustomNameVisible:1}" to NBT of last spawned armor stand
  656. show 5 dust of anvil at location 0.0 meters above location of event-block
  657.  
  658.  
  659. else if clicked block is cauldron:
  660. if {furnace.%location of event-block%} is not true:
  661. if isFurnace1(location 1 meters below clicked block):
  662. set {furnace.%location of event-block%} to true
  663. show 5 dust of anvil at location 0.0 meters above location of event-block
  664. cancel event
  665.  
  666. else if clicked block is blast furnace:
  667. if {furnace.%location of event-block%} is not true:
  668. if isFurnace2(location of clicked block):
  669. set {furnace2.%location of event-block%} to true
  670. show 5 dust of anvil at location 0.0 meters above location of event-block
  671. cancel event
  672. send "WIP"
  673.  
  674. on break of smooth stone or iron block or diamond block:
  675. if {anvil.%location of event-block%} is true:
  676. set {_s} to 6
  677. loop all players in radius 6 around event-block:
  678. set {_v} to ({_s} - distance between loop-player and event-block)
  679. play sound "block.anvil.place" with volume {_v} and pitch 0 to loop-player
  680. delete {anvil.%location of event-block%}
  681. delete {anvil.%location of event-block%.tier}
  682. loop entities in radius 1 around event-block:
  683. if type of loop-entity is armor stand:
  684. kill loop-entity
  685.  
  686.  
  687. on inventory click:
  688. if type of clicked inventory is chest inventory:
  689. if inventory name of player's current inventory is {@tier1Furnace} or {@tier2Furnace}:
  690. cancel event
  691. if clicked slot is set:
  692. if clicked item is not air:
  693. set {_item} to player's cursor slot
  694. set {_leftClick} to false
  695. if click type is left mouse button:
  696. set {_leftClick} to true
  697. if {_item} is not air:
  698. if name of clicked item is "&a&lOre":
  699. if canSmelt({_item}, 1):
  700. if canSmeltInFurnace(player, {_item}):
  701. setItemInSlot(player, "Ore", clicked slot, clicked item, {_item}, true, {_leftClick})
  702. else if name of clicked item is "&a&lFuel":
  703. if getFuelingTime({_item}) > 0:
  704. setItemInSlot(player, "Fuel", clicked slot, clicked item, {_item}, true, {_leftClick})
  705. else if getFuelingTime(clicked item) > 0:
  706. if getFuelingTime({_item}) > 0:
  707. setItemInSlot(player, "Fuel", clicked slot, clicked item, {_item}, false, {_leftClick})
  708. else if canSmelt(clicked item, 1) is true:
  709. if canSmelt({_item}, 1):
  710. if canSmeltInFurnace(player, {_item}):
  711. setItemInSlot(player, "Ore", clicked slot, clicked item, {_item}, false, {_leftClick})
  712. else if clicked slot is 42:
  713. if type of clicked item is not lime stained glass pane:
  714. updateItemAndRemoveFromLoop(player, clicked item, clicked slot, 1, " %{inventory.%player%.tier}%", "Ingot", {_leftClick})
  715. else if getFuelingTime(clicked item) > 0:
  716. updateItemAndRemoveFromLoop(player, clicked item, clicked slot, 1, " %{inventory.%player%.tier}%", "Fuel", {_leftClick})
  717. else if canSmelt(clicked item, 1) is true:
  718. updateItemAndRemoveFromLoop(player, clicked item, clicked slot, 1, " %{inventory.%player%.tier}%", "Ore", {_leftClick})
  719.  
  720. else if inventory name of player's current inventory starts with "Anvil Tier ":
  721. cancel event
  722. if clicked slot is set:
  723. if clicked item is any helmet, any chestplate, any leggings or any boots:
  724. set {_item::*} to ("%type of clicked item%") split at " "
  725. tryCraftArmour(player, {_item::1}, {_item::2})
  726.  
  727. else if inventory name of player's current inventory is "Smithing":
  728. cancel event
  729. if clicked slot is set:
  730. if {blacksmith.smithing.%player%.chainmail} is true:
  731. if clicked item is iron nugget:
  732. if {blacksmith.smithing.%player%.stage} is 0:
  733. add 1 to {blacksmith.smithing.%player%.stage}
  734. 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
  735. play sound "entity.item.pickup" with volume 12 and pitch 2 to player
  736. else:
  737. userFailedMinigame(player)
  738.  
  739. else if clicked item is iron hoe:
  740. if {blacksmith.smithing.%player%.stage} is 1:
  741. add 1 to {blacksmith.smithing.%player%.stage}
  742. play sound "block.anvil.land" with volume 10 and pitch 1 to player
  743. setSmithingGui(player)
  744. else:
  745. userFailedMinigame(player)
  746. else:
  747. if clicked item is iron ingot:
  748. if {blacksmith.smithing.%player%.stage} is 0 or 2:
  749. play sound "block.anvil.use" with volume 12 and pitch 2 to player
  750. if {blacksmith.smithing.%player%.stage} is 0:
  751. 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
  752. else:
  753. 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."
  754. add 1 to {blacksmith.smithing.%player%.stage}
  755. else:
  756. userFailedMinigame(player)
  757.  
  758.  
  759. else if clicked item is iron axe:
  760. if {blacksmith.smithing.%player%.stage} is 1:
  761. add 1 to {blacksmith.smithing.%player%.stage}
  762. play sound "block.anvil.use" with volume 12 and pitch 2 to player
  763. 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."
  764. else:
  765. userFailedMinigame(player)
  766. else if clicked item is water bucket:
  767. if {blacksmith.smithing.%player%.stage} is 3:
  768. play sound "block.anvil.land" with volume 12 and pitch 2 to player
  769. give {blacksmith.smithing.%player%.result} to player
  770. close player's inventory
  771. else:
  772. userFailedMinigame(player)
  773.  
  774. on inventory close:
  775. if {inventory.%player%.name} is set:
  776. remove player from {inventoryList.%{inventory.%player%.current}%.%{inventory.%player%.name}%::*}
  777. delete {inventory.%player%.name}
  778. delete {inventory.%player%.current}
  779. else if {anvil.current.%player%} is set:
  780. delete {anvil.current.%player%}
  781.  
  782. on inventory drag:
  783. set {_tier1} to uncolored {@tier1Furnace}
  784. if {inventory.%player%.name} is "Anvil" or "%{_tier1}%" or "Furnace II":
  785. cancel event
  786. else if {anvil.current.%player%} is set:
  787. cancel event
  788.  
  789. on craft:
  790. if event-item is any helmet, any chestplate, any leggings or any boots:
  791. if "%event-item%" doesn't start with "leather":
  792. send "{@logo} You cannot craft this item in a crafting table!"
  793. cancel event
  794.  
  795. on right click on armor stand:
  796. if name of event-entity contains "Anvil" or "Tier I":
  797. cancel event
  798.  
  799.  
Advertisement
Add Comment
Please, Sign In to add comment