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; } } }
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; } }
/** 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); } }
@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); }
public boolean damageEntity(DamageSource damagesource, float f) { Entity entity = damagesource.getEntity(); return this.passenger != null && this.passenger.equals(entity) ? false : super.damageEntity(damagesource, f); }
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); } } }
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); }
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); } } }
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); }
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; } }
/** 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); } }
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); } }
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); } } } }
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; } }
public boolean damageEntity(DamageSource damagesource, int i) { if (this.isInvulnerable()) { return false; } else if (super.damageEntity(damagesource, i)) { Entity entity = damagesource.getEntity(); if (this.passenger != entity && this.vehicle != entity) { if (entity != this) { // CraftBukkit start - we still need to call events for entities without goals if (entity != this.target && (this instanceof EntityBlaze || this instanceof EntityEnderman || this instanceof EntitySpider || this instanceof EntityGiantZombie || this instanceof EntitySilverfish)) { EntityTargetEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callEntityTargetEvent( this, entity, EntityTargetEvent.TargetReason.TARGET_ATTACKED_ENTITY); if (!event.isCancelled()) { if (event.getTarget() == null) { this.target = null; } else { this.target = ((org.bukkit.craftbukkit.entity.CraftEntity) event.getTarget()).getHandle(); } } } else { this.target = entity; } // CraftBukkit end } return true; } else { return true; } } else { return false; } }
public void die(DamageSource damagesource) { Entity entity = damagesource.getEntity(); EntityLiving entityliving = this.aS(); 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.isBaby() && this.world.getGameRules().getBoolean("doMobLoot")) { this.dropDeathLoot(this.lastDamageByPlayerTime > 0, i); this.dropEquipment(this.lastDamageByPlayerTime > 0, i); if (false && this.lastDamageByPlayerTime > 0) { // CraftBukkit - move rare item drop call to dropDeathLoot int j = this.random.nextInt(200) - i; if (j < 5) { this.l(j <= 0 ? 1 : 0); } } } else { // CraftBukkit CraftEventFactory.callEntityDeathEvent(this); // CraftBukkit } } this.world.broadcastEntityEffect(this, (byte) 3); }
public boolean damageEntity(DamageSource damagesource, int i) { Entity entity = damagesource.getEntity(); if ((entity instanceof EntityHuman)) { List list = this.world.getEntities(this, this.boundingBox.grow(32.0D, 32.0D, 32.0D)); Iterator iterator = list.iterator(); while (iterator.hasNext()) { Entity entity1 = (Entity) iterator.next(); if ((entity1 instanceof EntityPigZombie)) { EntityPigZombie entitypigzombie = (EntityPigZombie) entity1; entitypigzombie.c(entity); } } c(entity); } return super.damageEntity(damagesource, i); }
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); } } }
@Override public boolean damageEntity(DamageSource source, float damage) { if (invulnerable || noDamageTicks > 0) { return false; } DamageCause cause = null; org.bukkit.entity.Entity bEntity = null; if (source instanceof EntityDamageSource) { Entity damager = source.getEntity(); cause = DamageCause.ENTITY_ATTACK; if (source instanceof EntityDamageSourceIndirect) { damager = ((EntityDamageSourceIndirect) source).getProximateDamageSource(); if (damager.getBukkitEntity() instanceof ThrownPotion) { cause = DamageCause.MAGIC; } else if (damager.getBukkitEntity() instanceof Projectile) { cause = DamageCause.PROJECTILE; } } bEntity = damager.getBukkitEntity(); } else if (source == DamageSource.FIRE) cause = DamageCause.FIRE; else if (source == DamageSource.STARVE) cause = DamageCause.STARVATION; else if (source == DamageSource.WITHER) cause = DamageCause.WITHER; else if (source == DamageSource.STUCK) cause = DamageCause.SUFFOCATION; else if (source == DamageSource.DROWN) cause = DamageCause.DROWNING; else if (source == DamageSource.BURN) cause = DamageCause.FIRE_TICK; else if (source == CraftEventFactory.MELTING) cause = DamageCause.MELTING; else if (source == CraftEventFactory.POISON) cause = DamageCause.POISON; else if (source == DamageSource.MAGIC) { cause = DamageCause.MAGIC; } else if (source == DamageSource.OUT_OF_WORLD) { cause = DamageCause.VOID; } if (cause != null) { NPCDamageEvent event = new NPCDamageEvent(npc, bEntity, cause, (double) damage); Bukkit.getPluginManager().callEvent(event); if (!event.isCancelled()) { return super.damageEntity(source, (float) event.getDamage()); } else { return false; } } if (super.damageEntity(source, damage)) { if (bEntity != null) { Entity e = ((CraftEntity) bEntity).getHandle(); double d0 = e.locX - this.locX; double d1; for (d1 = e.locZ - this.locZ; d0 * d0 + d1 * d1 < 0.0001D; d1 = (Math.random() - Math.random()) * 0.01D) { d0 = (Math.random() - Math.random()) * 0.01D; } a(e, damage, d0, d1); } return true; } else { return false; } }
public boolean damageEntity(DamageSource damagesource, float f) { if (this.isInvulnerable()) { return false; } else if (this.world.isStatic) { return false; } else { this.aV = 0; if (this.getHealth() <= 0.0F) { return false; } else if (damagesource.m() && this.hasEffect(MobEffectList.FIRE_RESISTANCE)) { return false; } else { if ((damagesource == DamageSource.ANVIL || damagesource == DamageSource.FALLING_BLOCK) && this.getEquipment(4) != null) { this.getEquipment(4).damage((int) (f * 4.0F + this.random.nextFloat() * f * 2.0F), this); f *= 0.75F; } this.aG = 1.5F; boolean flag = true; // CraftBukkit start EntityDamageEvent event = CraftEventFactory.handleEntityDamageEvent(this, damagesource, f); if (event != null) { if (event.isCancelled()) { return false; } f = (float) event.getDamage(); } // CraftBukkit end if ((float) this.noDamageTicks > (float) this.maxNoDamageTicks / 2.0F) { if (f <= this.lastDamage) { return false; } this.d(damagesource, f - this.lastDamage); this.lastDamage = f; flag = false; } else { this.lastDamage = f; this.ax = this.getHealth(); this.noDamageTicks = this.maxNoDamageTicks; this.d(damagesource, f); this.hurtTicks = this.az = 10; } this.aA = 0.0F; Entity entity = damagesource.getEntity(); if (entity != null) { if (entity instanceof EntityLiving) { this.b((EntityLiving) entity); } if (entity instanceof EntityHuman) { this.lastDamageByPlayerTime = 100; this.killer = (EntityHuman) entity; } else if (entity instanceof EntityWolf) { EntityWolf entitywolf = (EntityWolf) entity; if (entitywolf.isTamed()) { this.lastDamageByPlayerTime = 100; this.killer = null; } } } if (flag) { this.world.broadcastEntityEffect(this, (byte) 2); if (damagesource != DamageSource.DROWN) { this.K(); } if (entity != null) { double d0 = entity.locX - this.locX; double d1; for (d1 = entity.locZ - this.locZ; d0 * d0 + d1 * d1 < 1.0E-4D; d1 = (Math.random() - Math.random()) * 0.01D) { d0 = (Math.random() - Math.random()) * 0.01D; } this.aA = (float) (Math.atan2(d1, d0) * 180.0D / 3.1415927410125732D) - this.yaw; this.a(entity, f, d0, d1); } else { this.aA = (float) ((int) (Math.random() * 2.0D) * 180); } } if (this.getHealth() <= 0.0F) { if (flag) { this.makeSound(this.aP(), this.ba(), this.bb()); } this.die(damagesource); } else if (flag) { this.makeSound(this.aO(), this.ba(), this.bb()); } return true; } } }
public boolean damageEntity(DamageSource damagesource, int i) { if (!this.world.isStatic && !this.dead) { if (this.isInvulnerable()) { return false; } else { this.i(-this.k()); this.h(10); this.K(); this.setDamage(this.getDamage() + i * 10); if (damagesource.getEntity() instanceof EntityHuman && ((EntityHuman) damagesource.getEntity()).abilities.canInstantlyBuild) { this.setDamage(100); } if (this.getDamage() > 40) { if (this.passenger != null) { this.passenger.mount(this); } this.die(); this.a(Item.MINECART.id, 1, 0.0F); if (this.type == 1) { EntityMinecart entityminecart = this; for (int j = 0; j < entityminecart.getSize(); ++j) { ItemStack itemstack = entityminecart.getItem(j); if (itemstack != null) { float f = this.random.nextFloat() * 0.8F + 0.1F; float f1 = this.random.nextFloat() * 0.8F + 0.1F; float f2 = this.random.nextFloat() * 0.8F + 0.1F; while (itemstack.count > 0) { int k = this.random.nextInt(21) + 10; if (k > itemstack.count) { k = itemstack.count; } itemstack.count -= k; EntityItem entityitem = new EntityItem( this.world, this.locX + (double) f, this.locY + (double) f1, this.locZ + (double) f2, new ItemStack(itemstack.id, k, itemstack.getData())); float f3 = 0.05F; entityitem.motX = (double) ((float) this.random.nextGaussian() * f3); entityitem.motY = (double) ((float) this.random.nextGaussian() * f3 + 0.2F); entityitem.motZ = (double) ((float) this.random.nextGaussian() * f3); this.world.addEntity(entityitem); } } } this.a(Block.CHEST.id, 1, 0.0F); } else if (this.type == 2) { this.a(Block.FURNACE.id, 1, 0.0F); } } return true; } } else { return true; } }