How can i detect player moves (without head moves)?


#1

Hello
Trying to detect player moves:
@Listener
public void MoveEntityEvent(MoveEntityEvent event) {

}
But when player moves his mouse this events works too
How can i detect moves without head moves?
P.S. Mabe that’s a bad event for this detect?


#2

You use the same event. Just throw out if the players full position does not move.

The code below probably has errors as it is memory typed so use it as a base line

public void onEntityMove(EntityMoveEvent event){
  Location<World> oldLoc = event.getFromTransform().getLocation();
  Location<World> newLoc = event.getTransform().getLocation();
  if((oldLoc.getX() == newLoc.getX()) && (oldLoc .... Etc)){
    //throws out the event
    return;
 }
 //continue here like a normal event

If you really want to stop just rotation. The getTransform class has a getRotation() that you could compare as well as the location


#3

Thank you!
This is exactly what I thought, no special tools for this case


#4

You can actually just compare the locations directly. Location is just the x y and z coordinates. Transform is what incorporates rotation.


#5

Yeah sorry. Been working with bukkit lately so my mind set was still in the bukkit workaround mode