Zeldaboy111

Particles toevoegen! ]|[ Skript #379

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