Zeldaboy111

Furnaces Optimizen ]|[ Skript #377

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