Detect entity movement?

Discussion in 'Plugin Development' started by Mr. Sandwich, Jun 3, 2016.

Thread Status:
Not open for further replies.
  1. Offline

    Mr. Sandwich

    Hey is there a way to detect when an entity is walking?

    EDIT: And if its sprinting
     
    Last edited: Jun 3, 2016
  2. There isn't a bukkit event to detect entity movement.

    To detect it, you should use a plugin like BKCommonLib, or you should make a repeating schedule to check for entities that are moving.

    You should know that there' s a chance of a serious lag.
    :)
     
    Last edited: Jun 3, 2016
  3. Offline

    Mr. Sandwich

    Okay so I used hashmaps to do this: the server saves the entities' location for 1.5 sec and then removes it(then repeats the same thing) but how can check if the location changed?
     
  4. Well when you add the location and you have saved it, next time, before deletion, get the current location of entity. Then if x, y, or z are not the same as before, that means that the entity moved.

    Does this help?
     
  5. Offline

    Xerox262

    @Mr. Sandwich What are you trying to do, stop an entity from moving? Why do you need to know if an entity is moving there might be another way to do what you're trying to do.
     
  6. Offline

    Mr. Sandwich

    Yeah but how do I check if the x y z changed?
    and Xerox I need to play particles when a specific mob moves
     
  7. Offline

    Xerox262

    @Mr. Sandwich !Location#equals(Location) means movement, or at least yaw/pitch change.
     
  8. Offline

    Minibros

    You can use PlayerMoveEvent, check with if (event.getPlayer() instanceof Entity) {with your code here}
    I think this will do it.
     
  9. Offline

    Xerox262

    @Minibros No you cannot, the PlayerMoveEvent only gets called when a player moves, and the If checking if it's an entity would always return true since a player is an entity
     
Thread Status:
Not open for further replies.

Share This Page