-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Throttle the display updates to once every 8 ticks.
- Loading branch information
Showing
3 changed files
with
57 additions
and
43 deletions.
There are no files selected for viewing
46 changes: 46 additions & 0 deletions
46
coords/src/data/io.totemo.coords/functions/coords-display.mcfunction
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
# Get player X, Y, Z and Yaw angle. Store as X, Y, Z, Bearing objectives. | ||
execute as @a store result score @s X run data get entity @s Pos[0] 1.0 | ||
execute as @a store result score @s Y run data get entity @s Pos[1] 1.0 | ||
execute as @a store result score @s Z run data get entity @s Pos[2] 1.0 | ||
execute as @a store result score @s Bearing run data get entity @s Rotation[0] | ||
|
||
# Adjust bearing to compass convention. | ||
scoreboard players operation @a Bearing += 540 const | ||
scoreboard players operation @a Bearing %= 360 const | ||
|
||
# Set Octant to 0..7: | ||
# First set Octant = Bearing, longhand. | ||
execute as @a store result score @s Octant run scoreboard players get @s Bearing | ||
scoreboard players operation @a Octant *= 2 const | ||
scoreboard players operation @a Octant += 45 const | ||
scoreboard players operation @a Octant /= 90 const | ||
scoreboard players operation @a Octant %= 8 const | ||
|
||
# Debugging Bearing and Octant: | ||
#title @a title {"text":""} | ||
#title @a subtitle [{"text":"X ","color":"gray"},{"score":{"name":"*","objective":"X"},"color":"white"},{"text":" Y ","color":"gray"},{"score":{"name":"*","objective":"Y"},"color":"white"},{"text":" Z ","color":"gray"},{"score":{"name":"*","objective":"Z"},"color":"white"},{"text":" B ","color":"gray"},{"score":{"name":"*","objective":"Bearing"},"color":"white"},{"text":" O ","color":"gray"},{"score":{"name":"*","objective":"Octant"},"color":"white"}] | ||
|
||
# N: Octant = 0 | ||
title @a[scores={Octant=0,CoordsHidden=0}] actionbar [{"text":"N ","color":"white"},{"text":"X ","color":"gray"},{"score":{"name":"*","objective":"X"},"color":"white"},{"text":" Y ","color":"gray"},{"score":{"name":"*","objective":"Y"},"color":"white"},{"text":" Z ","color":"gray"},{"score":{"name":"*","objective":"Z"},"color":"white"}] | ||
|
||
# NE: Octant = 1 | ||
title @a[scores={Octant=1,CoordsHidden=0}] actionbar [{"text":"NE ","color":"white"},{"text":"X ","color":"gray"},{"score":{"name":"*","objective":"X"},"color":"white"},{"text":" Y ","color":"gray"},{"score":{"name":"*","objective":"Y"},"color":"white"},{"text":" Z ","color":"gray"},{"score":{"name":"*","objective":"Z"},"color":"white"}] | ||
|
||
# E: Octant = 2 | ||
title @a[scores={Octant=2,CoordsHidden=0}] actionbar [{"text":"E ","color":"white"},{"text":"X ","color":"gray"},{"score":{"name":"*","objective":"X"},"color":"white"},{"text":" Y ","color":"gray"},{"score":{"name":"*","objective":"Y"},"color":"white"},{"text":" Z ","color":"gray"},{"score":{"name":"*","objective":"Z"},"color":"white"}] | ||
|
||
# SE: Octant = 3 | ||
title @a[scores={Octant=3,CoordsHidden=0}] actionbar [{"text":"SE ","color":"white"},{"text":"X ","color":"gray"},{"score":{"name":"*","objective":"X"},"color":"white"},{"text":" Y ","color":"gray"},{"score":{"name":"*","objective":"Y"},"color":"white"},{"text":" Z ","color":"gray"},{"score":{"name":"*","objective":"Z"},"color":"white"}] | ||
|
||
# S: Octant = 4 | ||
title @a[scores={Octant=4,CoordsHidden=0}] actionbar [{"text":"S ","color":"white"},{"text":"X ","color":"gray"},{"score":{"name":"*","objective":"X"},"color":"white"},{"text":" Y ","color":"gray"},{"score":{"name":"*","objective":"Y"},"color":"white"},{"text":" Z ","color":"gray"},{"score":{"name":"*","objective":"Z"},"color":"white"}] | ||
|
||
# SW: Octant = 5 | ||
title @a[scores={Octant=5,CoordsHidden=0}] actionbar [{"text":"SW ","color":"white"},{"text":"X ","color":"gray"},{"score":{"name":"*","objective":"X"},"color":"white"},{"text":" Y ","color":"gray"},{"score":{"name":"*","objective":"Y"},"color":"white"},{"text":" Z ","color":"gray"},{"score":{"name":"*","objective":"Z"},"color":"white"}] | ||
|
||
# W: Octant = 6 | ||
title @a[scores={Octant=6,CoordsHidden=0}] actionbar [{"text":"W ","color":"white"},{"text":"X ","color":"gray"},{"score":{"name":"*","objective":"X"},"color":"white"},{"text":" Y ","color":"gray"},{"score":{"name":"*","objective":"Y"},"color":"white"},{"text":" Z ","color":"gray"},{"score":{"name":"*","objective":"Z"},"color":"white"}] | ||
|
||
# NW: Octant = 7 | ||
title @a[scores={Octant=7,CoordsHidden=0}] actionbar [{"text":"NW ","color":"white"},{"text":"X ","color":"gray"},{"score":{"name":"*","objective":"X"},"color":"white"},{"text":" Y ","color":"gray"},{"score":{"name":"*","objective":"Y"},"color":"white"},{"text":" Z ","color":"gray"},{"score":{"name":"*","objective":"Z"},"color":"white"}] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 7 additions & 42 deletions
49
coords/src/data/io.totemo.coords/functions/coords-tick.mcfunction
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,49 +1,14 @@ | ||
# Initialise CoordsHidden to 0 when unset. | ||
scoreboard players add @a CoordsHidden 0 | ||
|
||
# Get player X, Y, Z and Yaw angle. Store as X, Y, Z, Bearing objectives. | ||
execute as @a store result score @s X run data get entity @s Pos[0] 1.0 | ||
execute as @a store result score @s Y run data get entity @s Pos[1] 1.0 | ||
execute as @a store result score @s Z run data get entity @s Pos[2] 1.0 | ||
execute as @a store result score @s Bearing run data get entity @s Rotation[0] | ||
# If not initialised, itc.Tick = 0. | ||
scoreboard players add @a itc.Tick 0 | ||
|
||
# Adjust bearing to compass convention. | ||
scoreboard players operation @a Bearing += 540 const | ||
scoreboard players operation @a Bearing %= 360 const | ||
# itc.Tick = (itcTick + 1) % 8 | ||
scoreboard players operation @a itc.Tick += 1 const | ||
scoreboard players operation @a itc.Tick %= 8 const | ||
|
||
# Set Octant to 0..7: | ||
# First set Octant = Bearing, longhand. | ||
execute as @a store result score @s Octant run scoreboard players get @s Bearing | ||
scoreboard players operation @a Octant *= 2 const | ||
scoreboard players operation @a Octant += 45 const | ||
scoreboard players operation @a Octant /= 90 const | ||
scoreboard players operation @a Octant %= 8 const | ||
# Update display when itc.Tick is 0. | ||
execute as @a[scores={itc.Tick=0}] run function io.totemo.coords:coords-display | ||
|
||
# Debugging Bearing and Octant: | ||
#title @a title {"text":""} | ||
#title @a subtitle [{"text":"X ","color":"gray"},{"score":{"name":"*","objective":"X"},"color":"white"},{"text":" Y ","color":"gray"},{"score":{"name":"*","objective":"Y"},"color":"white"},{"text":" Z ","color":"gray"},{"score":{"name":"*","objective":"Z"},"color":"white"},{"text":" B ","color":"gray"},{"score":{"name":"*","objective":"Bearing"},"color":"white"},{"text":" O ","color":"gray"},{"score":{"name":"*","objective":"Octant"},"color":"white"}] | ||
|
||
# N: Octant = 0 | ||
title @a[scores={Octant=0,CoordsHidden=0}] actionbar [{"text":"N ","color":"white"},{"text":"X ","color":"gray"},{"score":{"name":"*","objective":"X"},"color":"white"},{"text":" Y ","color":"gray"},{"score":{"name":"*","objective":"Y"},"color":"white"},{"text":" Z ","color":"gray"},{"score":{"name":"*","objective":"Z"},"color":"white"}] | ||
|
||
# NE: Octant = 1 | ||
title @a[scores={Octant=1,CoordsHidden=0}] actionbar [{"text":"NE ","color":"white"},{"text":"X ","color":"gray"},{"score":{"name":"*","objective":"X"},"color":"white"},{"text":" Y ","color":"gray"},{"score":{"name":"*","objective":"Y"},"color":"white"},{"text":" Z ","color":"gray"},{"score":{"name":"*","objective":"Z"},"color":"white"}] | ||
|
||
# E: Octant = 2 | ||
title @a[scores={Octant=2,CoordsHidden=0}] actionbar [{"text":"E ","color":"white"},{"text":"X ","color":"gray"},{"score":{"name":"*","objective":"X"},"color":"white"},{"text":" Y ","color":"gray"},{"score":{"name":"*","objective":"Y"},"color":"white"},{"text":" Z ","color":"gray"},{"score":{"name":"*","objective":"Z"},"color":"white"}] | ||
|
||
# SE: Octant = 3 | ||
title @a[scores={Octant=3,CoordsHidden=0}] actionbar [{"text":"SE ","color":"white"},{"text":"X ","color":"gray"},{"score":{"name":"*","objective":"X"},"color":"white"},{"text":" Y ","color":"gray"},{"score":{"name":"*","objective":"Y"},"color":"white"},{"text":" Z ","color":"gray"},{"score":{"name":"*","objective":"Z"},"color":"white"}] | ||
|
||
# S: Octant = 4 | ||
title @a[scores={Octant=4,CoordsHidden=0}] actionbar [{"text":"S ","color":"white"},{"text":"X ","color":"gray"},{"score":{"name":"*","objective":"X"},"color":"white"},{"text":" Y ","color":"gray"},{"score":{"name":"*","objective":"Y"},"color":"white"},{"text":" Z ","color":"gray"},{"score":{"name":"*","objective":"Z"},"color":"white"}] | ||
|
||
# SW: Octant = 5 | ||
title @a[scores={Octant=5,CoordsHidden=0}] actionbar [{"text":"SW ","color":"white"},{"text":"X ","color":"gray"},{"score":{"name":"*","objective":"X"},"color":"white"},{"text":" Y ","color":"gray"},{"score":{"name":"*","objective":"Y"},"color":"white"},{"text":" Z ","color":"gray"},{"score":{"name":"*","objective":"Z"},"color":"white"}] | ||
|
||
# W: Octant = 6 | ||
title @a[scores={Octant=6,CoordsHidden=0}] actionbar [{"text":"W ","color":"white"},{"text":"X ","color":"gray"},{"score":{"name":"*","objective":"X"},"color":"white"},{"text":" Y ","color":"gray"},{"score":{"name":"*","objective":"Y"},"color":"white"},{"text":" Z ","color":"gray"},{"score":{"name":"*","objective":"Z"},"color":"white"}] | ||
|
||
# NW: Octant = 7 | ||
title @a[scores={Octant=7,CoordsHidden=0}] actionbar [{"text":"NW ","color":"white"},{"text":"X ","color":"gray"},{"score":{"name":"*","objective":"X"},"color":"white"},{"text":" Y ","color":"gray"},{"score":{"name":"*","objective":"Y"},"color":"white"},{"text":" Z ","color":"gray"},{"score":{"name":"*","objective":"Z"},"color":"white"}] | ||
|