Could not pass event EntityDamageEvent

Discussion in 'Plugin Development' started by Sparmerlin, Jan 15, 2013.

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

    Sparmerlin

  2. Offline

    EnvisionRed

    Go to the main plugin development forum page, and read the sticky thread about learning to read stack traces. Then come back here.
     
  3. Offline

    chasechocolate

    Lol you can't cast CraftSkeleton to Player...
     
    Sparmerlin likes this.
  4. Offline

    Sparmerlin

    Yea, my friend coded this bit. It used to work a few builds ago though. What is the new player damage event called?
     
  5. Offline

    chasechocolate

    EntityDamageEvent or EntityDamageByEntityEvent then use if(event.getEntity() instanceof Player)
     
    Sparmerlin likes this.
  6. Offline

    Sparmerlin

    What would i use for fall damage? (Sorry if this is a stupid question)

    Here his code.
    Code:
            @EventHandler
            public void onEntityDamaged(EntityDamageEvent event) {
                    Player p = (Player)event.getEntity();                             
                    Block block2 = p.getLocation().getBlock().getRelative(BlockFace.DOWN);
                   
                      //if (!(event.getEntity() instanceof Player)){
                              //return;
                      //}
                   
                    if(event.getCause().equals(EntityDamageEvent.DamageCause.FALL) && p instanceof Player){
                            if(block2.getTypeId() == blocktype){
                              //if(p.getWorld() == Bukkit.getWorld("world")){
                                    event.setCancelled(true);
                            }else if(block2.getTypeId() == 41){
                                    event.setCancelled(true);
                            }else{
                                    event.setCancelled(false);
                            }
                    }
            }
    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 30, 2016
  7. Offline

    Sebc722

    I imagine it would be the EntityDamageEvent as chasechocolate said above.
     
  8. Offline

    chasechocolate

    Cast player to event.getEntity() after checking if the entity is a player.
     
Thread Status:
Not open for further replies.

Share This Page