Want a better Minecraft server? Read about SpigotMC here!
Separate names with a comma.
Discussion in 'Spigot Plugin Development' started by Mr.Midnight, May 14, 2016.
How can I set the yaw and pitch of an EntityPlayer?
Teleport doesn't do anything to custom EntityPlayers.
Ah, I misread. I printed out all the methods associated with EntityPlayer, and this one (from a superclass) looks promising:
I will try it in a bit ^-^. But off to the next problem, I am giving the EntityPlayer velocity using EntityPlayer#move(x, y, z); , But I want the yaw and pitch to match the moving player whilst moving.
Try using just location.
Location l = p.getLocation();
Yaw/pitch information can be derived from a Vector. It would be wrong to claim that a Vector is the the same as yaw/pitch, since vectors have magnitude as well as direction, but changing the direction a player is facing disregards this magnitude and only considers the direction.
I think all you need to do is find the direction a player is moving (Entity#getVelocity(), and probably something similar for EntityPlayer) and assign that direction to the player's Location (as a Vector!) using the teleport command I described above.
Problem is, the move() only takes x, y, z
Did you fix this already? If not, you can set the pitch/yaw of an EntityPlayer using the following:
entityPlayer.pitch = pitch;
entityPlayer.lastPitch = pitch;
entityPlayer.yaw = yaw;
entityPlayer.lastYaw = yaw;
entityPlayer.aQ = yaw;
entityPlayer.aR = yaw;
entityPlayer.aO = yaw;
entityPlayer.aP = yaw;
I haven't been messing with NPC's recently, but this could be useful for future reference, thank you <3 :3