Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new /trigger ping #145

Merged
merged 7 commits into from
Aug 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
function nincodedo:uniqueitems/load
function nincodedo:items/load
function nincodedo:rewards/load
function nincodedo:triggers/ping/load

scoreboard objectives add advrewards dummy
scoreboard objectives add bannerplz trigger
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ tellraw @s[scores={clearday1tools=1}] {"text":"Aww, your Day 1 tool vanished..."
tellraw @s[scores={clearday1tools=2..}] [{"text":"Aww, your "},{"score":{"name":"@s","objective":"clearday1tools"}},{"text":" Day 1 tools vanished..."}]

advancement revoke @s only nincodedo:rewards/removeday1tools
scoreboard players reset @s day1tooltime
6 changes: 6 additions & 0 deletions datapacks/ocw-stuff/data/nincodedo/functions/tick.mcfunction
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
execute as @a[scores={bannerplz=1}] at @s run function nincodedo:triggers/givebannerforlocation
execute as @a[scores={nopotionsplz=1}] run function nincodedo:triggers/nopotionsplz
execute as @a[scores={day1tooltime=1}] run function nincodedo:triggers/day1tooltimecheck
execute as @a[scores={ping=1}] at @s run function nincodedo:triggers/ping/start_ping
execute as @a[scores={ping_config=0}] run function nincodedo:triggers/ping/show_config
execute as @a[scores={ping_config=1..16}] run function nincodedo:triggers/ping/set_config
execute as @a[tag=!triggerbannerenabled] run function nincodedo:util/setup_new_player
execute as @a[tag=!ping_config_set] run scoreboard players enable @s ping_config
execute as @a[tag=!ping_config_set] run scoreboard players set @s ping_config -1
execute as @a[tag=!ping_config_set] run tag @s add ping_config_set
execute if score potionhorn rhcdata matches 1 as @a[tag=!triggernopotionenabled] run scoreboard players enable @s nopotionsplz
execute if score potionhorn rhcdata matches 1 as @a[tag=!triggernopotionenabled] run tag @s add triggernopotionenabled
scoreboard players enable @a[advancements={nincodedo:unique_items/ascend/main=true},tag=!triggerascendemr] ascend_emergency_fix
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
execute if score @s ping_color matches 1..16 run data modify entity @e[tag=block_ping,sort=nearest,limit=1] Glowing set value true

execute if score @s ping_color matches 1 run data modify entity @e[tag=block_ping,sort=nearest,limit=1] block_state.Name set value "minecraft:white_stained_glass"
execute if score @s ping_color matches 2 run data modify entity @e[tag=block_ping,sort=nearest,limit=1] block_state.Name set value "minecraft:light_gray_stained_glass"
execute if score @s ping_color matches 3 run data modify entity @e[tag=block_ping,sort=nearest,limit=1] block_state.Name set value "minecraft:gray_stained_glass"
execute if score @s ping_color matches 4 run data modify entity @e[tag=block_ping,sort=nearest,limit=1] block_state.Name set value "minecraft:black_stained_glass"
execute if score @s ping_color matches 5 run data modify entity @e[tag=block_ping,sort=nearest,limit=1] block_state.Name set value "minecraft:brown_stained_glass"
execute if score @s ping_color matches 6 run data modify entity @e[tag=block_ping,sort=nearest,limit=1] block_state.Name set value "minecraft:red_stained_glass"
execute if score @s ping_color matches 7 run data modify entity @e[tag=block_ping,sort=nearest,limit=1] block_state.Name set value "minecraft:orange_stained_glass"
execute if score @s ping_color matches 8 run data modify entity @e[tag=block_ping,sort=nearest,limit=1] block_state.Name set value "minecraft:yellow_stained_glass"
execute if score @s ping_color matches 9 run data modify entity @e[tag=block_ping,sort=nearest,limit=1] block_state.Name set value "minecraft:lime_stained_glass"
execute if score @s ping_color matches 10 run data modify entity @e[tag=block_ping,sort=nearest,limit=1] block_state.Name set value "minecraft:green_stained_glass"
execute if score @s ping_color matches 11 run data modify entity @e[tag=block_ping,sort=nearest,limit=1] block_state.Name set value "minecraft:cyan_stained_glass"
execute if score @s ping_color matches 12 run data modify entity @e[tag=block_ping,sort=nearest,limit=1] block_state.Name set value "minecraft:light_blue_stained_glass"
execute if score @s ping_color matches 13 run data modify entity @e[tag=block_ping,sort=nearest,limit=1] block_state.Name set value "minecraft:blue_stained_glass"
execute if score @s ping_color matches 14 run data modify entity @e[tag=block_ping,sort=nearest,limit=1] block_state.Name set value "minecraft:purple_stained_glass"
execute if score @s ping_color matches 15 run data modify entity @e[tag=block_ping,sort=nearest,limit=1] block_state.Name set value "minecraft:magenta_stained_glass"
execute if score @s ping_color matches 16 run data modify entity @e[tag=block_ping,sort=nearest,limit=1] block_state.Name set value "minecraft:pink_stained_glass"

execute if score @s ping_color matches 1 run data modify entity @e[tag=block_ping,sort=nearest,limit=1] glow_color_override set value 16777215
execute if score @s ping_color matches 2 run data modify entity @e[tag=block_ping,sort=nearest,limit=1] glow_color_override set value 13882323
execute if score @s ping_color matches 3 run data modify entity @e[tag=block_ping,sort=nearest,limit=1] glow_color_override set value 8421504
execute if score @s ping_color matches 4 run data modify entity @e[tag=block_ping,sort=nearest,limit=1] glow_color_override set value 1315860
execute if score @s ping_color matches 5 run data modify entity @e[tag=block_ping,sort=nearest,limit=1] glow_color_override set value 9127187
execute if score @s ping_color matches 6 run data modify entity @e[tag=block_ping,sort=nearest,limit=1] glow_color_override set value 16711680
execute if score @s ping_color matches 7 run data modify entity @e[tag=block_ping,sort=nearest,limit=1] glow_color_override set value 16753920
execute if score @s ping_color matches 8 run data modify entity @e[tag=block_ping,sort=nearest,limit=1] glow_color_override set value 16776960
execute if score @s ping_color matches 9 run data modify entity @e[tag=block_ping,sort=nearest,limit=1] glow_color_override set value 12582656
execute if score @s ping_color matches 10 run data modify entity @e[tag=block_ping,sort=nearest,limit=1] glow_color_override set value 65280
execute if score @s ping_color matches 11 run data modify entity @e[tag=block_ping,sort=nearest,limit=1] glow_color_override set value 65535
execute if score @s ping_color matches 12 run data modify entity @e[tag=block_ping,sort=nearest,limit=1] glow_color_override set value 11393254
execute if score @s ping_color matches 13 run data modify entity @e[tag=block_ping,sort=nearest,limit=1] glow_color_override set value 255
execute if score @s ping_color matches 14 run data modify entity @e[tag=block_ping,sort=nearest,limit=1] glow_color_override set value 8388736
execute if score @s ping_color matches 15 run data modify entity @e[tag=block_ping,sort=nearest,limit=1] glow_color_override set value 16711935
execute if score @s ping_color matches 16 run data modify entity @e[tag=block_ping,sort=nearest,limit=1] glow_color_override set value 16761035
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
scoreboard players remove @e[tag=ping] ping_lifetime 1
kill @e[tag=block_ping,scores={ping_lifetime=..0}]

execute if entity @e[tag=ping] run schedule function nincodedo:triggers/ping/lifetime_watch 1t
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
scoreboard objectives add ping_lifetime dummy
scoreboard objectives add ping_color dummy
scoreboard objectives add raycast_steps dummy
scoreboard objectives add ping trigger
scoreboard objectives add ping_config trigger

scoreboard players set config_ping_ping_lifetime rhcconfig 140
scoreboard players set max_raycast_steps rhcconfig 120

data modify storage nincodedo:storage colors append value "White"
data modify storage nincodedo:storage colors append value "Light Gray"
data modify storage nincodedo:storage colors append value "Gray"
data modify storage nincodedo:storage colors append value "Black"
data modify storage nincodedo:storage colors append value "Brown"
data modify storage nincodedo:storage colors append value "Red"
data modify storage nincodedo:storage colors append value "Orange"
data modify storage nincodedo:storage colors append value "Yellow"
data modify storage nincodedo:storage colors append value "Lime"
data modify storage nincodedo:storage colors append value "Green"
data modify storage nincodedo:storage colors append value "Cyan"
data modify storage nincodedo:storage colors append value "Light Blue"
data modify storage nincodedo:storage colors append value "Blue"
data modify storage nincodedo:storage colors append value "Purple"
data modify storage nincodedo:storage colors append value "Magenta"
data modify storage nincodedo:storage colors append value "Pink"
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
execute if score @s raycast_steps > max_raycast_steps rhcconfig run tag @s remove raycasting
execute if entity @s[tag=!raycasting] run return 0
execute if entity @s[tag=raycasting] if block ~ ~ ~ minecraft:air unless entity @e[distance=..1.5,type=!minecraft:marker,type=!minecraft:interaction,tag=!raycasting] positioned ^ ^ ^0.5 run function nincodedo:triggers/ping/raycast
execute if entity @s[tag=raycasting] unless block ~ ~ ~ minecraft:air run function nincodedo:triggers/ping/this_block
execute if entity @s[tag=raycasting] if entity @e[distance=..1.5,type=!minecraft:marker,type=!minecraft:interaction,tag=!raycasting] run function nincodedo:triggers/ping/this_entity
scoreboard players add @s raycast_steps 1
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
execute if score @s ping_config matches 1..16 store result score @s ping_color run scoreboard players get @s ping_config

scoreboard players enable @s ping_config
scoreboard players set @s ping_config -1
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
execute if score @s ping_color matches 1 run data modify storage nincodedo:storage current_color set from storage nincodedo:storage colors[0]
execute if score @s ping_color matches 2 run data modify storage nincodedo:storage current_color set from storage nincodedo:storage colors[1]
execute if score @s ping_color matches 3 run data modify storage nincodedo:storage current_color set from storage nincodedo:storage colors[2]
execute if score @s ping_color matches 4 run data modify storage nincodedo:storage current_color set from storage nincodedo:storage colors[3]
execute if score @s ping_color matches 5 run data modify storage nincodedo:storage current_color set from storage nincodedo:storage colors[4]
execute if score @s ping_color matches 6 run data modify storage nincodedo:storage current_color set from storage nincodedo:storage colors[5]
execute if score @s ping_color matches 7 run data modify storage nincodedo:storage current_color set from storage nincodedo:storage colors[6]
execute if score @s ping_color matches 8 run data modify storage nincodedo:storage current_color set from storage nincodedo:storage colors[7]
execute if score @s ping_color matches 9 run data modify storage nincodedo:storage current_color set from storage nincodedo:storage colors[8]
execute if score @s ping_color matches 10 run data modify storage nincodedo:storage current_color set from storage nincodedo:storage colors[9]
execute if score @s ping_color matches 11 run data modify storage nincodedo:storage current_color set from storage nincodedo:storage colors[10]
execute if score @s ping_color matches 12 run data modify storage nincodedo:storage current_color set from storage nincodedo:storage colors[11]
execute if score @s ping_color matches 13 run data modify storage nincodedo:storage current_color set from storage nincodedo:storage colors[12]
execute if score @s ping_color matches 14 run data modify storage nincodedo:storage current_color set from storage nincodedo:storage colors[13]
execute if score @s ping_color matches 15 run data modify storage nincodedo:storage current_color set from storage nincodedo:storage colors[14]
execute if score @s ping_color matches 16 run data modify storage nincodedo:storage current_color set from storage nincodedo:storage colors[15]

tellraw @s [{"text":"---Ping Color Config---\n"},{"text":"Click on a color to set your ping block's color.\n"},{"text":"Current ping color: "},{"nbt":"current_color","storage":"nincodedo:storage"},{"text":"\n"},{"text":"White","color":"white","clickEvent":{"action":"run_command","value":"/trigger ping_config set 1"}},{"text":" - "},{"text":"Light Gray","color":"#d3d3d3","clickEvent":{"action":"run_command","value":"/trigger ping_config set 2"}},{"text":" - "},{"text":"Gray","color":"#808080","clickEvent":{"action":"run_command","value":"/trigger ping_config set 3"}},{"text":" - "},{"text":"Black\n","color":"#161616","clickEvent":{"action":"run_command","value":"/trigger ping_config set 4"}},{"text":"Brown","color":"#a52a2a","clickEvent":{"action":"run_command","value":"/trigger ping_config set 5"}},{"text":" - "},{"text":"Red","color":"red","clickEvent":{"action":"run_command","value":"/trigger ping_config set 6"}},{"text":" - "},{"text":"Orange","color":"#ffa500","clickEvent":{"action":"run_command","value":"/trigger ping_config set 7"}},{"text":" - "},{"text":"Yellow\n","color":"yellow","clickEvent":{"action":"run_command","value":"/trigger ping_config set 8"}},{"text":"Lime","color":"green","clickEvent":{"action":"run_command","value":"/trigger ping_config set 9"}},{"text":" - "},{"text":"Green","color":"dark_green","clickEvent":{"action":"run_command","value":"/trigger ping_config set 10"}},{"text":" - "},{"text":"Cyan","color":"#1E817F","clickEvent":{"action":"run_command","value":"/trigger ping_config set 11"}},{"text":" - "},{"text":"Light Blue\n","color":"aqua","clickEvent":{"action":"run_command","value":"/trigger ping_config set 12"}},{"text":"Blue","color":"blue","clickEvent":{"action":"run_command","value":"/trigger ping_config set 13"}},{"text":" - "},{"text":"Purple","color":"dark_purple","clickEvent":{"action":"run_command","value":"/trigger ping_config set 14"}},{"text":" - "},{"text":"Magenta","color":"light_purple","clickEvent":{"action":"run_command","value":"/trigger ping_config set 15"}},{"text":" - "},{"text":"Pink","color":"#ffcccc"}]

scoreboard players enable @s ping_config
scoreboard players set @s ping_config -1
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
scoreboard players reset @s ping
scoreboard players enable @s ping
scoreboard players reset @s raycast_steps
tag @s add raycasting
execute anchored eyes positioned ^ ^ ^1 run function nincodedo:triggers/ping/raycast
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
tag @s remove raycasting
execute align xyz run summon minecraft:block_display ~ ~ ~ {Glowing:true,block_state:{Name:"minecraft:light_gray_stained_glass"},Tags:["block_ping","ping"]}
function nincodedo:triggers/ping/color_ping_block
data modify entity @e[tag=ping,sort=nearest,limit=1] transformation.scale set value [0.98f,0.98f,0.98f]
execute as @e[tag=ping,sort=nearest,limit=1] at @s run tp ~0.01 ~0.01 ~0.01
playsound minecraft:entity.player.levelup player @a ~ ~ ~ 1 2
execute as @e[tag=ping,sort=nearest,limit=1] store result score @s ping_lifetime run scoreboard players get config_ping_ping_lifetime rhcconfig
schedule function nincodedo:triggers/ping/lifetime_watch 1t
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
effect give @e[distance=..1.5,type=!minecraft:marker,type=!minecraft:interaction,tag=!raycasting] glowing 10 0 true
playsound minecraft:entity.player.levelup player @a ~ ~ ~ 1 2

tag @s remove raycasting
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
scoreboard players enable @s bannerplz
scoreboard players enable @s ping
execute unless score @s ping_color matches 1..16 run scoreboard players set @s ping_color 2
loot give @s loot nincodedo:docs/faq_book
execute store result score @s day1toolticks run scoreboard players get day1tooltickinit rhcconfig

Expand Down
1 change: 1 addition & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ There are a few non-vanilla Java Minecraft features implemented through datapack

- [Minecraft Bedrock's bone meal](https://github.com/Nincodedo/mc-java-bedrock-bone-meal-datapack)
- [Custom composter items](customcomposter/index.md)
- [Trigger Commands](trigger/index.md)

### OCW Features

Expand Down
17 changes: 17 additions & 0 deletions docs/trigger/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Trigger Commands

## bannerplz

Using `/trigger bannerplz` when at certain structure locations will give the player a banner. The banner is intended to be placed at the structure and used for maps. This trigger has a 2 minute cooldown.

## day1tooltime

Using `/trigger day1tooltime` will show you how much time you have left on your Day 1 tools. This trigger is only available if you have remaining Day 1 tool time.

## ping

Using `/trigger ping` will highlight the block or entity you're looking at to notify other players.

### ping_config

As part of `/trigger ping`, you can also use `/trigger ping_config` to change your ping's block color.