Full video: [ Ссылка ]
Line of sight detection without raycasting. No datapacks required this time.
Inspired by
[ Ссылка ]
World download
[ Ссылка ]
All my links:
[ Ссылка ]
Commands
# create scoreboard objectives, call it "lineOfSight.x" and "lineOfSight.y"
# we will use these to store and calculate entity rotations
/scoreboard objectives add lineOfSight.x dummy
/scoreboard objectives add lineOfSight.y dummy
# summon armour stand, call it "lineOfSight.sensor"
/summon minecraft:armor_stand ~ ~1.9 ~ {Tags:["lineOfSight.sensor"], Marker: 1b, Invisible: 1b}
# LOOP: make sensor face away from the player
/execute as @e[tag=lineOfSight.sensor] at @s facing entity @p eyes run tp @s ~ ~ ~ ~180 ~
# LOOP: store player and sensor rotation in scoreboards
/execute as @e[tag=lineOfSight.sensor] store result score @s lineOfSight.x run data get entity @s Rotation[0]
/execute as @e[tag=lineOfSight.sensor] store result score @s lineOfSight.y run data get entity @s Rotation[1]
/execute as @p store result score @s lineOfSight.x run data get entity @s Rotation[0]
/execute as @p store result score @s lineOfSight.y run data get entity @s Rotation[1]
# LOOP: add/subtract player rotation from sensor rotation to find the relative rotation
/scoreboard players operation @e[tag=lineOfSight.sensor] lineOfSight.x -= @p lineOfSight.x
/scoreboard players operation @e[tag=lineOfSight.sensor] lineOfSight.y += @p lineOfSight.y
# LOOP: if the sensor's relative rotation is 0, then the player is looking at it.
# you might want to leave some margin so the rotations don't have to match exactly.
/execute as @e[tag=lineOfSight.sensor] if score @s lineOfSight.x matches -1..1 if score @s lineOfSight.y matches -1..1 run tellraw @a "Hello World!"
Music
C418 - Blind Spots (Minecraft Volume Beta)
[ Ссылка ]
Build inspirations
"Minecraft: 30+ Laboratory Build Hacks!" by BBlocks
[ Ссылка ]
"Abandoned Lab" by StayCooling
[ Ссылка ]
#minecraft #commandblock
![](https://i.ytimg.com/vi/Fuy59vTB2p0/maxresdefault.jpg)