Last active
March 13, 2019 09:16
-
-
Save S4WA/7ce7630e07162c2b121bb84a9cca59f6 to your computer and use it in GitHub Desktop.
velocity
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@EventHandler | |
private void onVelocity(PlayerVelocityEvent event) { | |
if (event.getPlayer().getLastDamageCause().getCause() != EntityDamageEvent.DamageCause.ENTITY_ATTACK) return; | |
Player damaged = event.getPlayer(); | |
Vector vector = damaged.getVelocity(); | |
vector.normalize(); | |
if (!damaged.isSprinting()) { | |
vector = new Vector(vector.getX() * this.horizontal, 1.0D * this.vertical, vector.getZ() * this.horizontal); | |
} else { | |
vector = new Vector(vector.getX() * this.sprintHorizontal, vector.getY() * this.sprintVertical, vector.getZ() * this.sprintHorizontal); | |
} | |
event.setVelocity(vector); | |
} | |
private double vertical = 0.35D, horizontal = 0.35D, sprintVertical = 0.55D, sprintHorizontal = 0.45D; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment