Zeldaboy111

Klik detectie ]|[ Skript #393

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