Completely Remove Fall Damage From the Player

Discussion in 'Plugin Development' started by blobjim, Feb 27, 2013.

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

    blobjim

    I am making a little plugin just for fun (my first one) and I have not found a simple way to remove fall damage from the player for a duration. I have a command that gives a jump boost and I don't want the player to do the bone breaking thing that slows you down when you fall from a high distance.

    Code:
        else if(cmd.getName().equalsIgnoreCase("predator")) {//beginning of the /predator command
               
            Player player = (Player) sender;
            sender.sendMessage(ChatColor.RED + "You are the predator!");
            Location playerlocation = player.getLocation();
            for (PotionEffect effect : player.getActivePotionEffects())
                    player.removePotionEffect(effect.getType());
            player.playSound(playerlocation, Sound.BLAZE_DEATH, 100, 0);
                player.addPotionEffect(new PotionEffect(PotionEffectType.JUMP,600 ,3));   
                player.addPotionEffect(new PotionEffect(PotionEffectType.SPEED,600 ,3));   
                player.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY,600 ,3));   
                player.addPotionEffect(new PotionEffect(PotionEffectType.NIGHT_VISION,600 ,5));    
     
  2. Offline

    iWareWolf

    blobjim
    You could add them to a list by a command or somehow. Then when EntityDamageEvent fires, check if the damage is caused by fall, and if they are on the list, cancel.
     
  3. Offline

    kreashenz

    Couldn't you set their fallDistance to 0 for each time?
    like : player.setFallDistance(0);
     
  4. Offline

    blobjim

    I'm very... very... very inexperienced with Java let alone any programming language so I am very confused about the EntityDamageEvent. It would be nice if someone could walk me through how events and entities work in general in Bukkit that would be nice. I know its a lot to ask but I could use a kick start.
     
  5. Offline

    chasechocolate

    Look at the plugin tutorial, it explains on how to use listeners. But listen for EntityDamageEvent, check if the event.getEntity() instanceof Player, check if the event.getCause() == EntityDamageEvent.DamageCause.FALL, and event.setCancelled(true).
     
    MasterDuque likes this.
  6. Offline

    blobjim

    Thanks everyone for your help, I'll definitely look into this and report back if i'm successful. Thanks!
     
  7. Offline

    ZeusAllMighty11

    This is called automatically whenever an Entity is Damaged, but it won't be called ever because you need an @EventHandler annotation above the method, and to register the evet
     
  8. Offline

    blobjim

    How do I call the method. It requires an EntityDamage in the parenthases. What do I put there?
     
Thread Status:
Not open for further replies.

Share This Page