Minecraft Java Edition – Positioning Particles to Face Player’s Coordinates Correctly

minecraft-commandsminecraft-java-edition

I used a command that makes particles that face a certain player, but I am not sure how to make it on one y coordinate. This is the command I was using: execute as @a[nbt={SelectedItem:{id:"minecraft:music_disc_11"}}] at @s if entity @a[distance=0.1..] facing entity player1 eyes positioned ~ ~1 ~ positioned ^ ^ ^3 run particle minecraft:dust 1.0 1.0 1.0 1.0 ~ ~ ~ 0 0 0 0 1. I am trying to figure out how to make it face the x and z of one player, player1 (I didn't want to post a real username), but then take the y of the player the particles are close to, so it doesnt point downward if the player is below me. Is there a way to do that or is that not possible?

Best Answer

I don't think it's possible directly, but you can use a dummy entity, like an invisible marker armour stand. Summon it at one player and then use a command like this one:

/execute as [dummy_entity] run data modify entity @s Pos[1] set from entity [other_player] Pos[1]

The copies the y coordinate from the NBT of the player to the NBT of the entity, therefore teleporting it to that player's height. You can then use the coordinates of that entity for your other commands and afterwards kill the dummy entity again.