/** * Reduces damage, depending on potions */ protected float applyPotionDamageCalculations(DamageSource source, float damage) { damage = super.applyPotionDamageCalculations(source, damage); if (source.getEntity() == this) { damage = 0.0F; } if (source.isMagicDamage()) { damage = (float)((double)damage * 0.15D); } return damage; }
@Override public boolean attackEntityFrom(DamageSource source, float amount) { Entity entity = source.getTrueSource(); boolean takenDamage = super.attackEntityFrom(source, amount); if (takenDamage && entity != null) { this.playSound(ModSoundEvents.ENTITY_FAKE_FADE, 1.0F, ((rand.nextFloat() - rand.nextFloat()) * 0.1F) + 1.0F); this.spawnExplosionParticle(); this.spawnExplosionParticle(); // TODO - examine why this is being fired twice - twice as many particles? this.setDead(); } return takenDamage; }
/** * Called when the entity is attacked. */ public boolean attackEntityFrom(DamageSource source, float amount) { if (!this.func_175472_n() && !source.isMagicDamage() && source.getSourceOfDamage() instanceof EntityLivingBase) { EntityLivingBase entitylivingbase = (EntityLivingBase)source.getSourceOfDamage(); if (!source.isExplosion()) { entitylivingbase.attackEntityFrom(DamageSource.causeThornsDamage(this), 2.0F); entitylivingbase.playSound("damage.thorns", 0.5F, 1.0F); } } this.wander.makeUpdate(); return super.attackEntityFrom(source, amount); }
/** * Called when the entity is attacked. */ public boolean attackEntityFrom(DamageSource source, float amount) { if (this.isEntityInvulnerable(source)) { return false; } else { this.setBeenAttacked(); this.xpOrbHealth = (int)((float)this.xpOrbHealth - amount); if (this.xpOrbHealth <= 0) { this.setDead(); } return false; } }
/** * Called when the entity is attacked. */ public boolean attackEntityFrom(DamageSource source, float amount) { Entity entity = source.getSourceOfDamage(); if (entity instanceof EntityArrow) { EntityArrow entityarrow = (EntityArrow)entity; if (entityarrow.isBurning()) { this.explodeCart(entityarrow.motionX * entityarrow.motionX + entityarrow.motionY * entityarrow.motionY + entityarrow.motionZ * entityarrow.motionZ); } } return super.attackEntityFrom(source, amount); }
/** * Called when the mob's health reaches 0. */ public void onDeath(DamageSource cause) { super.onDeath(cause); if (cause.getEntity() instanceof EntityCreeper) { EntityCreeper entitycreeper = (EntityCreeper)cause.getEntity(); if (entitycreeper.getPowered() && entitycreeper.isAIEnabled()) { entitycreeper.incrementDroppedSkulls(); this.entityDropItem(new ItemStack(Items.SKULL, 1, 1), 0.0F); } } }
public void fall(float distance, float damageMultiplier) { super.fall(distance, damageMultiplier); PotionEffect potioneffect = this.getActivePotionEffect(Potion.jump); float f = potioneffect != null ? (float)(potioneffect.getAmplifier() + 1) : 0.0F; int i = MathHelper.ceiling_float_int((distance - 3.0F - f) * damageMultiplier); if (i > 0) { this.playSound(this.getFallSoundString(i), 1.0F, 1.0F); this.attackEntityFrom(DamageSource.fall, (float)i); int j = MathHelper.floor_double(this.posX); int k = MathHelper.floor_double(this.posY - 0.20000000298023224D); int l = MathHelper.floor_double(this.posZ); Block block = this.worldObj.getBlockState(new BlockPos(j, k, l)).getBlock(); if (block.getMaterial() != Material.air) { Block.SoundType block$soundtype = block.stepSound; this.playSound(block$soundtype.getStepSound(), block$soundtype.getVolume() * 0.5F, block$soundtype.getFrequency() * 0.75F); } } }
public void affectEntity(@Nullable Entity source, @Nullable Entity indirectSource, EntityLivingBase entityLivingBaseIn, int amplifier, double health) { if ((this != MobEffects.INSTANT_HEALTH || entityLivingBaseIn.isEntityUndead()) && (this != MobEffects.INSTANT_DAMAGE || !entityLivingBaseIn.isEntityUndead())) { if (this == MobEffects.INSTANT_DAMAGE && !entityLivingBaseIn.isEntityUndead() || this == MobEffects.INSTANT_HEALTH && entityLivingBaseIn.isEntityUndead()) { int j = (int)(health * (double)(6 << amplifier) + 0.5D); if (source == null) { entityLivingBaseIn.attackEntityFrom(DamageSource.magic, (float)j); } else { entityLivingBaseIn.attackEntityFrom(DamageSource.causeIndirectMagicDamage(source, indirectSource), (float)j); } } } else { int i = (int)(health * (double)(4 << amplifier) + 0.5D); entityLivingBaseIn.heal((float)i); } }
protected void updateAITasks() { if (this.isWet()) { this.attackEntityFrom(DamageSource.drown, 1.0F); } if (this.world.isDaytime() && this.ticksExisted >= this.targetChangeTime + 600) { float f = this.getBrightness(1.0F); if (f > 0.5F && this.world.canSeeSky(new BlockPos(this)) && this.rand.nextFloat() * 30.0F < (f - 0.4F) * 2.0F) { this.setAttackTarget((EntityLivingBase)null); this.teleportRandomly(); } } super.updateAITasks(); }
protected void updateAITasks() { if (this.isWet()) { this.attackEntityFrom(DamageSource.drown, 1.0F); } --this.heightOffsetUpdateTime; if (this.heightOffsetUpdateTime <= 0) { this.heightOffsetUpdateTime = 100; this.heightOffset = 0.5F + (float)this.rand.nextGaussian() * 3.0F; } EntityLivingBase entitylivingbase = this.getAttackTarget(); if (entitylivingbase != null && entitylivingbase.posY + (double)entitylivingbase.getEyeHeight() > this.posY + (double)this.getEyeHeight() + (double)this.heightOffset) { this.motionY += (0.30000001192092896D - this.motionY) * 0.30000001192092896D; this.isAirBorne = true; } super.updateAITasks(); }
/** * Called when the entity is attacked. */ public boolean attackEntityFrom(DamageSource source, float amount) { if (this.isEntityInvulnerable(source)) { return false; } else { if (source instanceof EntityDamageSource || source == DamageSource.magic) { this.summonSilverfish.func_179462_f(); } return super.attackEntityFrom(source, amount); } }
public void killMinecart(DamageSource source) { this.setDead(); if (this.world.getGameRules().getBoolean("doEntityDrops")) { ItemStack itemstack = new ItemStack(Items.MINECART, 1); if (this.hasCustomName()) { itemstack.setStackDisplayName(this.getCustomNameTag()); } this.entityDropItem(itemstack, 0.0F); } }
public boolean attackEntityFromPart(EntityDragonPart dragonPart, DamageSource source, float p_70965_3_) { if (dragonPart != this.dragonPartHead) { p_70965_3_ = p_70965_3_ / 4.0F + 1.0F; } float f = this.rotationYaw * (float)Math.PI / 180.0F; float f1 = MathHelper.sin(f); float f2 = MathHelper.cos(f); this.targetX = this.posX + (double)(f1 * 5.0F) + (double)((this.rand.nextFloat() - 0.5F) * 2.0F); this.targetY = this.posY + (double)(this.rand.nextFloat() * 3.0F) + 1.0D; this.targetZ = this.posZ - (double)(f2 * 5.0F) + (double)((this.rand.nextFloat() - 0.5F) * 2.0F); this.target = null; if (source.getEntity() instanceof EntityPlayer || source.isExplosion()) { this.attackDragonFrom(source, p_70965_3_); } return true; }
/** * Called when the mob's health reaches 0. */ public void onDeath(DamageSource cause) { super.onDeath(cause); if (cause.getEntity() instanceof EntitySkeleton) { int i = Item.getIdFromItem(Items.record_13); int j = Item.getIdFromItem(Items.record_wait); int k = i + this.rand.nextInt(j - i + 1); this.dropItem(Item.getItemById(k), 1); } else if (cause.getEntity() instanceof EntityCreeper && cause.getEntity() != this && ((EntityCreeper)cause.getEntity()).getPowered() && ((EntityCreeper)cause.getEntity()).isAIEnabled()) { ((EntityCreeper)cause.getEntity()).func_175493_co(); this.entityDropItem(new ItemStack(Items.skull, 1, 4), 0.0F); } }
/** * Called when the mob's health reaches 0. */ public void onDeath(DamageSource cause) { super.onDeath(cause); if (cause.getSourceOfDamage() instanceof EntityArrow && cause.getEntity() instanceof EntityPlayer) { EntityPlayer entityplayer = (EntityPlayer)cause.getEntity(); double d0 = entityplayer.posX - this.posX; double d1 = entityplayer.posZ - this.posZ; if (d0 * d0 + d1 * d1 >= 2500.0D) { entityplayer.triggerAchievement(AchievementList.snipeSkeleton); } } else if (cause.getEntity() instanceof EntityCreeper && ((EntityCreeper)cause.getEntity()).getPowered() && ((EntityCreeper)cause.getEntity()).isAIEnabled()) { ((EntityCreeper)cause.getEntity()).func_175493_co(); this.entityDropItem(new ItemStack(Items.skull, 1, this.getSkeletonType() == 1 ? 1 : 0), 0.0F); } }
/** * Called when the entity is attacked. */ public boolean attackEntityFrom(DamageSource source, float amount) { if (this.isEntityInvulnerable(source)) { return false; } else if (super.attackEntityFrom(source, amount)) { Entity entity = source.getEntity(); return this.riddenByEntity != entity && this.ridingEntity != entity ? true : true; } else { return false; } }
/** * Called when the mob's health reaches 0. */ public void onDeath(DamageSource cause) { super.onDeath(cause); if (!this.world.isRemote && this.horseChest != null) { for (int i = 0; i < this.horseChest.getSizeInventory(); ++i) { ItemStack itemstack = this.horseChest.getStackInSlot(i); if (!itemstack.func_190926_b()) { this.entityDropItem(itemstack, 0.0F); } } } }
/** * Called when the mob's health reaches 0. */ public void onDeath(DamageSource cause) { super.onDeath(cause); if (this.func_190695_dh()) { if (!this.world.isRemote) { this.dropItem(Item.getItemFromBlock(Blocks.CHEST), 1); } this.setChested(false); } }
public void killMinecart(DamageSource source) { super.killMinecart(source); if (!source.isExplosion() && this.world.getGameRules().getBoolean("doEntityDrops")) { this.entityDropItem(new ItemStack(Blocks.FURNACE, 1), 0.0F); } }
public boolean attackEntityAsMob(Entity entityIn) { boolean flag = entityIn.attackEntityFrom(DamageSource.causeMobDamage(this), (float)((int)this.getEntityAttribute(SharedMonsterAttributes.ATTACK_DAMAGE).getAttributeValue())); if (flag) { this.applyEnchantments(this, entityIn); } return flag; }
/** * Called frequently so the entity can update its state every tick as required. For example, zombies and skeletons * use this to react to sunlight and start to burn. */ public void onLivingUpdate() { super.onLivingUpdate(); if (!this.worldObj.isRemote) { int i = MathHelper.floor_double(this.posX); int j = MathHelper.floor_double(this.posY); int k = MathHelper.floor_double(this.posZ); if (this.isWet()) { this.attackEntityFrom(DamageSource.drown, 1.0F); } if (this.worldObj.getBiomeGenForCoords(new BlockPos(i, 0, k)).getFloatTemperature(new BlockPos(i, j, k)) > 1.0F) { this.attackEntityFrom(DamageSource.onFire, 1.0F); } for (int l = 0; l < 4; ++l) { i = MathHelper.floor_double(this.posX + (double)((float)(l % 2 * 2 - 1) * 0.25F)); j = MathHelper.floor_double(this.posY); k = MathHelper.floor_double(this.posZ + (double)((float)(l / 2 % 2 * 2 - 1) * 0.25F)); BlockPos blockpos = new BlockPos(i, j, k); if (this.worldObj.getBlockState(blockpos).getBlock().getMaterial() == Material.air && this.worldObj.getBiomeGenForCoords(new BlockPos(i, 0, k)).getFloatTemperature(blockpos) < 0.8F && Blocks.snow_layer.canPlaceBlockAt(this.worldObj, blockpos)) { this.worldObj.setBlockState(blockpos, Blocks.snow_layer.getDefaultState()); } } } }
/** * Reduces damage, depending on potions */ protected float applyPotionDamageCalculations(DamageSource source, float damage) { if (source.isDamageAbsolute()) { return damage; } else { if (this.isPotionActive(MobEffects.RESISTANCE) && source != DamageSource.outOfWorld) { int i = (this.getActivePotionEffect(MobEffects.RESISTANCE).getAmplifier() + 1) * 5; int j = 25 - i; float f = damage * (float)j; damage = f / 25.0F; } if (damage <= 0.0F) { return 0.0F; } else { int k = EnchantmentHelper.getEnchantmentModifierDamage(this.getArmorInventoryList(), source); if (k > 0) { damage = CombatRules.getDamageAfterMagicAbsorb(damage, (float)k); } return damage; } } }
/** * Called when a lightning bolt hits the entity. */ public void onStruckByLightning(EntityLightningBolt lightningBolt) { this.attackEntityFrom(DamageSource.lightningBolt, 5.0F); ++this.fire; if (this.fire == 0) { this.setFire(8); } }
@Override public void onDrink(World world, BlockPos pos, FluidStack stack, EntityPlayer player, boolean fromFluidContainer) { player.attackEntityFrom(DamageSource.LAVA, 7); player.setFire(30); NBTTagCompound tag = player.getEntityData(); tag.setLong("lavaDrink", world.getTotalWorldTime()); }
@Override public boolean attackEntityAsMob(Entity entityIn) { if (entityIn instanceof EntityLivingBase) { ((EntityLivingBase) entityIn).addPotionEffect(new PotionEffect(MobEffects.POISON, 100, 1)); } return entityIn.attackEntityFrom(DamageSource.causeMobDamage(this), (float) getEntityAttribute(SharedMonsterAttributes.ATTACK_DAMAGE).getAttributeValue()); }
public void fall(float distance, float damageMultiplier) { if (distance > 1.0F) { this.playSound("mob.horse.land", 0.4F, 1.0F); } int i = MathHelper.ceiling_float_int((distance * 0.5F - 3.0F) * damageMultiplier); if (i > 0) { this.attackEntityFrom(DamageSource.fall, (float)i); if (this.riddenByEntity != null) { this.riddenByEntity.attackEntityFrom(DamageSource.fall, (float)i); } Block block = this.worldObj.getBlockState(new BlockPos(this.posX, this.posY - 0.2D - (double)this.prevRotationYaw, this.posZ)).getBlock(); if (block.getMaterial() != Material.air && !this.isSilent()) { Block.SoundType block$soundtype = block.stepSound; this.worldObj.playSoundAtEntity(this, block$soundtype.getStepSound(), block$soundtype.getVolume() * 0.5F, block$soundtype.getFrequency() * 0.75F); } } }
public boolean attackEntityFrom(DamageSource source, float amount) { if (this.isEntityInvulnerable(source)) { return false; } if (source.damageType.equals("player")) { if(this.data != null) this.entityDropItem(ItemStatue.getStatue(this), 0); this.setDead(); return true; } return false; }
@Override public boolean hitEntity(ItemStack stack, EntityLivingBase target, EntityLivingBase attacker) { if (!target.world.isRemote) if (target instanceof EntityEnderman && attacker instanceof EntityPlayer) { target.attackEntityFrom(DamageSource.causePlayerDamage((EntityPlayer) attacker), 20); stack.damageItem(50, attacker); } else { stack.damageItem(1, attacker); } return true; }
/** * Triggered whenever an entity collides with this block (enters into the block) */ public void onEntityWalk(World worldIn, BlockPos pos, Entity entityIn) { if (!entityIn.isImmuneToFire() && entityIn instanceof EntityLivingBase && !EnchantmentHelper.hasFrostWalkerEnchantment((EntityLivingBase)entityIn)) { entityIn.attackEntityFrom(DamageSource.hotFloor, 1.0F); } super.onEntityWalk(worldIn, pos, entityIn); }
protected void func_175451_e(EntityLivingBase p_175451_1_) { int i = this.getSlimeSize(); if (this.canEntityBeSeen(p_175451_1_) && this.getDistanceSqToEntity(p_175451_1_) < 0.6D * (double)i * 0.6D * (double)i && p_175451_1_.attackEntityFrom(DamageSource.causeMobDamage(this), (float)this.getAttackStrength())) { this.playSound("mob.attack", 1.0F, (this.rand.nextFloat() - this.rand.nextFloat()) * 0.2F + 1.0F); this.applyEnchantments(this, p_175451_1_); } }
@Override public DamageSource getLastDamageSource() { if (m_realPlayer == null) { return super.getLastDamageSource(); } else { return m_realPlayer.getLastDamageSource(); } }
protected void collideWithNearbyEntities() { List<Entity> list = this.world.getEntitiesInAABBexcluding(this, this.getEntityBoundingBox(), EntitySelectors.<Entity>getTeamCollisionPredicate(this)); if (!list.isEmpty()) { int i = this.world.getGameRules().getInt("maxEntityCramming"); if (i > 0 && list.size() > i - 1 && this.rand.nextInt(4) == 0) { int j = 0; for (int k = 0; k < list.size(); ++k) { if (!((Entity)list.get(k)).isRiding()) { ++j; } } if (j > i - 1) { this.attackEntityFrom(DamageSource.field_191291_g, 6.0F); } } for (int l = 0; l < list.size(); ++l) { Entity entity = (Entity)list.get(l); this.collideWithEntity(entity); } } }
/** * Will deal the specified amount of damage to the entity if the entity isn't immune to fire damage. Args: * amountDamage */ protected void dealFireDamage(int amount) { if (!this.isImmuneToFire) { this.attackEntityFrom(DamageSource.inFire, (float)amount); } }
@Override public void onDeath(DamageSource cause) { super.onDeath(cause); if (!this.world.isRemote) { this.dead = true; this.world.createExplosion(this, this.posX, this.posY, this.posZ, 50F, false); this.setDead(); } }
/** * Called whenever the entity is walking inside of lava. */ protected void setOnFireFromLava() { if (!this.isImmuneToFire) { this.attackEntityFrom(DamageSource.lava, 4.0F); this.setFire(15); } }