Zeldaboy111

Advanced Mode ]|[ Skript #364

Nov 15th, 2020
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 24.87 KB | None | 0 0
  1. #requires: SkQuery, SkRayFall, Skellett, SkBee, TuSKe
  2.  
  3.  
  4. options:
  5. logo: &6&lBS&8:&7
  6. tier1Furnace: "&8Furnace I"
  7.  
  8. command /blacksmith [<text>] [<text>]:
  9. aliases: /bs
  10. trigger:
  11. if player has permission "blacksmith":
  12. if arg-1 is not set:
  13. send "{@logo} Incorrect usage! &e/blacksmith advanced <true | false>&7."
  14. else if arg-1 is "advanced":
  15. if arg-2 is "true" or "enable":
  16. if {blacksmith.advancedMode} is true:
  17. send "{@logo} The &eadvanced mode &7is already enabled."
  18. else:
  19. set {blacksmith.advancedMode} to true
  20. send "{@logo} You have enabled the &eadvanced mode&7!"
  21. else if arg-2 is "false" or "enable":
  22. if {blacksmith.advancedMode} is false:
  23. send "{@logo} The &eadvanced mode &7is already disabled."
  24. else:
  25. set {blacksmith.advancedMode} to false
  26. send "{@logo} You have disabled the &eadvanced mode&7!"
  27. else:
  28. send "{@logo} Incorrect usage! &e/blacksmith advanced <true | false>&7."
  29. else:
  30. send "{@logo} You do not have enough permissions to do this!"
  31.  
  32.  
  33.  
  34. function updateItemInSlot(furnaceId: Location, type: String, slot: Number, furnaceTier: String, typeId: integer):
  35. set {_typeLower} to {_type} in lower case
  36. loop {inventoryList.%{_furnaceId}%.furnace%{_furnaceTier}%::*}:
  37. 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)
  38. if {furnace%{_typeId}%.%{_furnaceId}%.contents.%{_typeLower}%} <= 0:
  39. set slot {_slot} of loop-value's current inventory to lime stained glass pane named "&a&l%{_type}%"
  40.  
  41. function updateItemAndRemoveFromLoop(p: Player, item: Item, slot: Number, furnaceTier: Integer, furnaceTierString: String, itemName: String, leftClick: Boolean):
  42. set {_nameLower} to {_itemName} in lower case
  43. set {_amount} to {furnace1.%{inventory.%{_p}%.current}%.contents.%{_nameLower}%}
  44. set {_removedAmount} to {_amount}
  45. if {_leftClick} is false:
  46. set {_removedAmount} to "%{_amount} / 2%" parsed as an integer
  47. if {_removedAmount} is {_amount}:
  48. set {_removedAmount} to 1
  49. add "%({_amount}-1) / 2%" parsed as an integer to {_removedAmount}
  50. set {_item} to "%{_amount} - {_removedAmount} + 1% %type of {_item}%" parsed as an item
  51. else:
  52. set {_item} to "%{_amount} - {_removedAmount}% %type of {_item}%" parsed as an item
  53.  
  54. set {_p}'s cursor slot to {_item}
  55. set {furnace1.%{inventory.%{_p}%.current}%.contents.%{_nameLower}%} to {_amount}-{_removedAmount}
  56. if {_amount}-{_removedAmount} <= 0:
  57. delete {furnace1.%{inventory.%{_p}%.current}%.contents.%{_nameLower}%Type}
  58. set slot ({_slot}) of {_p}'s current inventory to lime stained glass pane named "&a&l%{_itemName}%"
  59. if {_nameLower} is "ore" or "fuel":
  60. resetFuelIndicator({inventory.%{_p}%.current}, {_furnaceTierString})
  61. else:
  62. set slot ({_slot}) of {_p}'s current inventory to "%{_amount}-{_removedAmount}% %{furnace1.%{inventory.%{_p}%.current}%.contents.%{_nameLower}%Type}%" parsed as an item
  63.  
  64.  
  65. function updateInventoryFuelIndicator(furnaceId: Location, progressBar: Integer, furnaceTier: String):
  66. if {_progressBar} <= 4:
  67. if {_progressBar} >= 0:
  68. loop {inventoryList.%{_furnaceId}%.furnace%{_furnaceTier}%::*}:
  69. set slot 20+{_progressBar} of loop-value's current inventory to gray stained glass pane named "&f%20*({_progressBar}+1)%%%"
  70. if {_progressBar} > 0:
  71. set slot 20+{_progressBar}-1 of loop-value's current inventory to lime stained glass pane named "&f%20*{_progressBar}%%%"
  72. loop 4-{_progressBar} times:
  73. 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)%%%"
  74.  
  75. function resetFuelIndicator(furnaceId: Location, furnaceTier: String):
  76. set {furnace1.%{_furnaceId}%.smeltTime} to 0
  77. loop {inventoryList.%{_furnaceId}%.furnace%{_furnaceTier}%::*}:
  78. loop 5 times:
  79. set slot 19 + loop-value-2 of loop-value-1's current inventory to gray stained glass pane named "&f%20*loop-value-2%%%"
  80. if {_furnaceTier} is " I":
  81. removeFurnaceFromLoop({_furnaceId}, 1)
  82. else:
  83. removeFurnaceFromLoop({_furnaceId}, 2)
  84.  
  85. function setIngotType(furnaceId: Location, tier: Number):
  86. delete {furnace%{_tier}%.%{_furnaceId}%.contents.ingotType}
  87. if {furnace%{_tier}%.%{_furnaceId}%.contents.ingotType} is set:
  88. stop
  89. set {_type} to "%{furnace%{_tier}%.%{_furnaceId}%.contents.oreType}%"
  90. if {_tier} is 2:
  91. if {_type} is "diamond ore", "emerald ore" or "nether quartz ore":
  92. replace all " ore" in {_type} with " ingot"
  93. {furnace%{_tier}%.%{_furnaceId}%.contents.ingotType}
  94. stop
  95. if "%{_type}%" is "iron ore", "gold ore", "lapis ore" or "redstone ore":
  96. replace "ore" in {_type} with "ingot"
  97. set {furnace%{_tier}%.%{_furnaceId}%.contents.ingotType} to {_type} parsed as an item
  98. else if {_type} is "coal ore":
  99. set {furnace%{_tier}%.%{_furnaceId}%.contents.ingotType} to coal
  100.  
  101. function removeFurnaceFromLoop(furnaceId: Location, typeId: integer):
  102. delete {furnace.%{_furnaceId}%.isAddedToLoop}
  103. remove {_furnaceId} from {furnace%{_typeId}%.loopList::*}
  104.  
  105.  
  106. function loop_furnace1():
  107. set {furnace1.looping} to false
  108. if {furnace1.looping} is not true:
  109. set {furnace1.looping} to true
  110. while {furnace1.looping} is true:
  111. if size of {furnace1.loopList::*} is 0:
  112. set {furnace1.looping} to false
  113. stop loop
  114. else:
  115. loop {furnace1.loopList::*}:
  116. if {furnace1.%loop-value%.contents.ore} < 1:
  117. updateInventoryFuelIndicator(loop-value, 0, " I")
  118. removeFurnaceFromLoop(loop-value, 1)
  119.  
  120. else:
  121. if {furnace1.%loop-value%.contents.fuelingTime} is not set:
  122. remove 1 from {furnace1.%loop-value%.contents.fuel}
  123. updateItemInSlot(loop-value, "Fuel", 40, " I", 1)
  124.  
  125. add 1 to {furnace1.%loop-value%.smeltTime}
  126. add 1 to {furnace1.%loop-value%.fuelingTime}
  127. if "%{furnace1.%loop-value%.smeltTime}/2.0%" doesn't contain ".":
  128. if {furnace1.%loop-value%.smeltTime}/2 > 4:
  129. updateInventoryFuelIndicator(loop-value, 0, " I")
  130. else:
  131. updateInventoryFuelIndicator(loop-value, "%{furnace1.%loop-value%.smeltTime}/2%" parsed as an integer, " I")
  132. if {furnace1.%loop-value%.smeltTime} > 9:
  133. delete {furnace1.%loop-value%.smeltTime}
  134. remove 1 from {furnace1.%loop-value%.contents.ore}
  135. add 1 to {furnace1.%loop-value%.contents.ingot}
  136. setIngotType(loop-value, 1)
  137. updateItemInSlot(loop-value, "Ore", 38, " I", 1)
  138. updateItemInSlot(loop-value, "Ingot", 42, " I", 1)
  139. updateInventoryFuelIndicator(loop-value, 0, " I")
  140.  
  141.  
  142. if {furnace1.%loop-value%.fuelingTime} >= {furnace1.%Loop-value%.fuelingTimeMax}:
  143. if {furnace1.%loop-value%.contents.fuel} <= 0:
  144. delete {furnace1.%loop-value%.smeltTime}
  145. removeFurnaceFromLoop(loop-value, 1)
  146. updateInventoryFuelIndicator(loop-value, 0, " I")
  147. else:
  148. delete {furnace1.%loop-value%.fuelingTime}
  149. wait 1 second
  150.  
  151. # Returns how many ticks an item gives fuel
  152. function getFuelingTime(type: Item) :: integer:
  153. if {_type} is lava:
  154. return 20000
  155. else if {_type} is block of coal:
  156. return 16000
  157. else if {_type} is dried kelp block:
  158. return 4000
  159. else if {_type} is blaze rod:
  160. return 2400
  161. else if {_type} is coal or charcoal:
  162. return 1600
  163. else if {_type} is any boat or scaffolding:
  164. return 1200
  165. 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:
  166. return 300
  167. 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:
  168. return 200
  169. else if {_type} is bowl or any sapling or stick or any wool:
  170. return 100
  171. else if {_type} is any carpet:
  172. return 67
  173. else if {_type} is bamboo:
  174. return 50
  175. return 0
  176.  
  177. # Returns if the item can be smelted in the furnace, every smelt takes 10 seconds in a normal furnace
  178. function canSmelt(type: Item, tier: Integer) :: boolean:
  179. if {_type} is iron ore or gold ore or lapis ore or redstone ore or coal ore:
  180. return true
  181. else if {_tier} is 2:
  182. if {_type} is diamond ore or emerald ore or nether quartz ore:
  183. return true
  184.  
  185. return false
  186.  
  187. function canSmeltInFurnace(p: Player, item: Item) :: boolean:
  188. set {_furnaceId} to {inventory.%{_p}%.current}
  189. if {furnace1.%{_furnaceId}%.contents.oreType} is set:
  190. if "%type of {_item}%" is not "%{furnace1.%{_furnaceId}%.contents.oreType}%":
  191. return false
  192. if {furnace1.%{_furnaceId}%.contents.ingotType} is set:
  193. send "true" to {_p}
  194. if type of {_item} is coal ore:
  195. if type of {furnace1.%{_furnaceId}%.contents.ingotType} is coal:
  196. return true
  197. set {_item} to "%type of {_item}%"
  198. replace all " ore" in {_item} with " ingot"
  199. if {_item} is not "%{furnace1.%{_furnaceId}%.contents.ingotType}%":
  200. return false
  201. return true
  202.  
  203.  
  204. function outlineGui(p: Player):
  205. loop 9 times:
  206. set slot loop-value - 1 of {_p}'s current inventory to gray stained glass pane named "&8"
  207. set slot 54-loop-value of {_p}'s current inventory to gray stained glass pane named "&8"
  208.  
  209. loop 5 times:
  210. set slot loop-value * 9 of {_p}'s current inventory to gray stained glass pane named "&8"
  211. set slot loop-value * 9-1 of {_p}'s current inventory to gray stained glass pane named "&8"
  212.  
  213. function openGuiOutlined(p: Player, loc: Location, rows: integer, name: String):
  214. open chest with {_rows} rows named {_name} to {_p}
  215. set {inventory.%{_p}%.name} to uncolored {_name}
  216. set {inventory.%{_p}%.current} to {_loc}
  217. add {_p} to {inventoryList.%{_loc}%.%{inventory.%{_p}%.name}%::*}
  218. wait 2 ticks
  219. outlineGui({_p})
  220.  
  221. function guiFurnace1(p: Player, loc: Location):
  222. openGuiOutlined({_p}, {_loc}, 6, {@tier1Furnace})
  223.  
  224. if {furnace1.%{_loc}%.contents.fuel} is not set:
  225. set {furnace1.%{_loc}%.contents.fuel} to 0
  226. if {furnace1.%{_loc}%.contents.ore} is not set:
  227. set {furnace1.%{_loc}%.contents.ore} to 0
  228. if {furnace1.%{_loc}%.contents.ingot} is not set:
  229. set {furnace1.%{_loc}%.contents.ingot} to 0
  230.  
  231. if {furnace1.%{_loc}%.contents.ingotType} is not set:
  232. set {furnace1.%{_loc}%.contents.ingot} to 0
  233. if {furnace1.%{_loc}%.contents.oreType} is not set:
  234. set {furnace1.%{_loc}%.contents.ore} to 0
  235. if {furnace1.%{_loc}%.contents.fuelType} is not set:
  236. set {furnace1.%{_loc}%.contents.fuel} to 0
  237.  
  238. set {furnace1.%{_loc}%.fuelingTimeMax} to 0
  239. if {furnace1.%{_loc}%.contents.fuelType} is set:
  240. set {furnace1.%{_loc}%.fuelingTimeMax} to getFuelingTime({furnace1.%{_loc}%.contents.fuelType}) / 20
  241.  
  242. set slot 38 of {_p}'s current inventory to lime stained glass pane named "&a&lOre"
  243. set slot 40 of {_p}'s current inventory to lime stained glass pane named "&a&lFuel"
  244. set slot 42 of {_p}'s current inventory to lime stained glass pane named "&a&lIngot"
  245.  
  246. if {furnace1.%{_loc}%.contents.ore} > 0:
  247. set slot 38 of {_p}'s current inventory to ("%{furnace1.%{_loc}%.contents.ore}% %{furnace1.%{_loc}%.contents.oreType}%" parsed as an item)
  248.  
  249. if {furnace1.%{_loc}%.contents.fuel} > 0:
  250. set slot 40 of {_p}'s current inventory to ("%{furnace1.%{_loc}%.contents.fuel}% %{furnace1.%{_loc}%.contents.fuelType}%" parsed as an item)
  251.  
  252. if {furnace1.%{_loc}%.contents.ingot} > 0:
  253. set slot 42 of {_p}'s current inventory to ("%{furnace1.%{_loc}%.contents.ingot}% %{furnace1.%{_loc}%.contents.ingotType}%" parsed as an item)
  254.  
  255. loop 5 times:
  256. set slot 19 + loop-value of {_p}'s current inventory to gray stained glass pane named "&f%20*loop-value%%%"
  257.  
  258. set {_progressBar} to "%{furnace1.%{_loc}%.smeltTime}/2.0%"
  259. if {_progressBar} contains ".":
  260. set {_progressBar::*} to {_progressBar} split at "."
  261. set {_progressBar} to {_progressBar::1}
  262.  
  263. loop ({_progressBar} parsed as an integer) times:
  264. set slot 20+loop-value -1 of {_p}'s current inventory to lime stained glass pane named "&f%20*loop-value%%%"
  265.  
  266. function openAnvilGui(p: Player):
  267. if {anvil.current.%{_p}%} is 1:
  268. open chest with 6 rows named "Anvil Tier I" to {_p}
  269. wait 2 ticks
  270. outlineGui({_p})
  271.  
  272. set slot 12 of {_p}'s current inventory to golden helmet named "&6Golden Helmet" with lore "&8" and "&7Cost&8: &e5 Gold Ingot" without any NBT
  273. set slot 21 of {_p}'s current inventory to golden chestplate named "&6Golden Chestplate" with lore "&8" and "&7Cost&8: &e8 Gold Ingot" without any NBT
  274. set slot 30 of {_p}'s current inventory to golden leggings named "&6Golden Leggings" with lore "&8" and "&7Cost&8: &e7 Gold Ingot" without any NBT
  275. set slot 39 of {_p}'s current inventory to golden boots named "&6Golden Boots" with lore "&8" and "&7Cost&8: &e4 Gold Ingot" without any NBT
  276.  
  277. set slot 14 of {_p}'s current inventory to chainmail helmet named "&fChainmail Helmet" with lore "&8" and "&7Cost&8: &75 Iron Nugget" without any NBT
  278. set slot 23 of {_p}'s current inventory to chainmail chestplate named "&fChainmail Chestplate" with lore "&8" and "&7Cost&8: &78 Iron Nugget" without any NBT
  279. set slot 32 of {_p}'s current inventory to chainmail leggings named "&fChainmail Leggings" with lore "&8" and "&7Cost&8: &77 Iron Nugget" without any NBT
  280. set slot 41 of {_p}'s current inventory to chainmail boots named "&fChainmail Boots" with lore "&8" and "&7Cost&8: &74 Iron Nugget" without any NBT
  281.  
  282.  
  283.  
  284. else if {anvil.curent.%{_p}%} is 2:
  285.  
  286. else if {anvil.current.%{_p}%} is 3:
  287.  
  288. #advanced mode = short minigame / extra work to do whilst smithing weapons / tools
  289.  
  290.  
  291.  
  292. # U T I L I T I E S
  293.  
  294. function getNextNumber(base: number, addToDefault: number, max: number) :: number:
  295. set {_value} to {_base} + {_addToDefault}
  296. if {_value} > {_max}:
  297. set {_value} to {_addToDefault} - ({_max} - {_base})
  298.  
  299. return {_value}
  300.  
  301. function detectStair(facing: number, loc: Location, startValue: String) :: boolean:
  302. set {_list::*} to "westward red brick stair", "red brick stair", "eastward red brick stair" and "southward red brick stair"
  303. set {_dir} to {_facing}/2 + 1
  304.  
  305. if {_dir} > 4:
  306. remove 4 from {_dir}
  307.  
  308. if "%block at location of {_loc}%" is "%{_startValue}%%{_list::%{_dir}%}%":
  309. return true
  310. return false
  311.  
  312. function setItemInSlot(p: Player, type: String, slot: number, clickedItem: Item, item: Item, startLoop: Boolean, leftClick: Boolean):
  313. if {_type} is "Ore" or "Fuel" or "Ingot":
  314. set {_typeLower} to {_type} in lower case
  315. if {_leftClick} is false:
  316. if {furnace1.%{inventory.%{_p}%.current}%.contents.%{_typeLower}%} >= 64:
  317. stop
  318. add 1 to {furnace1.%{inventory.%{_p}%.current}%.contents.%{_typeLower}%}
  319. set {furnace1.%{inventory.%{_p}%.current}%.contents.%{_typeLower}%Type} to "%type of {_item}%"
  320. set {_item} to "%item amount of {_item}-1% %type of {_item}%"
  321. else:
  322. if {furnace1.%{inventory.%{_p}%.current}%.contents.%{_typeLower}%} >= 64:
  323. stop
  324. if {furnace1.%{inventory.%{_p}%.current}%.contents.%{_typeLower}%} + item amount of {_item} > 64:
  325. set {_item} to "%(item amount of {_item} - (64 - {furnace1.%{inventory.%{_p}%.current}%.contents.%{_typeLower}%}))% %type of {_item}%"
  326. set {furnace1.%{inventory.%{_p}%.current}%.contents.%{_typeLower}%} to 64
  327. set {_p}'s cursor to ("%{_item}%" parsed as an item)
  328. else:
  329. add item amount of {_item} to {furnace1.%{inventory.%{_p}%.current}%.contents.%{_typeLower}%}
  330. set {furnace1.%{inventory.%{_p}%.current}%.contents.%{_typeLower}%Type} to "%type of {_item}%"
  331. set {_item} to air
  332.  
  333. set {_typeId} to 2
  334. set {_typeString} to " II"
  335. if {inventory.%{_p}%.name} is uncolored {@tier1Furnace}:
  336. set {_typeId} to 1
  337. set {_typeString} to " I"
  338.  
  339. set {_p}'s cursor to ("%{_item}%" parsed as an item)
  340. updateItemInSlot({inventory.%{_p}%.current}, {_type}, {_slot}, {_typeString}, {_typeId})
  341. if {_startLoop}:
  342. if {furnace.%{inventory.%{_p}%.current}%.isAddedToLoop} is not true:
  343. add {inventory.%{_p}%.current} to {furnace1.loopList::*}
  344. loop_furnace1()
  345.  
  346. # F U R N A C E D E T E C T S
  347.  
  348. function isFurnace1(below: Location) :: boolean:
  349. if block at {_below} is campfire:
  350. set {_xAdjust::*} to 1, 1, 1, 0, 0, -1, -1 and -1
  351. set {_zAdjust::*} to 1, 0, -1, 1, -1, 1, 0 and -1
  352. loop 8 times:
  353. 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}
  354. if block at {_checkLoc} is not red brick block:
  355. return false
  356. else:
  357. return false
  358. return true
  359.  
  360.  
  361. function isFurnace2(loc: Location) :: boolean:
  362. if block at {_loc} is not blast furnace:
  363. return false
  364.  
  365. set {_layer1::*} to air, brick slab, red brick block, air, red brick block, air, red brick block and brick slab
  366. set {_layer2::*} to air, red brick stair, eastward red brick stair and southward red brick stair
  367. set {_x::*} to 1, 1, 0, -1, -1, -1, 0 and 1
  368. set {_z::*} to 0, 1, 1, 1, 0, -1, -1 and -1
  369.  
  370. set {_base} to -2
  371. if block at location at x-coordinate of {_loc} + {_x::1}, y-coordinate of {_loc}, z-coordinate of {_loc} + {_z::1} in world of {_loc} is {_layer1::1}:
  372. set {_base} to 0
  373.  
  374. else if block at location at x-coordinate of {_loc} + {_x::3}, y-coordinate of {_loc}, z-coordinate of {_loc} + {_z::3} in world of {_loc} is {_layer1::1}:
  375. set {_base} to 2
  376.  
  377. else if block at location at x-coordinate of {_loc} + {_x::5}, y-coordinate of {_loc}, z-coordinate of {_loc} + {_z::5} in world of {_loc} is {_layer1::1}:
  378. set {_base} to 4
  379.  
  380. else if block at location at x-coordinate of {_loc} + {_x::7}, y-coordinate of {_loc}, z-coordinate of {_loc} + {_z::7} in world of {_loc} is {_layer1::1}:
  381. set {_base} to 6
  382.  
  383. set {_size} to size of {_x::*}
  384. if {_base} is not -2:
  385. loop 7 times:
  386. set {_value} to getNextNumber({_base}, loop-value, {_size})
  387. if block at location at x-coordinate of {_loc} + {_x::%{_value}%}, y-coordinate of {_loc}, z-coordinate of {_loc} + {_z::%{_value}%} in world of {_loc} is not {_layer1::%loop-value%}:
  388. return false
  389.  
  390.  
  391. set {_facingAdjust::*} to 0, 4, 6 and 8
  392. if detectStair({_base}, location 1 meters above {_loc}, "top "):
  393. loop 4 times:
  394. set {_value} to getNextNumber({_base}, loop-value*2, {_size}) - 1
  395. 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}
  396. set {_facing} to {_base}
  397. if {_facing} - {_facingAdjust::%loop-value%} >= 2:
  398. remove {_facingAdjust::%loop-value%} from {_facing}
  399. else:
  400. add {_facingAdjust::%loop-value%} to {_facing}
  401.  
  402. if loop-value is 1:
  403. if block at {_check} is not {_layer2::%loop-value%}:
  404. return false
  405. else if detectStair({_facing} - 2, {_check}, "") is false:
  406. return false
  407.  
  408. if block at location 2 meters above {_loc} is not red brick block:
  409. return false
  410. else:
  411. return false
  412. else:
  413. return false
  414. return true
  415.  
  416. # C L I C K E V E N T S
  417.  
  418. on rightclick on smooth stone:
  419. if player is not sneaking:
  420. if {anvil.%location of clicked block%} is true:
  421. set {anvil.current.%player%} to 1
  422. openAnvilGui(player)
  423. cancel event
  424.  
  425. on rightclick on cauldron:
  426. if {furnace.%location of event-block%} is true:
  427. if isFurnace1(location 1 meters below clicked block):
  428. cancel event
  429. guiFurnace1(player, location of clicked block)
  430.  
  431. else:
  432. delete {furnace1.%location of clicked block%.contents.fuel}
  433. delete {furnace1.%location of clicked block%.contents.ore}
  434. delete {furnace1.%location of clicked block%.contents.ingot}
  435. delete {furnace.%location of event-block%}
  436.  
  437. on rightclick on blast furnace:
  438. if {furnace2.%location of event-block%} is true:
  439. if isFurnace2(location of clicked block):
  440. cancel event
  441. send "WIP"
  442. else:
  443. delete {furnace2.%location of event-block%}
  444.  
  445. on rightclick holding stone axe:
  446. if clicked block is smooth stone or iron block or diamond block:
  447. if {anvil.%location of event-block%} is not true:
  448. set {anvil.%location of event-block%} to true
  449. set {_tier} to "Tier I"
  450. if clicked block is smooth stone:
  451. set {anvil.%location of event-block%.tier} to 1
  452. else if clicked block is iron block:
  453. set {anvil.%location of event-block%.tier} to 2
  454. set {_tier} to "Tier II"
  455. else:
  456. set {anvil.%location of event-block%.tier} to 3
  457. set {_tier} to "Tier III"
  458.  
  459. set {_s} to 6
  460. loop all players in radius 6 around event-block:
  461. set {_v} to ({_s} - distance between loop-player and event-block)
  462. play sound "block.anvil.place" with volume {_v} and pitch 0 to loop-player
  463.  
  464. send "{@logo} Successfully created an anvil of %{_tier}%."
  465. summon armor stand at location 0.6 meters below event-block
  466. set name of last spawned armor stand to "&7Anvil"
  467. add "{Invisible:1b,NoGravity:1b,NoAI:1b,CustomNameVisible:1}" to NBT of last spawned armor stand
  468.  
  469. summon armor stand at location 0.9 meters below event-block
  470. set name of last spawned armor stand to "&7%{_tier}%"
  471. add "{Invisible:1b,NoGravity:1b,NoAI:1b,CustomNameVisible:1}" to NBT of last spawned armor stand
  472.  
  473. else if clicked block is cauldron:
  474. if {furnace.%location of event-block%} is not true:
  475. if isFurnace1(location 1 meters below clicked block):
  476. set {furnace.%location of event-block%} to true
  477. cancel event
  478.  
  479. else if clicked block is blast furnace:
  480. if {furnace.%location of event-block%} is not true:
  481. if isFurnace2(location of clicked block):
  482. set {furnace2.%location of event-block%} to true
  483. cancel event
  484. send "WIP"
  485.  
  486. on break of smooth stone or iron block or diamond block:
  487. if {anvil.%location of event-block%} is true:
  488. set {_s} to 6
  489. loop all players in radius 6 around event-block:
  490. set {_v} to ({_s} - distance between loop-player and event-block)
  491. play sound "block.anvil.place" with volume {_v} and pitch 0 to loop-player
  492. delete {anvil.%location of event-block%}
  493. delete {anvil.%location of event-block%.tier}
  494. loop entities in radius 1 around event-block:
  495. if type of loop-entity is armor stand:
  496. kill loop-entity
  497.  
  498.  
  499. on inventory click:
  500. if type of clicked inventory is chest inventory:
  501. if {anvil.current.%player%} is set:
  502. cancel event
  503.  
  504. else if inventory name of player's current inventory is {@tier1Furnace}:
  505. cancel event
  506. if clicked slot is set:
  507. if clicked item is not air:
  508. set {_item} to player's cursor slot
  509. set {_leftClick} to false
  510. if click type is left mouse button:
  511. set {_leftClick} to true
  512. if {_item} is not air:
  513. if name of clicked item is "&a&lOre":
  514. if canSmelt({_item}, 1):
  515. if canSmeltInFurnace(player, {_item}):
  516. setItemInSlot(player, "Ore", clicked slot, clicked item, {_item}, true, {_leftClick})
  517. else if name of clicked item is "&a&lFuel":
  518. if getFuelingTime({_item}) > 0:
  519. setItemInSlot(player, "Fuel", clicked slot, clicked item, {_item}, true, {_leftClick})
  520. else if getFuelingTime(clicked item) > 0:
  521. if getFuelingTime({_item}) > 0:
  522. setItemInSlot(player, "Fuel", clicked slot, clicked item, {_item}, false, {_leftClick})
  523. else if canSmelt(clicked item, 1) is true:
  524. if canSmelt({_item}, 1):
  525. if canSmeltInFurnace(player, {_item}):
  526. setItemInSlot(player, "Ore", clicked slot, clicked item, {_item}, false, {_leftClick})
  527. else if clicked slot is 42:
  528. if type of clicked item is not lime stained glass pane:
  529. updateItemAndRemoveFromLoop(player, clicked item, clicked slot, 1, " I", "Ingot", {_leftClick})
  530. else if getFuelingTime(clicked item) > 0:
  531. updateItemAndRemoveFromLoop(player, clicked item, clicked slot, 1, " I", "Fuel", {_leftClick})
  532. else if canSmelt(clicked item, 1) is true:
  533. updateItemAndRemoveFromLoop(player, clicked item, clicked slot, 1, " I", "Ore", {_leftClick})
  534.  
  535. on inventory close:
  536. if {inventory.%player%.name} is set:
  537. remove player from {inventoryList.%{inventory.%player%.current}%.%{inventory.%player%.name}%::*}
  538. delete {inventory.%player%.name}
  539. delete {inventory.%player%.current}
  540. else if {anvil.current.%player%} is set:
  541. delete {anvil.current.%player%}
  542.  
  543. on inventory drag:
  544. set {_tier1} to uncolored {@tier1Furnace}
  545. if {inventory.%player%.name} is "Anvil" or "%{_tier1}%" or "Furnace II":
  546. cancel event
  547. else if {anvil.current.%player%} is set:
  548. cancel event
  549.  
  550.  
  551. on disable:
  552. if {furnace1.looping} is true:
  553. set {furnace1.looping} to false
  554. set {furnace1.loopStopped} to true
  555.  
  556. on enable:
  557. if {blacksmith.advancedMode} is not set:
  558. set {blacksmith.advancedMode} to true
  559. wait 1 second
  560. if {furnace1.loopStopped} is true:
  561. set {furnace1.looping} to true
  562. set {furnace1.loopStopped} to false
  563.  
  564. on craft:
  565. if event-item is any helmet, any chestplate, any leggings or any boots:
  566. if "%event-item%" doesn't start with "leather":
  567. send "{@logo} You cannot craft this item in a crafting table!"
  568. cancel event
  569.  
Advertisement
Add Comment
Please, Sign In to add comment