Need help with EnderDragon

Discussion in 'Plugin Development' started by Zolli, Jan 31, 2012.

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

    Zolli

    Hello,

    I'm using EntityTarget event to detect EnderDragon attacks on a Player. This code is working fine when I replace the EnderDragon to Enderman. I Also try'd ComplexEntity and Complex LivingEntity, but is not works.

    This problem is also occur on EntityDamageEvent. Please help me, Thanks. ;)

    PS.: Sorry for My bad English. :(

    The Code:

    PHP:
    public void onEntityTarget(EntityTargetEvent e) {
     
            if(
    e.getEntity() instanceof EnderDragon && e.getTarget() instanceof Player) {
             
                    
    e.setCancelled(true);
         
            }
     
        }
    EntityDamage Event:

    PHP:
    public void onEntityDamage(EntityDamageEvent e) {
     
            if(
    instanceof EntityDamageByEntityEvent) {
         
                
    EntityDamageByEntityEvent event  = (EntityDamageByEntityEvent)e;
         
                if(
    event.getEntity() instanceof LivingEntity && event.getDamager() instanceof Player) {
             
                    
    LivingEntity entity = (LivingEntity)event.getEntity();
             
                    if(
    entity instanceof EnderDragon) {
                     
                            
    event.setCancelled(true);
                     
                    }
             
                }
         
            }
     
        }
     
  2. Offline

    Steeveeo

    You might try changing this line:

    Code:java
    1. LivingEntity entity = (LivingEntity)event.getEntity();

    To this:
    Code:java
    1. Entity entity = event.getEntity();

    That should allow you to do instanceof EnderDragon without error.
     
  3. Offline

    Zolli

    Hy, thanks for answer, but this not working. I made a lot of test's and they show that the problem with bukit.
    The EntityDamageEvent calls on attacking EnderDragon and call EntityDamageByEntityEvent, its fine. Then something is not working.
     
Thread Status:
Not open for further replies.

Share This Page