예제 #1
0
  public boolean damageEntity(DamageSource damagesource, float f) {
    if (this.isInvulnerable()) {
      return false;
    } else {
      this.J();
      if (damagesource.getEntity() != null) {
        Vec3D vec3d = damagesource.getEntity().Z();

        if (vec3d != null) {
          this.motX = vec3d.c;
          this.motY = vec3d.d;
          this.motZ = vec3d.e;
          this.dirX = this.motX * 0.1D;
          this.dirY = this.motY * 0.1D;
          this.dirZ = this.motZ * 0.1D;
        }

        if (damagesource.getEntity() instanceof EntityLiving) {
          this.shooter = (EntityLiving) damagesource.getEntity();
        }

        return true;
      } else {
        return false;
      }
    }
  }
예제 #2
0
  public boolean damageEntity(DamageSource damagesource, float f) {
    if (this.isInvulnerable()) {
      return false;
    } else if (!this.world.isStatic && !this.dead) {
      this.c(-this.h());
      this.a(10);
      this.setDamage(this.getDamage() + f * 10.0F);
      this.J();
      boolean flag =
          damagesource.getEntity() instanceof EntityHuman
              && ((EntityHuman) damagesource.getEntity()).abilities.canInstantlyBuild;

      if (flag || this.getDamage() > 40.0F) {
        if (this.passenger != null) {
          this.passenger.mount(this);
        }

        if (!flag) {
          this.a(Item.BOAT.id, 1, 0.0F);
        }

        this.die();
      }

      return true;
    } else {
      return true;
    }
  }
예제 #3
0
  protected void c(DamageSource damagesource, int i) {
    if (!damagesource.ignoresArmor() && this.P()) {
      i = 1 + i >> 1;
    }

    i = this.d(damagesource, i);
    i = this.b(damagesource, i);
    this.c(damagesource.f());
    this.health -= i;
  }
예제 #4
0
 /** Called when the entity is attacked. */
 public boolean attackEntityFrom(DamageSource par1DamageSource, int par2) {
   if (this.isEntityInvulnerable()) {
     return false;
   } else if ("fireball".equals(par1DamageSource.getDamageType())
       && par1DamageSource.getEntity() instanceof EntityPlayer) {
     super.attackEntityFrom(par1DamageSource, 1000);
     ((EntityPlayer) par1DamageSource.getEntity()).triggerAchievement(AchievementList.ghast);
     return true;
   } else {
     return super.attackEntityFrom(par1DamageSource, par2);
   }
 }
예제 #5
0
  public void a(DamageSource damagesource) {
    super.a(damagesource);
    double d0 = this.motX * this.motX + this.motZ * this.motZ;

    if (!damagesource.c()) {
      this.a(new ItemStack(Blocks.TNT, 1), 0.0F);
    }

    if (damagesource.o() || damagesource.c() || d0 >= 0.009999999776482582D) {
      this.c(d0);
    }
  }
예제 #6
0
  public void die(DamageSource damagesource) {
    Entity entity = damagesource.getEntity();
    EntityLiving entityliving = this.aX();

    if (this.bb >= 0 && entityliving != null) {
      entityliving.b(this, this.bb);
    }

    if (entity != null) {
      entity.a(this);
    }

    this.aU = true;
    if (!this.world.isStatic) {
      int i = 0;

      if (entity instanceof EntityHuman) {
        i = EnchantmentManager.getBonusMonsterLootEnchantmentLevel((EntityLiving) entity);
      }

      if (this.aG() && this.world.getGameRules().getBoolean("doMobLoot")) {
        this.dropDeathLoot(this.lastDamageByPlayerTime > 0, i);
        this.dropEquipment(this.lastDamageByPlayerTime > 0, i);
        if (this.lastDamageByPlayerTime > 0) {
          int j = this.random.nextInt(200) - i;

          if (j < 5) {
            this.getRareDrop(j <= 0 ? 1 : 0);
          }
        }
      }
    }

    this.world.broadcastEntityEffect(this, (byte) 3);
  }
예제 #7
0
  public boolean damageEntity(DamageSource damagesource, int i) {
    if (this.isInvulnerable()) {
      return false;
    } else {
      // CraftBukkit - this.server.getPvP() -> this.world.pvpMode
      boolean flag =
          this.server.T() && this.world.pvpMode && "fall".equals(damagesource.translationIndex);

      if (!flag && this.invulnerableTicks > 0 && damagesource != DamageSource.OUT_OF_WORLD) {
        return false;
      } else {
        // CraftBukkit - this.server.getPvP() -> this.world.pvpMode
        if (!this.world.pvpMode && damagesource instanceof EntityDamageSource) {
          Entity entity = damagesource.getEntity();

          if (entity instanceof EntityHuman) {
            return false;
          }

          if (entity instanceof EntityArrow) {
            EntityArrow entityarrow = (EntityArrow) entity;

            if (entityarrow.shooter instanceof EntityHuman) {
              return false;
            }
          }
        }

        return super.damageEntity(damagesource, i);
      }
    }
  }
예제 #8
0
  public boolean damageEntity(DamageSource damagesource, float f) {
    Entity entity = damagesource.getEntity();

    return this.passenger != null && this.passenger.equals(entity)
        ? false
        : super.damageEntity(damagesource, f);
  }
예제 #9
0
  public boolean a(DamageSource damagesource, int i0) {
    if (this.aq()) {
      return false;
    } else {
      // CanaryMod moved pvp to per-world config
      boolean haspvp = Configuration.getWorldConfig(getCanaryWorld().getFqName()).isPvpEnabled();
      boolean flag0 = this.b.T() && haspvp && "fall".equals(damagesource.o);

      if (!flag0 && this.cq > 0 && damagesource != DamageSource.i) {
        return false;
      } else {
        if (damagesource instanceof EntityDamageSource) {
          Entity entity = damagesource.i();

          if (entity instanceof EntityPlayer && !this.a((EntityPlayer) entity)) {
            return false;
          }

          if (entity instanceof EntityArrow) {
            EntityArrow entityarrow = (EntityArrow) entity;

            if (entityarrow.c instanceof EntityPlayer && !this.a((EntityPlayer) entityarrow.c)) {
              return false;
            }
          }
        }

        return super.a(damagesource, i0);
      }
    }
  }
 @Override
 public boolean damageEntity(DamageSource damageSource, float v) {
   if (this.controllableEntity != null
       && damageSource.getEntity() != null
       && damageSource.getEntity().getBukkitEntity() instanceof Player) {
     return !this.controllableEntity
         .getMind()
         .getAttribute(InteractAttribute.class)
         .call(
             this.controllableEntity,
             damageSource.getEntity().getBukkitEntity(),
             Action.LEFT_CLICK)
         .isCancelled();
   }
   return super.damageEntity(damageSource, v);
 }
예제 #11
0
 @Override
 protected void a(MovingObjectPosition movingobjectposition) {
   if (movingobjectposition.entity != null) {
     movingobjectposition.entity.damageEntity(DamageSource.fireball(this, this.shooter), damage);
   }
   die();
 }
예제 #12
0
  public boolean damageEntity(DamageSource damagesource, float f) {
    if (this.isInvulnerable()) {
      return false;
    } else {
      this.a(true);
      if (damagesource instanceof EntityDamageSource
          && damagesource.getEntity() instanceof EntityHuman) {
        this.bv = true;
      }

      if (damagesource instanceof EntityDamageSourceIndirect) {
        this.bv = false;

        for (int i = 0; i < 64; ++i) {
          if (this.bZ()) {
            return true;
          }
        }

        return false;
      } else {
        return super.damageEntity(damagesource, f);
      }
    }
  }
예제 #13
0
  public boolean damageEntity(DamageSource damagesource, int i) {
    if (this.abilities.isInvulnerable && !damagesource.ignoresInvulnerability()) {
      return false;
    } else {
      this.aV = 0;
      if (this.getHealth() <= 0) {
        return false;
      } else {
        if (this.isSleeping() && !this.world.isStatic) {
          this.a(true, true, false);
        }

        Entity entity = damagesource.getEntity();

        if (entity instanceof EntityMonster || entity instanceof EntityArrow) {
          if (this.world.difficulty == 0) {
            i = 0;
          }

          if (this.world.difficulty == 1) {
            i = i / 2 + 1;
          }

          if (this.world.difficulty == 3) {
            i = i * 3 / 2;
          }
        }

        if (i == 0) {
          return false;
        } else {
          Entity entity1 = entity;

          if (entity instanceof EntityArrow && ((EntityArrow) entity).shooter != null) {
            entity1 = ((EntityArrow) entity).shooter;
          }

          if (entity1 instanceof EntityLiving) {
            this.a((EntityLiving) entity1, false);
          }

          this.a(StatisticList.x, i);
          return super.damageEntity(damagesource, i);
        }
      }
    }
  }
예제 #14
0
  protected float b(DamageSource damagesource, float f) {
    if (!damagesource.ignoresArmor()) {
      int i = 25 - this.aQ();
      float f1 = f * (float) i;

      this.h(f);
      f = f1 / 25.0F;
    }

    return f;
  }
  public boolean damageEntity(DamageSource var1, float var2) {
    if (this.b((DamageSource) var1)) {
      return false;
    } else {
      Entity var3 = var1.j();
      if (var3 instanceof EntityHuman) {
        this.b(var3);
      }

      return super.damageEntity(var1, var2);
    }
  }
예제 #16
0
  public void b_(EntityHuman entityhuman) {
    if (this.l()) {
      int i = this.getSize();

      if (this.n(entityhuman)
          && this.e(entityhuman) < 0.6D * (double) i * 0.6D * (double) i
          && entityhuman.damageEntity(DamageSource.mobAttack(this), this.m())) {
        this.makeSound(
            "mob.attack", 1.0F, (this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.0F);
      }
    }
  }
예제 #17
0
  public void die(DamageSource damagesource) {
    // CraftBukkit start
    if (this.dead) {
      return;
    }

    java.util.List<org.bukkit.inventory.ItemStack> loot =
        new java.util.ArrayList<org.bukkit.inventory.ItemStack>();
    boolean keepInventory = this.world.getGameRules().getBoolean("keepInventory");

    if (!keepInventory) {
      for (int i = 0; i < this.inventory.items.length; ++i) {
        if (this.inventory.items[i] != null) {
          loot.add(CraftItemStack.asCraftMirror(this.inventory.items[i]));
        }
      }

      for (int i = 0; i < this.inventory.armor.length; ++i) {
        if (this.inventory.armor[i] != null) {
          loot.add(CraftItemStack.asCraftMirror(this.inventory.armor[i]));
        }
      }
    }

    org.bukkit.event.entity.PlayerDeathEvent event =
        CraftEventFactory.callPlayerDeathEvent(
            this, loot, damagesource.getLocalizedDeathMessage(this));

    String deathMessage = event.getDeathMessage();

    if (deathMessage != null && deathMessage.length() > 0) {
      this.server.getPlayerList().k(event.getDeathMessage());
    }

    // CraftBukkit - we clean the player's inventory after the EntityDeathEvent is called so plugins
    // can get the exact state of the inventory.
    if (!keepInventory) {
      for (int i = 0; i < this.inventory.items.length; ++i) {
        this.inventory.items[i] = null;
      }

      for (int i = 0; i < this.inventory.armor.length; ++i) {
        this.inventory.armor[i] = null;
      }
    }

    this.closeInventory();

    // Update effects on player death
    this.updateEffects = true;
    // CraftBukkit end
  }
예제 #18
0
  public boolean damageEntity(DamageSource damagesource, float f) {
    if (this.isInvulnerable(damagesource)) {
      return false;
    } else if (damagesource != DamageSource.DROWN
        && !(damagesource.getEntity() instanceof EntityWither)) {
      if (this.cj() > 0 && damagesource != DamageSource.OUT_OF_WORLD) {
        return false;
      } else {
        Entity entity;

        if (this.ck()) {
          entity = damagesource.i();
          if (entity instanceof EntityArrow) {
            return false;
          }
        }

        entity = damagesource.getEntity();
        if (entity != null
            && !(entity instanceof EntityHuman)
            && entity instanceof EntityLiving
            && ((EntityLiving) entity).getMonsterType() == this.getMonsterType()) {
          return false;
        } else {
          if (this.bo <= 0) {
            this.bo = 20;
          }

          for (int i = 0; i < this.bn.length; ++i) {
            this.bn[i] += 3;
          }

          return super.damageEntity(damagesource, f);
        }
      }
    } else {
      return false;
    }
  }
예제 #19
0
  public boolean m(Entity entity) {
    this.br = 10;
    this.world.broadcastEntityEffect(this, (byte) 4);
    boolean flag =
        entity.damageEntity(DamageSource.mobAttack(this), (float) (7 + this.random.nextInt(15)));

    if (flag) {
      entity.motY += 0.4000000059604645D;
    }

    this.makeSound("mob.irongolem.throw", 1.0F, 1.0F);
    return flag;
  }
 public void die(DamageSource damagesource) {
   if (village != null) {
     Entity entity = damagesource.getEntity();
     if (entity != null) {
       if (entity instanceof EntityHuman) village.a(entity.getName(), -2);
       else if (entity instanceof IMonster) village.h();
     } else if (entity == null) {
       EntityHuman entityhuman = world.findNearbyPlayer(this, 16D);
       if (entityhuman != null) village.h();
     }
   }
   super.die(damagesource);
 }
예제 #21
0
  public boolean damageEntity(DamageSource damagesource, float f) {
    if (this.isInvulnerable()) {
      return false;
    } else if (this.getItem() != null) {
      if (!this.world.isStatic) {
        this.b(damagesource.getEntity(), false);
        this.setItem((ItemStack) null);
      }

      return true;
    } else {
      return super.damageEntity(damagesource, f);
    }
  }
예제 #22
0
  public boolean attackEntityAsMob(Entity par1Entity) {
    this.attackTimer = 10;
    this.worldObj.setEntityState(this, (byte) 4);
    boolean var2 =
        par1Entity.attackEntityFrom(
            DamageSource.causeMobDamage(this), (float) (7 + this.rand.nextInt(15)));

    if (var2) {
      par1Entity.motionY += 0.4000000059604645D;
    }

    this.playSound("mob.irongolem.throw", 1.0F, 1.0F);
    return var2;
  }
  public boolean r(Entity var1) {
    this.bs = 10;
    this.o.a((Entity) this, (byte) 4);
    boolean var2 =
        var1.damageEntity(
            DamageSource.a((EntityLiving) this), (float) (7 + this.random.nextInt(15)));
    if (var2) {
      var1.motY += 0.4000000059604645D;
      this.a(this, var1);
    }

    this.a("mob.irongolem.throw", 1.0F, 1.0F);
    return var2;
  }
예제 #24
0
  /** Called when the entity is attacked. */
  public boolean attackEntityFrom(DamageSource par1DamageSource, int par2) {
    if (this.func_85032_ar()) {
      return false;
    } else {
      Entity var3 = par1DamageSource.getEntity();
      this.aiSit.setSitting(false);

      if (var3 != null && !(var3 instanceof EntityPlayer) && !(var3 instanceof EntityArrow)) {
        par2 = (par2 + 1) / 2;
      }

      return super.attackEntityFrom(par1DamageSource, par2);
    }
  }
  protected void a(MovingObjectPosition movingobjectposition) {
    if (!this.world.isStatic) {
      if (movingobjectposition.entity != null) {
        if (this.shooter != null) {
          if (movingobjectposition.entity.damageEntity(DamageSource.mobAttack(this.shooter), 8)
              && !movingobjectposition.entity.isAlive()) {
            this.shooter.heal(5, EntityRegainHealthEvent.RegainReason.WITHER); // CraftBukkit
          }
        } else {
          movingobjectposition.entity.damageEntity(DamageSource.MAGIC, 5);
        }

        if (movingobjectposition.entity instanceof EntityLiving) {
          byte b0 = 0;

          if (this.world.difficulty > 1) {
            if (this.world.difficulty == 2) {
              b0 = 10;
            } else if (this.world.difficulty == 3) {
              b0 = 40;
            }
          }

          if (b0 > 0) {
            ((EntityLiving) movingobjectposition.entity)
                .addEffect(new MobEffect(MobEffectList.WITHER.id, 20 * b0, 1));
          }
        }
      }

      // CraftBukkit start
      ExplosionPrimeEvent event = new ExplosionPrimeEvent(this.getBukkitEntity(), 1.0F, false);
      this.world.getServer().getPluginManager().callEvent(event);

      if (!event.isCancelled()) {
        this.world.createExplosion(
            this,
            this.locX,
            this.locY,
            this.locZ,
            event.getRadius(),
            event.getFire(),
            this.world.getGameRules().getBoolean("mobGriefing"));
      }
      // CraftBukkit end

      this.die();
    }
  }
예제 #26
0
  public boolean damageEntity(DamageSource damagesource, float f) {
    if (this.isInvulnerable()) {
      return false;
    } else if (damagesource == DamageSource.DROWN) {
      return false;
    } else if (this.bU() > 0) {
      return false;
    } else {
      Entity entity;

      if (this.bV()) {
        entity = damagesource.h();
        if (entity instanceof EntityArrow) {
          return false;
        }
      }

      entity = damagesource.getEntity();
      if (entity != null
          && !(entity instanceof EntityHuman)
          && entity instanceof EntityLiving
          && ((EntityLiving) entity).getMonsterType() == this.getMonsterType()) {
        return false;
      } else {
        if (this.bv <= 0) {
          this.bv = 20;
        }

        for (int i = 0; i < this.bu.length; ++i) {
          this.bu[i] += 3;
        }

        return super.damageEntity(damagesource, f);
      }
    }
  }
 public int func_77318_a(int p_77318_1_, DamageSource p_77318_2_) {
   if (p_77318_2_.func_76357_e()) {
     return 0;
   }
   int i = (6 + p_77318_1_ * p_77318_1_) / 2;
   if (field_77356_a == 0) {
     return i;
   }
   if (field_77356_a == 1 && p_77318_2_.func_76347_k()) {
     return i;
   }
   if (field_77356_a == 2 && p_77318_2_ == DamageSource.field_76379_h) {
     return i * 2;
   }
   if (field_77356_a == 3 && p_77318_2_ == DamageSource.field_76378_k
       || p_77318_2_ == DamageSource.field_76375_l) {
     return i;
   }
   if (field_77356_a == 4 && p_77318_2_.func_76352_a()) {
     return i;
   } else {
     return 0;
   }
 }
예제 #28
0
  public void a_(EntityHuman entityhuman) {
    if (this.C()) {
      int i = this.getSize();

      if (this.g(entityhuman)
          && (double) this.h(entityhuman) < 0.6D * (double) i
          && entityhuman.damageEntity(DamageSource.mobAttack(this), this.D())) {
        this.world.makeSound(
            this,
            "mob.slimeattack",
            1.0F,
            (this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.0F);
      }
    }
  }
예제 #29
0
 public void func_40613_a(
     EntityLiving p_40613_1_, EntityLiving p_40613_2_, int p_40613_3_, double p_40613_4_) {
   if (field_35670_H == field_35685_h.field_35670_H && !p_40613_2_.func_40122_aP()
       || field_35670_H == field_35686_i.field_35670_H && p_40613_2_.func_40122_aP()) {
     int i = (int) (p_40613_4_ * (double) (6 << p_40613_3_) + 0.5D);
     p_40613_2_.func_432_b(i);
   } else if (field_35670_H == field_35686_i.field_35670_H && !p_40613_2_.func_40122_aP()
       || field_35670_H == field_35685_h.field_35670_H && p_40613_2_.func_40122_aP()) {
     int j = (int) (p_40613_4_ * (double) (6 << p_40613_3_) + 0.5D);
     if (p_40613_1_ == null) {
       p_40613_2_.func_396_a(DamageSource.field_35545_l, j);
     } else {
       p_40613_2_.func_396_a(DamageSource.func_40542_b(p_40613_2_, p_40613_1_), j);
     }
   }
 }
예제 #30
0
  public boolean damageEntity(DamageSource damagesource, float f) {
    if (this.isInvulnerable()) {
      return false;
    } else if (super.damageEntity(damagesource, f)) {
      Entity entity = damagesource.getEntity();

      if (this.passenger != entity && this.vehicle != entity) {
        if (entity != this) {
          this.target = entity;
        }

        return true;
      } else {
        return true;
      }
    } else {
      return false;
    }
  }