Solved EntityDamageByEntityEvent Help.

Discussion in 'Plugin Development' started by FuZioN720, May 20, 2013.

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

    FuZioN720

    Hello, I'm trying to get it so if the The entity that is damaged is a player and the damager is a baby zombie, then set the damage done to 0, can someone help me.

    Here is the event
    Code:
    public void EntityDamageByEntityEvent (final Entity damager, final Entity damagee, final DamageCause cause, final int damage)
    I find out what the code is for player that is damge, a baby zmobie, and seting the damge(I think is setDamage())
     
  2. Offline

    teunie75

    Code:
    if(damager instanceof Entity.BABY_ZOMBIE){ //Think that Entity.BABY_ZOMBIE is right, checking if the damager is a baby zombie
    if(damagee instanceof Player){ //Check if the damager entity is a player
    event.setDamage(0); //Set the damage to 0
     
    
     
    Skyshayde and FuZioN720 like this.
  3. Offline

    FuZioN720

    teunie75 OK this is what i have now i changed the Event alittle but BABY_ZOMBIE is giving an error and even when i change it to ZOMBIE is still gives me an error, in eclipse it says Fix porjectsetup for the solution. Here is my event now.

    Code:
        @EventHandler
        public void onEntityDamage (EntityDamageByEntityEvent event) {
            EntityDamageByEntityEvent damageEvent = (EntityDamageByEntityEvent) event;
           
            if (damageEvent.getDamager() instanceof Entity.BABY_ZOMBIE) {
                event.setDamage(0);
            }
     
        }
     
  4. Offline

    teunie75

    Can't find the baby zombie entity myself.
    You can view the entity with EntityType instead of Entity but no baby zombie :(
     
  5. Offline

    FuZioN720

    teunie75 is there a when i can say like if its a zombie && getBaby() == true
     
  6. Offline

    tbsman

    FuZioN720 It's
    Code:
    EntityType.ZOMBIE 
    or you could just do
    Code:
    instanceof Zombie
    and Zombie has the function isBaby().

    So basically, it's
    Code:
    EntityDamageByEntityEvent damageEvent = (EntityDamageByEntityEvent) event;
     
            if (damageEvent.getEntity() instanceof Zombie) {
                if (((Zombie)damageEvent.getEntity()).isBaby())
                    event.setDamage(0);
            }
     
    FuZioN720 likes this.
  7. Offline

    FuZioN720

Thread Status:
Not open for further replies.

Share This Page