From 0f45de26c9f60461bc69d0a40019f2f9c9c602d8 Mon Sep 17 00:00:00 2001 From: Bavadin <115598588+Bavadin@users.noreply.github.com> Date: Fri, 20 Dec 2024 02:31:47 -0800 Subject: [PATCH] Add scorebaord do2.utility.onInstance, and run most actions on it rather than onServer (0.13.17) --- .../agronet/shut_down_server.mcfunction | 8 +- .../agronet/test_for_instance.mcfunction | 6 ++ .../events/on_datapack_load.mcfunction | 96 ++++++++++--------- .../events/on_datapack_tick.mcfunction | 4 +- .../events/on_player_join.mcfunction | 2 +- .../do2/functions/reset_player.mcfunction | 4 +- .../scoreboard/setup/utility.mcfunction | 3 + .../data/do2/functions/version.mcfunction | 4 +- JSON/scoreboards.json | 6 ++ docs/scoreboard.md | 1 + 10 files changed, 77 insertions(+), 57 deletions(-) create mode 100644 Brilliance Datapack/data/do2/functions/agronet/test_for_instance.mcfunction diff --git a/Brilliance Datapack/data/do2/functions/agronet/shut_down_server.mcfunction b/Brilliance Datapack/data/do2/functions/agronet/shut_down_server.mcfunction index c32532ce..7bab883a 100644 --- a/Brilliance Datapack/data/do2/functions/agronet/shut_down_server.mcfunction +++ b/Brilliance Datapack/data/do2/functions/agronet/shut_down_server.mcfunction @@ -1,8 +1,8 @@ log-event exit-button-pressed 1 -execute if score $dungeon do2.utility.onServer matches 1 run kick @a[tag=!do2.staff] -execute if score $dungeon do2.utility.onServer matches 1 run tellraw @s ["",{"text":"[§9B§r]: You have the tag [§bdo2.staff§r], and this has stopped:\n - §5/kick "},{"selector":"@s","color":"dark_purple"},{"text":"\n§f[§9B§r]: Click "},{"text":"§b[here]","clickEvent":{"action":"run_command","value":"/kick @s"}},{"text":" to run the command anyway."}] +execute if score $dungeon do2.utility.onInstance matches 1 run kick @a[tag=!do2.staff] +execute if score $dungeon do2.utility.onInstance matches 1 run tellraw @s ["",{"text":"[§9B§r]: You have the tag [§bdo2.staff§r], and this has stopped:\n - §5/kick "},{"selector":"@s","color":"dark_purple"},{"text":"\n§f[§9B§r]: Click "},{"text":"§b[here]","clickEvent":{"action":"run_command","value":"/kick @s"}},{"text":" to run the command anyway."}] -execute if score $dungeon do2.utility.onServer matches 1 unless entity @a[tag=do2.staff] run stop -execute if score $dungeon do2.utility.onServer matches 1 as @a[tag=do2.staff] run tellraw @s ["",{"text":"[§9B§r]: You have the tag [§bdo2.staff§r], and this has stopped:\n - §5/stop\n§f[§9B§r]: Click "},{"text":"§b[here]","clickEvent":{"action":"run_command","value":"/stop"}},{"text":" to run the command anyway."}] +execute if score $dungeon do2.utility.onInstance matches 1 unless entity @a[tag=do2.staff] run stop +execute if score $dungeon do2.utility.onInstance matches 1 as @a[tag=do2.staff] run tellraw @s ["",{"text":"[§9B§r]: You have the tag [§bdo2.staff§r], and this has stopped:\n - §5/stop\n§f[§9B§r]: Click "},{"text":"§b[here]","clickEvent":{"action":"run_command","value":"/stop"}},{"text":" to run the command anyway."}] diff --git a/Brilliance Datapack/data/do2/functions/agronet/test_for_instance.mcfunction b/Brilliance Datapack/data/do2/functions/agronet/test_for_instance.mcfunction new file mode 100644 index 00000000..ccb29904 --- /dev/null +++ b/Brilliance Datapack/data/do2/functions/agronet/test_for_instance.mcfunction @@ -0,0 +1,6 @@ + +# This command will NEVER run, player's aren't bees :P +# But, since the command "is-dungeon-instance" is part of the wordage, this file will fail to load if NOT on an instance. +execute as @p if entity @s[type=bee] run is-dungeon-instance + +scoreboard players set $dungeon do2.utility.onInstance 1 \ No newline at end of file diff --git a/Brilliance Datapack/data/do2/functions/events/on_datapack_load.mcfunction b/Brilliance Datapack/data/do2/functions/events/on_datapack_load.mcfunction index 2e0e567a..1766ecd6 100644 --- a/Brilliance Datapack/data/do2/functions/events/on_datapack_load.mcfunction +++ b/Brilliance Datapack/data/do2/functions/events/on_datapack_load.mcfunction @@ -2,10 +2,14 @@ execute as @a[scores={do2.logs.datapack_setup=1..}] run tellraw @s "§f[§9B§r]: Datapack loaded." # - End Log - -# Check if I'm on the server or not. +# Check where I'm running. scoreboard objectives add do2.utility.onServer dummy "Checking if this Brilliance is loaded on the server" execute unless score $dungeon do2.utility.onServer matches 0.. run scoreboard players set $dungeon do2.utility.onServer 0 function do2:agronet/test_for_agronet +scoreboard objectives add do2.utility.onInstance dummy "Checking if this Brilliance is loaded on an instance" +execute unless score $dungeon do2.utility.onInstance matches 0.. run scoreboard players set $dungeon do2.utility.onInstance 0 +function do2:agronet/test_for_instance + # Setup scoreboard function do2:scoreboard/setup/all # Setup stats room @@ -35,52 +39,52 @@ time set noon weather clear -# If server has agronet, than set worldspawn to be the deck area. +# If server has is-dungeon-instance, than set worldspawn to be the deck area. # Otherwise set worldspawn to be the portal -execute if score $dungeon do2.utility.onServer matches 0 run setworldspawn -524 103 2167 -execute if score $dungeon do2.utility.onServer matches 1 run setworldspawn -547 115 1980 - -# If server has agronet, unlock the iron door. NOTE: If it's on the server, only one use -execute if score $dungeon do2.utility.onServer matches 1 run setblock -551 119 1977 minecraft:redstone_block -execute if score $dungeon do2.utility.onServer matches 0 run setblock -551 119 1977 air - -# If server does not have agronet, remove the fall chamber. -execute if score $dungeon do2.utility.onServer matches 0 run fill -548 111 1980 -548 73 1980 air -execute if score $dungeon do2.utility.onServer matches 0 run fill -547 111 1981 -547 73 1981 air -execute if score $dungeon do2.utility.onServer matches 0 run fill -546 109 1980 -546 73 1980 air -execute if score $dungeon do2.utility.onServer matches 0 run fill -547 111 1979 -547 73 1979 air -execute if score $dungeon do2.utility.onServer matches 0 run fill -547 111 1980 -547 110 1980 air -execute if score $dungeon do2.utility.onServer matches 0 run fill -549 72 1978 -546 70 1982 air - -# If server has agronet, create card selection station. -execute if score $dungeon do2.utility.onServer matches 1 run setblock -551 115 1982 minecraft:warped_wall_sign[facing=north,waterlogged=false]{back_text:{color:"black",has_glowing_text:0b,messages:['{"text":""}','{"text":""}','{"text":""}','{"text":""}']},front_text:{color:"light_gray",has_glowing_text:1b,messages:['{"text":"Card selection"}','{"text":"station. Push"}','{"text":"button to get"}','{"text":"the shulker back."}']},is_waxed:0b} -execute if score $dungeon do2.utility.onServer matches 1 run setblock -551 114 1982 minecraft:warped_button[face=wall,facing=north,powered=false] -execute if score $dungeon do2.utility.onServer matches 1 run setblock -551 112 1982 minecraft:tinted_glass -execute if score $dungeon do2.utility.onServer matches 1 run setblock -551 111 1982 minecraft:redstone_lamp[lit=true] -execute if score $dungeon do2.utility.onServer matches 1 run setblock -551 111 1981 minecraft:redstone_block -execute if score $dungeon do2.utility.onServer matches 1 run setblock -552 112 1982 minecraft:deepslate_tiles -execute if score $dungeon do2.utility.onServer matches 1 run setblock -551 112 1983 minecraft:deepslate_tiles -execute if score $dungeon do2.utility.onServer matches 1 run setblock -551 112 1984 minecraft:deepslate_tiles -execute if score $dungeon do2.utility.onServer matches 1 run setblock -552 113 1983 minecraft:deepslate_tiles -execute if score $dungeon do2.utility.onServer matches 1 run setblock -552 113 1984 minecraft:deepslate_tiles -execute if score $dungeon do2.utility.onServer matches 1 run setblock -551 115 1984 minecraft:deepslate_tiles -execute if score $dungeon do2.utility.onServer matches 1 run setblock -551 114 1984 minecraft:note_block[instrument=harp,note=0,powered=false] -execute if score $dungeon do2.utility.onServer matches 1 run setblock -551 113 1984 minecraft:sticky_piston[extended=false,facing=north] -execute if score $dungeon do2.utility.onServer matches 0 run setblock -551 115 1982 air -execute if score $dungeon do2.utility.onServer matches 0 run setblock -551 114 1982 air -execute if score $dungeon do2.utility.onServer matches 0 run setblock -551 112 1982 minecraft:polished_basalt[axis=x] -execute if score $dungeon do2.utility.onServer matches 0 run setblock -551 111 1982 air -execute if score $dungeon do2.utility.onServer matches 0 run setblock -551 111 1981 air -execute if score $dungeon do2.utility.onServer matches 0 run setblock -552 112 1982 air -execute if score $dungeon do2.utility.onServer matches 0 run setblock -551 112 1983 air -execute if score $dungeon do2.utility.onServer matches 0 run setblock -551 112 1984 air -execute if score $dungeon do2.utility.onServer matches 0 run setblock -552 113 1983 air -execute if score $dungeon do2.utility.onServer matches 0 run setblock -552 113 1984 air -execute if score $dungeon do2.utility.onServer matches 0 run setblock -551 115 1984 air -execute if score $dungeon do2.utility.onServer matches 0 run setblock -551 114 1984 air -execute if score $dungeon do2.utility.onServer matches 0 run setblock -551 113 1984 air - -# If server has agronet, create manual shulker breaker. +execute if score $dungeon do2.utility.onInstance matches 0 run setworldspawn -524 103 2167 +execute if score $dungeon do2.utility.onInstance matches 1 run setworldspawn -547 115 1980 + +# If server has is-dungeon-instance, unlock the iron door. NOTE: If it's on the server, only one use +execute if score $dungeon do2.utility.onInstance matches 1 run setblock -551 119 1977 minecraft:redstone_block +execute if score $dungeon do2.utility.onInstance matches 0 run setblock -551 119 1977 air + +# If server does not have is-dungeon-instance, remove the fall chamber. +execute if score $dungeon do2.utility.onInstance matches 0 run fill -548 111 1980 -548 73 1980 air +execute if score $dungeon do2.utility.onInstance matches 0 run fill -547 111 1981 -547 73 1981 air +execute if score $dungeon do2.utility.onInstance matches 0 run fill -546 109 1980 -546 73 1980 air +execute if score $dungeon do2.utility.onInstance matches 0 run fill -547 111 1979 -547 73 1979 air +execute if score $dungeon do2.utility.onInstance matches 0 run fill -547 111 1980 -547 110 1980 air +execute if score $dungeon do2.utility.onInstance matches 0 run fill -549 72 1978 -546 70 1982 air + +# If server has is-dungeon-instance, create card selection station. +execute if score $dungeon do2.utility.onInstance matches 1 run setblock -551 115 1982 minecraft:warped_wall_sign[facing=north,waterlogged=false]{back_text:{color:"black",has_glowing_text:0b,messages:['{"text":""}','{"text":""}','{"text":""}','{"text":""}']},front_text:{color:"light_gray",has_glowing_text:1b,messages:['{"text":"Card selection"}','{"text":"station. Push"}','{"text":"button to get"}','{"text":"the shulker back."}']},is_waxed:0b} +execute if score $dungeon do2.utility.onInstance matches 1 run setblock -551 114 1982 minecraft:warped_button[face=wall,facing=north,powered=false] +execute if score $dungeon do2.utility.onInstance matches 1 run setblock -551 112 1982 minecraft:tinted_glass +execute if score $dungeon do2.utility.onInstance matches 1 run setblock -551 111 1982 minecraft:redstone_lamp[lit=true] +execute if score $dungeon do2.utility.onInstance matches 1 run setblock -551 111 1981 minecraft:redstone_block +execute if score $dungeon do2.utility.onInstance matches 1 run setblock -552 112 1982 minecraft:deepslate_tiles +execute if score $dungeon do2.utility.onInstance matches 1 run setblock -551 112 1983 minecraft:deepslate_tiles +execute if score $dungeon do2.utility.onInstance matches 1 run setblock -551 112 1984 minecraft:deepslate_tiles +execute if score $dungeon do2.utility.onInstance matches 1 run setblock -552 113 1983 minecraft:deepslate_tiles +execute if score $dungeon do2.utility.onInstance matches 1 run setblock -552 113 1984 minecraft:deepslate_tiles +execute if score $dungeon do2.utility.onInstance matches 1 run setblock -551 115 1984 minecraft:deepslate_tiles +execute if score $dungeon do2.utility.onInstance matches 1 run setblock -551 114 1984 minecraft:note_block[instrument=harp,note=0,powered=false] +execute if score $dungeon do2.utility.onInstance matches 1 run setblock -551 113 1984 minecraft:sticky_piston[extended=false,facing=north] +execute if score $dungeon do2.utility.onInstance matches 0 run setblock -551 115 1982 air +execute if score $dungeon do2.utility.onInstance matches 0 run setblock -551 114 1982 air +execute if score $dungeon do2.utility.onInstance matches 0 run setblock -551 112 1982 minecraft:polished_basalt[axis=x] +execute if score $dungeon do2.utility.onInstance matches 0 run setblock -551 111 1982 air +execute if score $dungeon do2.utility.onInstance matches 0 run setblock -551 111 1981 air +execute if score $dungeon do2.utility.onInstance matches 0 run setblock -552 112 1982 air +execute if score $dungeon do2.utility.onInstance matches 0 run setblock -551 112 1983 air +execute if score $dungeon do2.utility.onInstance matches 0 run setblock -551 112 1984 air +execute if score $dungeon do2.utility.onInstance matches 0 run setblock -552 113 1983 air +execute if score $dungeon do2.utility.onInstance matches 0 run setblock -552 113 1984 air +execute if score $dungeon do2.utility.onInstance matches 0 run setblock -551 115 1984 air +execute if score $dungeon do2.utility.onInstance matches 0 run setblock -551 114 1984 air +execute if score $dungeon do2.utility.onInstance matches 0 run setblock -551 113 1984 air + +# If server has is-dungeon-instance, create manual shulker breaker. execute if score $dungeon do2.utility.onServer matches 1 run setblock -562 116 1982 minecraft:warped_wall_sign[facing=east,waterlogged=false]{back_text:{color:"black",has_glowing_text:0b,messages:['{"text":""}','{"text":""}','{"text":""}','{"text":""}']},front_text:{color:"white",has_glowing_text:1b,messages:['{"text":"<-- Press button"}','{"text":"if in adventure"}','{"text":"mode and can\'t"}','{"text":"break shulker"}']},is_waxed:0b} execute if score $dungeon do2.utility.onServer matches 1 run setblock -562 116 1983 minecraft:warped_button[face=wall,facing=east,powered=false] execute if score $dungeon do2.utility.onServer matches 1 run setblock -564 116 1983 minecraft:redstone_wire[east=side,north=none,power=0,south=none,west=side] diff --git a/Brilliance Datapack/data/do2/functions/events/on_datapack_tick.mcfunction b/Brilliance Datapack/data/do2/functions/events/on_datapack_tick.mcfunction index af695126..f9d07ad6 100644 --- a/Brilliance Datapack/data/do2/functions/events/on_datapack_tick.mcfunction +++ b/Brilliance Datapack/data/do2/functions/events/on_datapack_tick.mcfunction @@ -30,8 +30,8 @@ execute if score $dungeon do2.config.vexTracking matches 1 run function do2:forc execute if score $dungeon do2.config.forceGamemode matches 1 as @a[team=do2.ghosts] at @s if entity @s[gamemode=spectator] unless entity @s[tag=do2.staff] unless entity @s[name=TangoCam] unless entity @s[name=tangocam] run spectate @p[team=do2.players] @s execute if score $dungeon do2.config.forceGamemode matches 1 as @a[team=do2.spectators] at @s if entity @s[gamemode=spectator] unless entity @s[tag=do2.staff] unless entity @s[name=TangoCam] unless entity @s[name=tangocam] run spectate @p[team=do2.players] @s -# If we're on the server, game isn't active. Enforce spectators to stay in lobby. -execute unless entity @e[team=do2.players] if score $dungeon do2.utility.onServer matches 1 as @a[gamemode=spectator,name=!tangocam,name=!TangoCam] at @s run function do2:ensure_spectator_location +# If we're on an instance, game isn't active. Enforce spectators to stay in lobby. +execute unless entity @e[team=do2.players] if score $dungeon do2.utility.onInstance matches 1 as @a[gamemode=spectator,name=!tangocam,name=!TangoCam] at @s run function do2:ensure_spectator_location # Force player's food. execute if score $dungeon do2.config.forceFood matches 1 as @a[scores={do2.utility.shouldForceFood=1}] run function do2:dungeon_setup/control_player_saturation diff --git a/Brilliance Datapack/data/do2/functions/events/on_player_join.mcfunction b/Brilliance Datapack/data/do2/functions/events/on_player_join.mcfunction index edaf03e9..7ff23400 100644 --- a/Brilliance Datapack/data/do2/functions/events/on_player_join.mcfunction +++ b/Brilliance Datapack/data/do2/functions/events/on_player_join.mcfunction @@ -29,7 +29,7 @@ execute positioned -547 113 1980 if entity @s[distance=..5] at @s run tp @s ~ ~ execute positioned -524 103 2167 if entity @s[distance=..10] at @s run tp @s ~ ~ ~ 180 -20 # If game hasn't started. Swap the difficulty, to the user's last used difficulty. -execute if score $dungeon do2.utility.onServer matches 1 unless score $dungeon do2.run.active matches 1.. as @p[tag=do2.received_shulker] run function do2:dungeon_setup/preset_difficulty +execute if score $dungeon do2.utility.onInstance matches 1 unless score $dungeon do2.run.active matches 1.. as @p[tag=do2.received_shulker] run function do2:dungeon_setup/preset_difficulty # Give playsound tag according to player Voice Chat status schedule function do2:voice_chat/set 5t append diff --git a/Brilliance Datapack/data/do2/functions/reset_player.mcfunction b/Brilliance Datapack/data/do2/functions/reset_player.mcfunction index efe019ba..ca81f47b 100644 --- a/Brilliance Datapack/data/do2/functions/reset_player.mcfunction +++ b/Brilliance Datapack/data/do2/functions/reset_player.mcfunction @@ -25,8 +25,8 @@ execute if score $dungeon do2.config.forceGamemode matches 1 unless entity @s[ga execute if score $dungeon do2.config.forceGamemode matches 1 unless entity @s[gamemode=creative] if entity @s[tag=do2.staff] if score @s do2.utility.oldGamemode matches 2 run tellraw @s ["",{"text":"§f[§9B§r]: You have the tag [§bdo2.staff§r], and this has stopped:\n - §5gamemode creative "},{"selector":"@s","color":"dark_purple"},{"text":"\n§f[§9B§r]: Click "},{"text":"§b[here]","clickEvent":{"action":"run_command","value":"/gamemode creative @s"}},{"text":" to run the command anyway."}] execute if score $dungeon do2.config.forceGamemode matches 1 unless entity @s[gamemode=spectator] if entity @s[tag=do2.staff] if score @s do2.utility.oldGamemode matches 3 run tellraw @s ["",{"text":"§f[§9B§r]: You have the tag [§bdo2.staff§r], and this has stopped:\n - §5gamemode spectator "},{"selector":"@s","color":"dark_purple"},{"text":"\n§f[§9B§r]: Click "},{"text":"§b[here]","clickEvent":{"action":"run_command","value":"/gamemode spectator @s"}},{"text":" to run the command anyway."}] -# If player is spectator AND we're on a server. Leave them on spectator mode. -execute if entity @s[team=do2.spectators] if score $dungeon do2.utility.onServer matches 1 unless entity @s[tag=do2.staff] run gamemode spectator @s +# If player is spectator AND we're on an instance. Leave them on spectator mode. +execute if entity @s[team=do2.spectators] if score $dungeon do2.utility.onInstance matches 1 unless entity @s[tag=do2.staff] run gamemode spectator @s # Reset Team & Tags team leave @s diff --git a/Brilliance Datapack/data/do2/functions/scoreboard/setup/utility.mcfunction b/Brilliance Datapack/data/do2/functions/scoreboard/setup/utility.mcfunction index 953484a9..4f67f914 100644 --- a/Brilliance Datapack/data/do2/functions/scoreboard/setup/utility.mcfunction +++ b/Brilliance Datapack/data/do2/functions/scoreboard/setup/utility.mcfunction @@ -32,6 +32,9 @@ scoreboard objectives add do2.utility.receivedJackpot dummy "Used to count the k scoreboard objectives add do2.utility.playersExperience dummy "Used to count how much experience players have." scoreboard objectives add do2.utility.onServer dummy "Checking if this Brilliance is loaded on the server" execute unless score $dungeon do2.utility.onServer matches 0.. run scoreboard players set $dungeon do2.utility.onServer 0 +scoreboard objectives add do2.utility.onInstance dummy "Checking if this Brilliance is loaded on an instance" +execute unless score $dungeon do2.utility.onInstance matches 0.. run scoreboard players set $dungeon do2.utility.onInstance 0 + # - Mob Controller - (mob_controller) scoreboard objectives add do2.utility.mc.mobCountCounterTest dummy "Used to count the how many mobs are in a barrel" diff --git a/Brilliance Datapack/data/do2/functions/version.mcfunction b/Brilliance Datapack/data/do2/functions/version.mcfunction index e16da536..b0d3fc23 100644 --- a/Brilliance Datapack/data/do2/functions/version.mcfunction +++ b/Brilliance Datapack/data/do2/functions/version.mcfunction @@ -1,3 +1,3 @@ -# DATAPACK VERSION NUMBER: 0.13.16 +# DATAPACK VERSION NUMBER: 0.13.17 -tellraw @s ["",{"text":"The §o§n§aBrilliance Datapack§r's version is: [§b0.13.16§r] Check latest version "},{"text":"§o§b§nhere§r","clickEvent":{"action":"open_url","value":"https://github.com/trackedout/Brilliance/blob/main/Brilliance%20Datapack/data/do2/functions/version.mcfunction"}},{"text":"."}] +tellraw @s ["",{"text":"The §o§n§aBrilliance Datapack§r's version is: [§b0.13.17§r] Check latest version "},{"text":"§o§b§nhere§r","clickEvent":{"action":"open_url","value":"https://github.com/trackedout/Brilliance/blob/main/Brilliance%20Datapack/data/do2/functions/version.mcfunction"}},{"text":"."}] diff --git a/JSON/scoreboards.json b/JSON/scoreboards.json index 4d1fe37a..e86542e1 100644 --- a/JSON/scoreboards.json +++ b/JSON/scoreboards.json @@ -971,6 +971,12 @@ "category": "utility", "description": "Whether Brilliance can detect Agronet." }, + "do2.utility.onInstance": { + "auto": 1, + "target": "$dungeon", + "category": "utility", + "description": "Whether Brilliance can detect 'is-dungeon-instance'." + }, "do2.utility.embersToGive": { "auto": 1, "target": "runners", diff --git a/docs/scoreboard.md b/docs/scoreboard.md index f8864243..f56df0f2 100644 --- a/docs/scoreboard.md +++ b/docs/scoreboard.md @@ -576,6 +576,7 @@ The name immediately after the `do2.` will generally be describing it's category | ✅ | 🟢 | do2.utility.old_position.y | utility | Used to store player's old Y location before teleporting them. | | ✅ | 🟢 | do2.utility.old_position.z | utility | Used to store player's old Z location before teleporting them. | | ✅ | 🔴 | do2.utility.onServer | utility | Whether Brilliance can detect Agronet. | +| ✅ | 🔴 | do2.utility.onInstance | utility | Whether Brilliance can detect 'is-dungeon-instance'. | | ✅ | 🔴 | do2.utility.playerCount | utility | Used to count how many players are on the server at a time. | | ✅ | 🔴 | do2.utility.playersExperience | utility | Used to check player's exp in order to give them 1 level if they dont have one. | | ✅ | 🟢 | do2.utility.playersFood | utility | Player's food level |