Move mobs in the direction of view (Minecraft 1.16.5)?

ri
3

I'm currently trying to make a throwable ax (Datapacks). For this I use the scoreboard and the execute command. When you right-click the ax, they spawn an armor stand that rotates like the player (clicker).

I've already made it that far. I'm just looking for a way to move the armor stand in his viewing direction. I've already tried teleport, but then they all fly in the same direction.

gl

However, then they all fly in the same direction.

Who do you mean by "all"?

br

You can move armor stands in the direction of view by entering these ^ instead of the "normal" coordinates for the teleport command and inserting any number for the third. So that would be:

/ tp @e [type = armor_stand, tag = xyz] ^ 1

to teleport the armor rack one block in the direction of view… But really, stop in the direction of view, if he looks even a little down, he will also fly in that direction. So that it does not fall through the floor and then, for example, fall on another level in a building, you must not forget to make it independent of gravity (NBT data: "NoGravity: 1b") …

If you now have several armament racks that are all supposed to do everything independently of each other, you unfortunately have to give them different tags, for example by giving the armor rack that is closest to the exporter a special tag (e.g. Currentthrow), which as soon as the ax stops moving, is removed. You would have the day with:

/ execute as @a [tag = executor] at @s run tag @e [type = armor_stand, limit = 1, sort = nearest, distance = .1] add currentthrow

add (swap currentthrow with the tag you want, swap executor for the player's tag and vary the distance if the armor stand does not spawn directly at the player) and with

/ tag @e [tag = currentthrow] remove currentthrow

remove again.

So, that's it, it's that easy.

Have fun programming

ri

I threw several axes in different directions, but they all flew in + X