Programming Minecraft: Moving Minecart in the direction of view?

cy
- in Plugins
2

I'd like to make a vehicle plugin where the Minecart moves in the direction the player looks, just how do I get the direction the player is looking? It would be great if someone could complete the code, thank you in advance!

@EventHandler
public void on (VehicleEnterEvents) {
if (e.getVehicle (). GetType (). Equals (EntityType.MINECART)) {
Minecart mc = (Minecart) e.getVehicle ();
Player p = (player) e.getVehicle (). GetPassenger ();
Bukkit.getScheduler (). RunTaskTimer (Main.plugin, () → {
mc.setVelocity (new Vector (// This is where the Minecart should move));
}, 5, 5);
}

Br

You get the direction of the player with player.getEyeLocation ();

In any case, I suspect, because there's nothing else with Eye so far. Try it and build it into your Vector.

cy

I've already tried everything with getEyeLocation (), could you please put it into my method the way you think?