No Fall damage?

Discussion in 'Plugin Development' started by ServerfromMinecraft, Jul 9, 2012.

Thread Status:
Not open for further replies.
  1. Hi all,

    how can you turn off the fall damage?i have made a plugin that allow to fly - but when landing, the player get fall damage..
     
  2. cancel the entitydamage event when there is an player that has recently flyed and when the cause is FALL
     
  3. Use the EntityDamageEvent, check if the entity is a player and if the damage cause is fall damage. If both applies cancel the event.
    Or just use player.allowFlight(true/false); - Minecraft doesn't damage the player if he lands cause of allowFlight(false) IIRC.
     
  4. yes, but the thing is that the diasbling off falldamage must in a onplayermove event...
     
  5. No, it must be in the EntityDamageEvent. You can combine it with the PlayerMoveEvent (may be more or less complicated, depending on your current codes) but you can't detect damage in a move event, that would be like trying to hear with the eyes and see with the ears...
     
  6. ah ok, I'll try it :)

    so now I have a disable-fall-damage-event but how do I connect with the onplayermoveevent now?

    i have make so:
    first a boolean:
    public boolean cancel = false;

    in my moveevent i have set the boolean on true, an in the damageevet:
    e.setCancelled(cancel)

    its right?

    yes it works :D
    thanks all :D

    EDIT:// now ALL falldamages are disabled :(

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 26, 2016
  7. Not 100%
    1. Your code may uncancel events cancelled by other plugins.
    2. Your code does not differentiate between the players (one boolean for all players).
    So use a HashSet intead of the boolean and only cancel the event but never uncancel it:
    HashSet<String> nodamage = new HashSet<String>();

    in the move event:
    nodamage.add(player.getName());

    and in the damage event:
    Code:text
    1. if(nodamage.contains(player.getName()))
    2. {
    3. nodamage.remove(player.getName());
    4. event.setCancelled(true);
    5. }

    But I just realize that a player will be hold in the set till he falls from a high point, giving the ability to cheat (do some action to get in the list but don't take fall damage, then go to some place where you're not allowed to fly and jump into the secret room at bedrock layer that would normally kill you but you don't get the falldamage this time).
     
Thread Status:
Not open for further replies.

Share This Page