Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #multiblock structure
- #rename function
- #requires: SkQuery, SkRayFall, Skellett, SkBee, TuSKe
- options:
- logo: &6&lBS&8:&7
- function updateItemInSlot(furnaceId: Location, type: String, slot: Number, furnaceTier: String, typeId: integer):
- set {_typeLower} to {_type} in lower case
- loop {inventoryList.%{_furnaceId}%.furnace%{_furnaceTier}%::*}:
- 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)
- if {furnace%{_typeId}%.%{_furnaceId}%.contents.%{_typeLower}%} <= 0:
- set slot {_slot} of loop-value's current inventory to lime stained glass pane named "&a&l%{_type}%"
- function updateItemAndRemoveFromLoop(p: Player, item: Item, slot: Number, furnaceTier: Integer, furnaceTierString: String, itemName: String, leftClick: Boolean):
- set {_nameLower} to {_itemName} in lower case
- set {_amount} to {furnace1.%{inventory.%{_p}%.current}%.contents.%{_nameLower}%}
- set {_removedAmount} to {_amount}
- if {_leftClick} is false:
- set {_removedAmount} to "%{_amount}/2%" parsed as a integer
- set {_item} to "%{_amount}-{_removedAmount}% %type of {_item}%" parsed as an item
- set {_p}'s cursor slot to {_item}
- set {furnace1.%{inventory.%{_p}%.current}%.contents.%{_nameLower}%} to {_amount}-{_removedAmount}
- if {_amount}-{_removedAmount} <= 0:
- delete {furnace1.%{inventory.%{_p}%.current}%.contents.%{_nameLower}%Type}
- set slot ({_slot}) of {_p}'s current inventory to lime stained glass pane named "&a&l%{_itemName}%"
- if {_nameLower} is "ore" or "fuel":
- resetFuelIndicator({inventory.%{_p}%.current}, {_furnaceTierString})
- else:
- set slot ({_slot}) of {_p}'s current inventory to "%{_amount}-{_removedAmount}% %{furnace1.%{inventory.%{_p}%.current}%.contents.%{_nameLower}%Type}%" parsed as an item
- #ingots update werkt niet
- #klik op slot met item terwijl er een item in het slot zit -> maak er een hele stack van indien het kan
- function updateInventoryFuelIndicator(furnaceId: Location, progressBar: Integer, furnaceTier: String):
- if {_progressBar} <= 4:
- if {_progressBar} >= 0:
- loop {inventoryList.%{_furnaceId}%.furnace%{_furnaceTier}%::*}:
- set slot 20+{_progressBar} of loop-value's current inventory to gray stained glass pane named "&f%20*({_progressBar}+1)%%%"
- if {_progressBar} > 0:
- set slot 20+{_progressBar}-1 of loop-value's current inventory to lime stained glass pane named "&f%20*{_progressBar}%%%"
- loop 4-{_progressBar} times:
- 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)%%%"
- function resetFuelIndicator(furnaceId: Location, furnaceTier: String):
- set {furnace1.%{_furnaceId}%.smeltTime} to 0
- loop {inventoryList.%{_furnaceId}%.furnace%{_furnaceTier}%::*}:
- loop 5 times:
- set slot 19 + loop-value-2 of loop-value-1's current inventory to gray stained glass pane named "&f%20*loop-value-2%%%"
- if {_furnaceTier} is " I":
- removeFurnaceFromLoop({_furnaceId}, 1)
- else:
- removeFurnaceFromLoop({_furnaceId}, 2)
- function setIngotType(furnaceId: Location, tier: Number):
- delete {furnace%{_tier}%.%{_furnaceId}%.contents.ingotType}
- if {furnace%{_tier}%.%{_furnaceId}%.contents.ingotType} is set:
- stop
- set {_type} to "%{furnace%{_tier}%.%{_furnaceId}%.contents.oreType}%"
- if {_tier} is 2:
- if {_type} is "diamond ore", "emerald ore" or "nether quartz ore":
- replace all " ore" in {_type} with ""
- set {furnace2.%{_furnaceId}%.contents.ingotType} to {_type} parsed as an item
- stop
- if {_type} is "iron ore", "gold ore", "lapis ore" and "redstone ore":
- replace "ore" in {_type} with "ingot"
- set {furnace%{_tier}%.%{_furnaceId}%.contents.ingotType} to {_type} parsed as an item
- else if {_type} is "coal ore":
- set {furnace%{_tier}%.%{_furnaceId}%.contents.ingotType} to coal
- function removeFurnaceFromLoop(furnaceId: Location, typeId: integer):
- delete {furnace.%{_furnaceId}%.isAddedToLoop}
- remove {_furnaceId} from {furnace%{_typeId}%.loopList::*}
- function loop_furnace1():
- set {furnace1.looping} to false
- if {furnace1.looping} is not true:
- set {furnace1.looping} to true
- while {furnace1.looping} is true:
- if size of {furnace1.loopList::*} is 0:
- set {furnace1.looping} to false
- stop loop
- else:
- loop {furnace1.loopList::*}:
- if {furnace1.%loop-value%.contents.ore} < 1:
- updateInventoryFuelIndicator(loop-value, 0, " I")
- removeFurnaceFromLoop(loop-value, 1)
- else:
- if {furnace1.%loop-value%.contents.fuelingTime} is not set:
- remove 1 from {furnace1.%loop-value%.contents.fuel}
- updateItemInSlot(loop-value, "Fuel", 40, " I", 1)
- add 1 to {furnace1.%loop-value%.smeltTime}
- add 1 to {furnace1.%loop-value%.fuelingTime}
- if "%{furnace1.%loop-value%.smeltTime}/2.0%" doesn't contain ".":
- if {furnace1.%loop-value%.smeltTime}/2 > 4:
- updateInventoryFuelIndicator(loop-value, 0, " I")
- else:
- updateInventoryFuelIndicator(loop-value, "%{furnace1.%loop-value%.smeltTime}/2%" parsed as an integer, " I")
- if {furnace1.%loop-value%.smeltTime} > 9:
- delete {furnace1.%loop-value%.smeltTime}
- remove 1 from {furnace1.%loop-value%.contents.ore}
- add 1 to {furnace1.%loop-value%.contents.ingot}
- setIngotType(loop-value, 1)
- updateItemInSlot(loop-value, "Ore", 38, " I", 1)
- updateItemInSlot(loop-value, "Ingot", 42, " I", 1)
- updateInventoryFuelIndicator(loop-value, 0, " I")
- if {furnace1.%loop-value%.fuelingTime} >= {furnace1.%Loop-value%.fuelingTimeMax}:
- if {furnace1.%loop-value%.contents.fuel} <= 0:
- delete {furnace1.%loop-value%.smeltTime}
- removeFurnaceFromLoop(loop-value, 1)
- updateInventoryFuelIndicator(loop-value, 0, " I")
- else:
- delete {furnace1.%loop-value%.fuelingTime}
- wait 1 second
- #function loop_furnace2():
- #if {furnace2.looping} is not true
- # Returns how many ticks an item gives fuel
- function getFuelingTime(type: Item) :: integer:
- if {_type} is lava:
- return 20000
- else if {_type} is block of coal:
- return 16000
- else if {_type} is dried kelp block:
- return 4000
- else if {_type} is blaze rod:
- return 2400
- else if {_type} is coal or charcoal:
- return 1600
- else if {_type} is any boat or scaffolding:
- return 1200
- 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:
- return 300
- 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:
- return 200
- else if {_type} is bowl or any sapling or stick or any wool:
- return 100
- else if {_type} is any carpet:
- return 67
- else if {_type} is bamboo:
- return 50
- return 0
- # Returns if the item can be smelted in the furnace, every smelt takes 10 seconds in a normal furnace
- function canSmelt(type: Item, tier: Integer) :: boolean:
- if {_type} is iron ore or gold ore or lapis ore or redstone ore or coal ore:
- return true
- else if {_tier} is 2:
- if {_type} is diamond ore or emerald ore or nether quartz ore:
- return true
- return false
- function canSmeltInFurnace(p: Player, item: Item) :: boolean:
- set {_furnaceId} to {inventory.%{_p}%.current}
- if {furnace1.%{_furnaceId}%.contents.oreType} is set:
- if "%type of {_item}%" is not "%type of {furnace1.%{_furnaceId}%.contents.oreType}%":
- return false
- if {furnace1.%{_furnaceId}%.contents.ingotType} is set:
- if type of {_item} is coal ore:
- if type of {furnace1.%{_furnaceId}%.contents.ingotType} is coal:
- return true
- set {_item} to "%type of {_item}%"
- replace all " ore" in {_item} with " ingot"
- if {_item} is not "%type of {furnace1.%{_furnaceId}%.contents.ingotType}%":
- return false
- return true
- function outlineGui(p: Player):
- loop 9 times:
- set slot loop-value - 1 of {_p}'s current inventory to gray stained glass pane named "&8"
- set slot 54-loop-value of {_p}'s current inventory to gray stained glass pane named "&8"
- loop 5 times:
- set slot loop-value * 9 of {_p}'s current inventory to gray stained glass pane named "&8"
- set slot loop-value * 9-1 of {_p}'s current inventory to gray stained glass pane named "&8"
- function openGuiOutlined(p: Player, loc: Location, rows: integer, name: String):
- open chest with {_rows} rows named {_name} to {_p}
- set {inventory.%{_p}%.name} to uncolored {_name}
- set {inventory.%{_p}%.current} to {_loc}
- add {_p} to {inventoryList.%{_loc}%.%{inventory.%{_p}%.name}%::*}
- wait 2 ticks
- outlineGui({_p})
- function guiFurnace1(p: Player, loc: Location):
- openGuiOutlined({_p}, {_loc}, 6, "&8Furnace I")
- if {furnace1.%{_loc}%.contents.fuel} is not set:
- set {furnace1.%{_loc}%.contents.fuel} to 0
- if {furnace1.%{_loc}%.contents.ore} is not set:
- set {furnace1.%{_loc}%.contents.ore} to 0
- if {furnace1.%{_loc}%.contents.ingot} is not set:
- set {furnace1.%{_loc}%.contents.ingot} to 0
- if {furnace1.%{_loc}%.contents.ingotType} is not set:
- set {furnace1.%{_loc}%.contents.ingot} to 0
- if {furnace1.%{_loc}%.contents.oreType} is not set:
- set {furnace1.%{_loc}%.contents.ore} to 0
- if {furnace1.%{_loc}%.contents.fuelType} is not set:
- set {furnace1.%{_loc}%.contents.fuel} to 0
- set {furnace1.%{_loc}%.fuelingTimeMax} to 0
- if {furnace1.%{_loc}%.contents.fuelType} is set:
- set {furnace1.%{_loc}%.fuelingTimeMax} to getFuelingTime({furnace1.%{_loc}%.contents.fuelType}) / 20
- set slot 38 of {_p}'s current inventory to lime stained glass pane named "&a&lOre"
- set slot 40 of {_p}'s current inventory to lime stained glass pane named "&a&lFuel"
- set slot 42 of {_p}'s current inventory to lime stained glass pane named "&a&lIngot"
- if {furnace1.%{_loc}%.contents.ore} > 0:
- set slot 38 of {_p}'s current inventory to ("%{furnace1.%{_loc}%.contents.ore}% %{furnace1.%{_loc}%.contents.oreType}%" parsed as an item)
- if {furnace1.%{_loc}%.contents.fuel} > 0:
- set slot 40 of {_p}'s current inventory to ("%{furnace1.%{_loc}%.contents.fuel}% %{furnace1.%{_loc}%.contents.fuelType}%" parsed as an item)
- if {furnace1.%{_loc}%.contents.ingot} > 0:
- set slot 42 of {_p}'s current inventory to ("%{furnace1.%{_loc}%.contents.ingot}% %{furnace1.%{_loc}%.contents.ingotType}%" parsed as an item)
- loop 5 times:
- set slot 19 + loop-value of {_p}'s current inventory to gray stained glass pane named "&f%20*loop-value%%%"
- set {_progressBar} to "%{furnace1.%{_loc}%.smeltTime}/2.0%"
- if {_progressBar} contains ".":
- set {_progressBar::*} to {_progressBar} split at "."
- set {_progressBar} to {_progressBar::1}
- loop ({_progressBar} parsed as an integer) times:
- set slot 20+loop-value -1 of {_p}'s current inventory to lime stained glass pane named "&f%20*loop-value%%%"
- # U T I L I T I E S
- function getNextNumber(base: number, addToDefault: number, max: number) :: number:
- set {_value} to {_base} + {_addToDefault}
- if {_value} > {_max}:
- set {_value} to {_addToDefault} - ({_max} - {_base})
- return {_value}
- function detectStair(facing: number, loc: Location, startValue: String) :: boolean:
- set {_list::*} to "westward red brick stair", "red brick stair", "eastward red brick stair" and "southward red brick stair"
- set {_dir} to {_facing}/2 + 1
- if {_dir} > 4:
- remove 4 from {_dir}
- if "%block at location of {_loc}%" is "%{_startValue}%%{_list::%{_dir}%}%":
- return true
- return false
- function setItemInSlot(p: Player, type: String, slot: number, clickedItem: Item, item: Item, startLoop: Boolean):
- if {_type} is "ore" or "fuel" or "ingot":
- set {_p}'s cursor slot to {_clickedItem}
- set slot {_slot} of {_p}'s current inventory to {_item}
- set {_itemStack::*} to ("%{_item}%") split at " "
- if ({_itemStack::1} parsed as a number) is not set:
- set {_itemStack::3} to {_itemStack::2}
- set {_itemStack::2} to {_itemStack::1}
- set {_itemStack::1} to "1"
- set {furnace1.%{inventory.%{_p}%.current}%.contents.%{_type}%} to {_itemStack::1} parsed as a number
- set {furnace1.%{inventory.%{_p}%.current}%.contents.%{_type}%Type} to type of {_item}
- if {_startLoop}:
- if {furnace.%{inventory.%{_p}%.current}%.isAddedToLoop} is not true:
- add {inventory.%{_p}%.current} to {furnace1.loopList::*}
- loop_furnace1()
- # ingots
- # F U R N A C E D E T E C T S
- function isFurnace1(below: Location) :: boolean:
- if block at {_below} is campfire:
- set {_xAdjust::*} to 1, 1, 1, 0, 0, -1, -1 and -1
- set {_zAdjust::*} to 1, 0, -1, 1, -1, 1, 0 and -1
- loop 8 times:
- 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}
- if block at {_checkLoc} is not red brick block:
- return false
- else:
- return false
- return true
- function isFurnace2(loc: Location) :: boolean:
- if block at {_loc} is not blast furnace:
- return false
- set {_layer1::*} to air, brick slab, red brick block, air, red brick block, air, red brick block and brick slab
- set {_layer2::*} to air, red brick stair, eastward red brick stair and southward red brick stair
- set {_x::*} to 1, 1, 0, -1, -1, -1, 0 and 1
- set {_z::*} to 0, 1, 1, 1, 0, -1, -1 and -1
- set {_base} to -2
- 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}:
- set {_base} to 0
- 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}:
- set {_base} to 2
- 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}:
- set {_base} to 4
- 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}:
- set {_base} to 6
- set {_size} to size of {_x::*}
- if {_base} is not -2:
- loop 7 times:
- set {_value} to getNextNumber({_base}, loop-value, {_size})
- 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%}:
- return false
- set {_facingAdjust::*} to 0, 4, 6 and 8
- if detectStair({_base}, location 1 meters above {_loc}, "top "):
- loop 4 times:
- set {_value} to getNextNumber({_base}, loop-value*2, {_size}) - 1
- 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}
- set {_facing} to {_base}
- if {_facing} - {_facingAdjust::%loop-value%} >= 2:
- remove {_facingAdjust::%loop-value%} from {_facing}
- else:
- add {_facingAdjust::%loop-value%} to {_facing}
- if loop-value is 1:
- if block at {_check} is not {_layer2::%loop-value%}:
- return false
- else if detectStair({_facing} - 2, {_check}, "") is false:
- return false
- if block at location 2 meters above {_loc} is not red brick block:
- return false
- else:
- return false
- else:
- return false
- return true
- # C L I C K E V E N T S
- on rightclick on smooth stone:
- if player is not sneaking:
- if {anvil.%location of clicked block%} is true:
- #gui(player)
- cancel event
- on rightclick on cauldron:
- if {furnace.%location of event-block%} is true:
- if isFurnace1(location 1 meters below clicked block):
- cancel event
- guiFurnace1(player, location of clicked block)
- else:
- delete {furnace1.%location of clicked block%.contents.fuel}
- delete {furnace1.%location of clicked block%.contents.ore}
- delete {furnace1.%location of clicked block%.contents.ingot}
- delete {furnace.%location of event-block%}
- on rightclick on blast furnace:
- if {furnace2.%location of event-block%} is true:
- if isFurnace2(location of clicked block):
- cancel event
- send "WIP"
- else:
- delete {furnace2.%location of event-block%}
- on rightclick holding stone axe:
- if clicked block is smooth stone or iron block or diamond block:
- if {anvil.%location of event-block%} is not true:
- set {anvil.%location of event-block%} to true
- set {_tier} to "Tier I"
- if clicked block is smooth stone:
- set {anvil.%location of event-block%.tier} to 1
- else if clicked block is iron block:
- set {anvil.%location of event-block%.tier} to 2
- set {_tier} to "Tier II"
- else:
- set {anvil.%location of event-block%.tier} to 3
- set {_tier} to "Tier III"
- set {_s} to 6
- loop all players in radius 6 around event-block:
- set {_v} to ({_s} - distance between loop-player and event-block)
- play sound "block.anvil.place" with volume {_v} and pitch 0 to loop-player
- send "{@logo} Successfully created an anvil of %{_tier}%."
- summon armor stand at location 0.6 meters below event-block
- set name of last spawned armor stand to "&7Anvil"
- add "{Invisible:1b,NoGravity:1b,NoAI:1b,CustomNameVisible:1}" to NBT of last spawned armor stand
- summon armor stand at location 0.9 meters below event-block
- set name of last spawned armor stand to "&7%{_tier}%"
- add "{Invisible:1b,NoGravity:1b,NoAI:1b,CustomNameVisible:1}" to NBT of last spawned armor stand
- else if clicked block is cauldron:
- if {furnace.%location of event-block%} is not true:
- if isFurnace1(location 1 meters below clicked block):
- set {furnace.%location of event-block%} to true
- cancel event
- else if clicked block is blast furnace:
- if {furnace.%location of event-block%} is not true:
- if isFurnace2(location of clicked block):
- set {furnace2.%location of event-block%} to true
- cancel event
- send "WIP"
- on break of smooth stone or iron block or diamond block:
- if {anvil.%location of event-block%} is true:
- set {_s} to 6
- loop all players in radius 6 around event-block:
- set {_v} to ({_s} - distance between loop-player and event-block)
- play sound "block.anvil.place" with volume {_v} and pitch 0 to loop-player
- delete {anvil.%location of event-block%}
- delete {anvil.%location of event-block%.tier}
- loop entities in radius 1 around event-block:
- if type of loop-entity is armor stand:
- kill loop-entity
- #right and left click fixes?
- on inventory click:
- if type of clicked inventory is chest inventory:
- if inventory name of player's current inventory is "&8Anvil":
- cancel event
- else if inventory name of player's current inventory is "&8Furnace I":
- #if click type is left mouse button:
- # send "LEft"
- cancel event
- if clicked slot is set:
- if clicked item is not air:
- set {_item} to player's cursor slot
- set {_leftClick} to false
- if click type is left mouse button:
- set {_leftClick} to true
- if {_item} is not air:
- if name of clicked item is "&a&lOre":
- if canSmelt({_item}, 1):
- if canSmeltInFurnace(player, {_item}):
- setItemInSlot(player, "ore", clicked slot, clicked item, {_item}, true)
- set player's cursor to air
- else if name of clicked item is "&a&lFuel":
- if getFuelingTime({_item}) > 0:
- setItemInSlot(player, "fuel", clicked slot, clicked item, {_item}, true)
- set player's cursor to air
- else if getFuelingTime(clicked item) > 0:
- if getFuelingTime({_item}) > 0:
- setItemInSlot(player, "fuel", clicked slot, clicked item, {_item}, false)
- else if canSmelt(clicked item, 1) is true:
- if canSmelt({_item}, 1):
- if canSmeltInFurnace(player, {_item}):
- setItemInSlot(player, "ore", clicked slot, clicked item, {_item}, false)
- else if clicked slot is 42:
- if type of clicked item is not lime stained glass pane:
- updateItemAndRemoveFromLoop(player, clicked item, clicked slot, 1, " I", "Ingot", {_leftClick})
- else if getFuelingTime(clicked item) > 0:
- updateItemAndRemoveFromLoop(player, clicked item, clicked slot, 1, " I", "Fuel", {_leftClick})
- else if canSmelt(clicked item, 1) is true:
- updateItemAndRemoveFromLoop(player, clicked item, clicked slot, 1, " I", "Ore", {_leftClick})
- on inventory close:
- if {inventory.%player%.name} is set:
- remove player from {inventoryList.%{inventory.%player%.current}%.%{inventory.%player%.name}%::*}
- delete {inventory.%player%.name}
- delete {inventory.%player%.current}
- on inventory drag:
- if {inventory.%player%.name} is "Anvil" or "Furnace I" or "Furnace II":
- cancel event
- on disable:
- if {furnace1.looping} is true:
- set {furnace1.looping} to false
- set {furnace1.loopStopped} to true
- on enable:
- wait 1 second
- if {furnace1.loopStopped} is true:
- set {furnace1.looping} to true
- set {furnace1.loopStopped} to false
- #Cancel in crafting table or below
- #register new shaped recipe for air using iron ingot, air, iron ingot, iron ingot, chest, iron ingot, air, iron ingot, air
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement