Detect a critical hit?

Discussion in 'Plugin Development' started by GeorgeeeHD, May 31, 2014.

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

    GeorgeeeHD

    Is it possible to detect if the hit a player did to another entity was a critical hit?
     
  2. yeah,
    Critical hits only happen when the attacker is jumping while attacking. So in your damage event, get whether or not the player is on the ground or in the air with boolean isOnGround(). If it returns false, then the hit was critical.
     
    xTrollxDudex likes this.
  3. Offline

    GeorgeeeHD

    no cos its only when the damager is falling.
     
  4. Offline

    Kobting

    GeorgeeeHD
    Not sure if this will work but check if the player is on the ground and if not get their Y value and then get it again right after and if it is less than the previous Y value and they are still in the air they are falling. (Bit of a run-on sorry lol)
     
  5. GeorgeeeHD
    Then .getVelocity and see if they're falling? 0.o
     
  6. Offline

    Kobting

    Or that
     
  7. Offline

    GeorgeeeHD

    how would you do that?

    //EDIT

    Don't worry I worked it out, here it is if anyone wants it:

    Code:java
    1. public boolean isCritical(Player p) {
    2. return (p.getVelocity().getY() + 0.0784000015258789) <= 0;
    3. }
     
Thread Status:
Not open for further replies.

Share This Page