Advertisement
Zeldaboy111

Inventory drag & Inventory opslaan ]|[ Skript #347

Sep 17th, 2020
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 14.86 KB | None | 0 0
  1. #multiblock structure
  2. #rename function
  3.  
  4. #requires: SkQuery, SkRayFall, Skellett, SkBee, TuSKe
  5.  
  6.  
  7. options:
  8. logo: &6&lBS&8:&7
  9.  
  10. function loop():
  11. if {furnace1.looping} is not true:
  12. set {furnace1.looping} to true
  13. while {furnace1.looping} is true:
  14. if size of {furnace1.loopList::*} is 0:
  15. set {furnace1.looping} to false
  16. stop loop
  17. else:
  18. loop {furnace1.loopList::*}:
  19. add 1 to {furnace1.%loop-value%.smeltTime}
  20. add 1 to {furnace1.%loop-value%.fuelingTime}
  21. if {furnace1.%loop-value%.smeltTime} >= 9:
  22. set {furnace1.%loop-value%.smeltTime} to 0
  23. remove 1 from {furnace1.%{_loc}%.contents.ore}
  24. add 1 to {furnace1.%{_loc}%.contents.ingot}
  25.  
  26. if {furnace1.%loop-value%.fuelingTime} >= {furnace1.%Loop-value%.fuelingTimeMax}:
  27. remove 1 from {furnace1.%loop-value%.contents.fuel}
  28. if {furnace1.%loop-value%.contents.fuel} <= 0:
  29. remove loop-value from {furnace1.loopList::*}
  30.  
  31. wait 1 second
  32.  
  33. function loop1():
  34. #if {furnace2.looping} is not true
  35.  
  36. # Returns how many ticks an item gives fuel
  37. function getFuelingTime(type: Item) :: integer:
  38. if {_type} is lava:
  39. return 20000
  40. else if {_type} is block of coal:
  41. return 16000
  42. else if {_type} is dried kelp block:
  43. return 4000
  44. else if {_type} is blaze rod:
  45. return 2400
  46. else if {_type} is coal or charcoal:
  47. return 1600
  48. else if {_type} is any boat or scaffolding:
  49. return 1200
  50. 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:
  51. return 300
  52. 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:
  53. return 200
  54. else if {_type} is bowl or any sapling or stick or any wool:
  55. return 100
  56. else if {_type} is any carpet:
  57. return 67
  58. else if {_type} is bamboo:
  59. return 50
  60. return 0
  61.  
  62. # Returns if the item can be smelted in the furnace, every smelt takes 10 seconds in a normal furnace
  63. function canSmelt(type: Item, tier: Integer) :: boolean:
  64. if {_type} is iron ore or gold ore or lapis ore or redstone ore or coal ore:
  65. return true
  66. else if {_tier} is 2:
  67. if {_type} is diamond ore or emerald ore or nether quartz ore:
  68. return true
  69.  
  70. return false
  71.  
  72. function outlineGui(p: Player):
  73. loop 9 times:
  74. set slot loop-value - 1 of {_p}'s current inventory to gray stained glass pane named "&8"
  75. set slot 54-loop-value of {_p}'s current inventory to gray stained glass pane named "&8"
  76.  
  77. loop 5 times:
  78. set slot loop-value * 9 of {_p}'s current inventory to gray stained glass pane named "&8"
  79. set slot loop-value * 9-1 of {_p}'s current inventory to gray stained glass pane named "&8"
  80.  
  81. function openGuiOutlined(p: Player, loc: Location, rows: integer, name: String):
  82. open chest with {_rows} rows named {_name} to {_p}
  83. set {inventory.%{_p}%.name} to uncolored {_name}
  84. set {inventory.%{_p}%.current} to {_loc}
  85. add {_p} to {inventoryList.%{_loc}%.%{inventory.%{_p}%.name}%::*}
  86. wait 2 ticks
  87. outlineGui({_p})
  88.  
  89. #function gui(p: Player):
  90. # openGuiOutlined({_p}, 6, "&8Anvil")
  91. #subcategorie armor -> alle armor die je kan maken laten zien
  92.  
  93. function guiFurnace1(p: Player, loc: Location):
  94. openGuiOutlined({_p}, {_loc}, 6, "&8Furnace I")
  95.  
  96. if {furnace1.%{_loc}%.contents.fuel} is not set:
  97. set {furnace1.%{_loc}%.contents.fuel} to 0
  98. if {furnace1.%{_loc}%.contents.ore} is not set:
  99. set {furnace1.%{_loc}%.contents.ore} to 0
  100. if {furnace1.%{_loc}%.contents.ingot} is not set:
  101. set {furnace1.%{_loc}%.contents.ingot} to 0
  102.  
  103. if {furnace1.%{_loc}%.contents.ingotType} is not set:
  104. set {furnace1.%{_loc}%.contents.ingot} to 0
  105. if {furnace1.%{_loc}%.contents.oreType} is not set:
  106. set {furnace1.%{_loc}%.contents.ore} to 0
  107. if {furnace1.%{_loc}%.contents.fuelType} is not set:
  108. set {furnace1.%{_loc}%.contents.fuel} to 0
  109.  
  110. set {furnace1.%{_loc}%.fuelingTimeMax} to 0
  111. if {furnace1.%{_loc}%.contents.fuelType} is set:
  112. set {furnace1.%{_loc}%.fuelingTimeMax} to getFuelingTime({furnace1.%{_loc}%.contents.fuelType}) / 20
  113.  
  114. set slot 38 of {_p}'s current inventory to lime stained glass pane named "&a&lOre"
  115. set slot 40 of {_p}'s current inventory to lime stained glass pane named "&a&lFuel"
  116. set slot 42 of {_p}'s current inventory to lime stained glass pane named "&a&lIngot"
  117.  
  118. if {furnace1.%{_loc}%.contents.ore} > 0:
  119. set slot 38 of {_p}'s current inventory to ("%{furnace1.%{_loc}%.contents.ore}% %{furnace1.%{_loc}%.contents.oreType}%" parsed as an item)
  120.  
  121. if {furnace1.%{_loc}%.contents.fuel} > 0:
  122. set slot 40 of {_p}'s current inventory to ("%{furnace1.%{_loc}%.contents.fuel}% %{furnace1.%{_loc}%.contents.fuelType}%" parsed as an item)
  123.  
  124. if {furnace1.%{_loc}%.contents.ingot} > 0:
  125. set slot 42 of {_p}'s current inventory to ("%{furnace1.%{_loc}%.contents.ingot}% %{furnace1.%{_loc}%.contents.ingotType}%" parsed as an item)
  126.  
  127. #Slot for ore
  128.  
  129. #Slot for ingot
  130.  
  131. # loop for the cooking -- use states
  132.  
  133. loop 5 times:
  134. set slot 19 + loop-value of {_p}'s current inventory to gray stained glass pane named "&f0%%"
  135.  
  136.  
  137.  
  138. # U T I L I T I E S
  139.  
  140. function getNextNumber(base: number, addToDefault: number, max: number) :: number:
  141. set {_value} to {_base} + {_addToDefault}
  142. if {_value} > {_max}:
  143. set {_value} to {_addToDefault} - ({_max} - {_base})
  144.  
  145. return {_value}
  146.  
  147. function detectStair(facing: number, loc: Location, startValue: String) :: boolean:
  148. set {_list::*} to "westward red brick stair", "red brick stair", "eastward red brick stair" and "southward red brick stair"
  149. set {_dir} to {_facing}/2 + 1
  150.  
  151. if {_dir} > 4:
  152. remove 4 from {_dir}
  153.  
  154. if "%block at location of {_loc}%" is "%{_startValue}%%{_list::%{_dir}%}%":
  155. return true
  156. return false
  157.  
  158.  
  159. function setItemInSlot(p: Player, type: String, slot: number, clickedItem: Item, item: Item):
  160. if {_type} is "ore" or "fuel" or "ingot":
  161. set {_p}'s cursor slot to {_clickedItem}
  162. set slot {_slot} of {_p}'s current inventory to {_item}
  163. set {_itemStack::*} to ("%{_item}%") split at " "
  164. set {furnace1.%{inventory.%{_p}%.current}%.contents.%{_type}%} to {_itemStack::1} parsed as a number
  165. set {furnace1.%{inventory.%{_p}%.current}%.contents.%{_type}%Type} to type of {_item}
  166.  
  167. # functie overal neerzetten
  168. # ingots
  169. # smelting progress -> Live update
  170.  
  171.  
  172. # F U R N A C E D E T E C T S
  173.  
  174. function isFurnace1(below: Location) :: boolean:
  175. if block at {_below} is campfire:
  176. set {_xAdjust::*} to 1, 1, 1, 0, 0, -1, -1 and -1
  177. set {_zAdjust::*} to 1, 0, -1, 1, -1, 1, 0 and -1
  178. loop 8 times:
  179. 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}
  180. if block at {_checkLoc} is not red brick block:
  181. return false
  182. else:
  183. return false
  184. return true
  185.  
  186.  
  187. function isFurnace2(loc: Location) :: boolean:
  188. if block at {_loc} is not blast furnace:
  189. return false
  190.  
  191. set {_layer1::*} to air, brick slab, red brick block, air, red brick block, air, red brick block and brick slab
  192. set {_layer2::*} to air, red brick stair, eastward red brick stair and southward red brick stair
  193. set {_x::*} to 1, 1, 0, -1, -1, -1, 0 and 1
  194. set {_z::*} to 0, 1, 1, 1, 0, -1, -1 and -1
  195.  
  196. set {_base} to -2
  197. 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}:
  198. set {_base} to 0
  199.  
  200. 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}:
  201. set {_base} to 2
  202.  
  203. 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}:
  204. set {_base} to 4
  205.  
  206. 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}:
  207. set {_base} to 6
  208.  
  209. set {_size} to size of {_x::*}
  210. if {_base} is not -2:
  211. loop 7 times:
  212. set {_value} to getNextNumber({_base}, loop-value, {_size})
  213. 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%}:
  214. return false
  215.  
  216.  
  217. set {_facingAdjust::*} to 0, 4, 6 and 8
  218. if detectStair({_base}, location 1 meters above {_loc}, "top "):
  219. loop 4 times:
  220. set {_value} to getNextNumber({_base}, loop-value*2, {_size}) - 1
  221. 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}
  222. set {_facing} to {_base}
  223. if {_facing} - {_facingAdjust::%loop-value%} >= 2:
  224. remove {_facingAdjust::%loop-value%} from {_facing}
  225. else:
  226. add {_facingAdjust::%loop-value%} to {_facing}
  227.  
  228. if loop-value is 1:
  229. if block at {_check} is not {_layer2::%loop-value%}:
  230. return false
  231. else if detectStair({_facing} - 2, {_check}, "") is false:
  232. return false
  233.  
  234. if block at location 2 meters above {_loc} is not red brick block:
  235. return false
  236. else:
  237. return false
  238. else:
  239. return false
  240. return true
  241.  
  242. # C L I C K E V E N T S
  243.  
  244. on rightclick on smooth stone:
  245. if player is not sneaking:
  246. if {anvil.%location of clicked block%} is true:
  247. #gui(player)
  248. cancel event
  249.  
  250. on rightclick on cauldron:
  251. if {furnace.%location of event-block%} is true:
  252. if isFurnace1(location 1 meters below clicked block):
  253. cancel event
  254. guiFurnace1(player, location of clicked block)
  255.  
  256. else:
  257. delete {furnace1.%location of clicked block%.contents.fuel}
  258. delete {furnace1.%location of clicked block%.contents.ore}
  259. delete {furnace1.%location of clicked block%.contents.ingot}
  260. delete {furnace.%location of event-block%}
  261.  
  262. on rightclick on blast furnace:
  263. if {furnace2.%location of event-block%} is true:
  264. if isFurnace2(location of clicked block):
  265. cancel event
  266. send "WIP"
  267. else:
  268. delete {furnace2.%location of event-block%}
  269.  
  270. on rightclick holding stone axe:
  271. if clicked block is smooth stone or iron block or diamond block:
  272. if {anvil.%location of event-block%} is not true:
  273. set {anvil.%location of event-block%} to true
  274. set {_tier} to "Tier I"
  275. if clicked block is smooth stone:
  276. set {anvil.%location of event-block%.tier} to 1
  277. else if clicked block is iron block:
  278. set {anvil.%location of event-block%.tier} to 2
  279. set {_tier} to "Tier II"
  280. else:
  281. set {anvil.%location of event-block%.tier} to 3
  282. set {_tier} to "Tier III"
  283.  
  284. set {_s} to 6
  285. loop all players in radius 6 around event-block:
  286. set {_v} to ({_s} - distance between loop-player and event-block)
  287. play sound "block.anvil.place" with volume {_v} and pitch 0 to loop-player
  288.  
  289. send "{@logo} Successfully created an anvil of %{_tier}%."
  290. summon armor stand at location 0.6 meters below event-block
  291. set name of last spawned armor stand to "&7Anvil"
  292. add "{Invisible:1b,NoGravity:1b,NoAI:1b,CustomNameVisible:1}" to NBT of last spawned armor stand
  293.  
  294. summon armor stand at location 0.9 meters below event-block
  295. set name of last spawned armor stand to "&7%{_tier}%"
  296. add "{Invisible:1b,NoGravity:1b,NoAI:1b,CustomNameVisible:1}" to NBT of last spawned armor stand
  297.  
  298. else if clicked block is cauldron:
  299. if {furnace.%location of event-block%} is not true:
  300. if isFurnace1(location 1 meters below clicked block):
  301. set {furnace.%location of event-block%} to true
  302. cancel event
  303.  
  304. else if clicked block is blast furnace:
  305. if {furnace.%location of event-block%} is not true:
  306. if isFurnace2(location of clicked block):
  307. set {furnace2.%location of event-block%} to true
  308. cancel event
  309. send "WIP"
  310.  
  311. on break of smooth stone or iron block or diamond block:
  312. if {anvil.%location of event-block%} is true:
  313. set {_s} to 6
  314. loop all players in radius 6 around event-block:
  315. set {_v} to ({_s} - distance between loop-player and event-block)
  316. play sound "block.anvil.place" with volume {_v} and pitch 0 to loop-player
  317. delete {anvil.%location of event-block%}
  318. delete {anvil.%location of event-block%.tier}
  319. loop entities in radius 1 around event-block:
  320. if type of loop-entity is armor stand:
  321. kill loop-entity
  322.  
  323.  
  324. on inventory click:
  325. if type of clicked inventory is chest inventory:
  326. if inventory name of player's current inventory is "&8Anvil":
  327. cancel event
  328.  
  329. else if inventory name of player's current inventory is "&8Furnace I":
  330. cancel event
  331. if clicked slot is set:
  332. if clicked item is not air:
  333. set {_item} to player's cursor slot
  334. if {_item} is not air:
  335. if name of clicked item is "&a&lOre":
  336. if canSmelt({_item}, 1):
  337. set slot (clicked slot) of player's current inventory to {_item}
  338. set player's cursor to air
  339. else if name of clicked item is "&a&lFuel":
  340. if getFuelingTime({_item}) > 0:
  341. set slot (clicked slot) of player's current inventory to {_item}
  342. set player's cursor to air
  343. else if getFuelingTime(clicked item) > 0:
  344. if getFuelingTime({_item}) > 0:
  345. set player's cursor slot to clicked item
  346. set slot (clicked slot) of player's current inventory to {_item}
  347. else if canSmelt(clicked item, 1) is true:
  348. if canSmelt({_item}, 1):
  349. setItemInSlot(player, "ore", clicked slot, clicked item, {_item})
  350. else if getFuelingTime(clicked item) > 0:
  351. set player's cursor slot to clicked item
  352. set slot (clicked slot) of player's current inventory to lime stained glass pane named "&a&lFuel"
  353. else if canSmelt(clicked item, 1) is true:
  354. set player's cursor slot to clicked item
  355. set slot (clicked slot) of player's current inventory to lime stained glass pane named "&a&lOre"
  356.  
  357. #ingot check
  358. #set slot 42 of {_p}'s current inventory to lime stained glass pane named "&a&lIngot"
  359.  
  360. #ore type
  361. #fuel type
  362.  
  363. # on inventory drag?
  364. # fuel/ore uit cursor slot verwijderen
  365. # fuel/ore uit inventory halen
  366. # fuel/ore opslaan
  367.  
  368.  
  369. on inventory close:
  370. if {inventory.%player%.name} is set:
  371. remove player from {inventoryList.%{inventory.%player%.current}%.%{inventory.%player%.name}%::*}
  372. delete {inventory.%player%.name}
  373. delete {inventory.%player%.current}
  374.  
  375. on inventory drag:
  376. if {inventory.%player%.name} is "Anvil" or "Furnace I" or "Furnace II":
  377. cancel event
  378.  
  379. #Cancel in crafting table or below
  380. #register new shaped recipe for air using iron ingot, air, iron ingot, iron ingot, chest, iron ingot, air, iron ingot, air
  381.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement