Hello Spigot. I'm trying to track a players location from before they move, PlayerMoveEvent has getFrom() and getTo() but is there any way I can access these from EntityDamageByEntityEvent? Or is there a way to check if a player has been attacked in a PlayerMoveEvent? ~ Thank You
You would need to write their location to a variable outside of the player move event where the entitydamage event can access it. It could be a hashMap of <Player><Location> lastMove Then when the damage event fires if the entity is InstanceOf player. location last = lastMove.getPlayer(); If last != null Compare their last position to their current position Note you will probably want to use a distance check when updating the location in player move, because player move fires OFTEN. Just wiggling your mouse will fire it a lot. So be cautious what you do in onPlayerMove. Finally you always need to check that the world in the saved list is == the players current world before measuring distance, if you fail to do this and a player teleports to a different world you'll get an error because you can not measure distance between worlds. Sent from my iPhone using Tapatalk
You could check if the Player's velocity isn't 0. It's better than storing it in a hashmap 20 times per second
Well, when a player is hit they are automatically moved back due to knock back. When they are hit, add that player to an array list. Inside the PlayerMoveEvent, check if they are contained in the array list. The list will store their previous location If they are in the list, do what you want and then remove them. If they are not in the list, don't do anything.
Hmm. So you are trying to get the location where they got hit, and the location they were hit to (knockbacked)?
Anti knockback hacks bypass velocity statements in the code, i would do it with protocollib but I'm not familiar with the API