@Override public boolean attackEntityFrom(DamageSource source, float amount) { if (isEntityInvulnerable(source)) { return false; } if ((source instanceof EntityDamageSourceIndirect)) { for (int i = 0; i < 64; i++) { } return false; } boolean flag = super.attackEntityFrom(source, amount); if ((source.isUnblockable()) && (rand.nextInt(10) != 0)) { teleportRandomly(); } return flag; }
public boolean snowballFight(DamageSource damagesource) { if (damagesource instanceof EntityDamageSourceIndirect) { EntityDamageSourceIndirect snowdamage = (EntityDamageSourceIndirect) damagesource; if (snowdamage.getSourceOfDamage() != null && snowdamage .getSourceOfDamage() instanceof EntitySnowball) { snowballin += 1; if (attackTime < 10) { attackTime = 10; } } } return snowballin <= 0; }
@Override public boolean attackEntityFrom(DamageSource damageSource, float damage) { if (damageSource instanceof EntityDamageSourceIndirect) { return false; } Entity src = damageSource.getSourceOfDamage(); if (!(src instanceof EntityPlayer)) { return false; } if (isDead) { return false; } EntityPlayer player = (EntityPlayer) src; if (worldObj.isRemote) return true; setDead(); if (!PlayerUtil.isPlayerCreative(player)) dropItemsOnBreak(); return true; }
@Override public boolean attackEntityFrom(DamageSource source, float damage) { if(source instanceof EntityDamageSourceIndirect) { EntityDamageSourceIndirect src = (EntityDamageSourceIndirect)source; if(src.getEntity() != null && src.getEntity() == this) { return false; } } if(this.hurtTime == 0) { playSound("mob.skeleton.hurt", 1.0F, 1.0F); } if(!worldObj.isRemote) { System.out.println("Dam: " + damage); } return super.attackEntityFrom(source, damage); }
@Override protected void onImpact(MovingObjectPosition pos) { if (pos.entityHit instanceof EntityEnderman) return; if (pos.typeOfHit == MovingObjectType.BLOCK) { if (worldObj.getBlock(pos.blockX, pos.blockY, pos.blockZ).getMaterial().isReplaceable()) return; } setDead(); if (!worldObj.isRemote) { if (pos.entityHit != null && pos.entityHit instanceof EntityLivingBase) { float min = (float)FarragoMod.config.getDouble("blunderbuss.damage.min"); float max = (float)FarragoMod.config.getDouble("blunderbuss.damage.max"); ((EntityLivingBase)pos.entityHit).attackEntityFrom(new EntityDamageSourceIndirect("blunderbuss", this, getThrower()), (rand.nextFloat()*(max-min))+min); ((EntityLivingBase)pos.entityHit).hurtResistantTime = 1; } if (worldObj instanceof WorldServer) { ((WorldServer)worldObj).func_147487_a("smoke", pos.hitVec.xCoord, pos.hitVec.yCoord, pos.hitVec.zCoord, 1, 0.2f, 0.2f, 0.2f, 0f); ((WorldServer)worldObj).playSoundAtEntity(this, "step.stone", 0.5f, 0.3f); } } }
public boolean func_70097_a(DamageSource p_70097_1_, float p_70097_2_) { if(this.func_85032_ar()) { return false; } else { this.func_70819_e(true); if(p_70097_1_ instanceof EntityDamageSource && p_70097_1_.func_76346_g() instanceof EntityPlayer) { this.field_104003_g = true; } if(p_70097_1_ instanceof EntityDamageSourceIndirect) { this.field_104003_g = false; for(int var3 = 0; var3 < 64; ++var3) { if(this.func_70820_n()) { return true; } } return false; } else { return super.func_70097_a(p_70097_1_, p_70097_2_); } } }
@SubscribeEvent public void onLivingHurt(LivingHurtEvent event) { if(event.source.getEntity() instanceof EntityPlayerMP && !(event.source instanceof EntityDamageSourceIndirect)) { EntityPlayer player = (EntityPlayer)event.source.getEntity(); MorphInfo info = Morph.proxy.tickHandlerServer.getPlayerMorphInfo(player); if(info != null && player.getCurrentEquippedItem() == null) { for(Ability ab : info.morphAbilities) { if(ab instanceof AbilityPotionEffect) { AbilityPotionEffect abPot = (AbilityPotionEffect)ab; event.entityLiving.addPotionEffect(new PotionEffect(abPot.potionId, abPot.duration, abPot.amplifier, abPot.ambient)); } } } } }
@Override public void onHit(EntityThrown entity, RayTraceResult result, boolean isServer) { if(result.entityHit != null && result.entityHit != entity.getThrower()) { entity.setDead(); if(result.entityHit.attackEntityFrom(new EntityDamageSourceIndirect("ender_bow", entity, entity.getThrower() == null ? entity : entity.getThrower()).setProjectile(), power * 20f)) entity.playSound(SoundEvents.ENTITY_ARROW_HIT, 1.0F, 1.2F / (itemRand.nextFloat() * 0.2F + 0.9F)); } }
@SubscribeEvent public void livingAttack(LivingAttackEvent event) { if (event.source instanceof EntityDamageSourceIndirect) { EntityDamageSourceIndirect dmgSrc = (EntityDamageSourceIndirect) event.source; if (dmgSrc.getSourceOfDamage() instanceof EntityTippedArrow) { EntityTippedArrow tippedArrow = (EntityTippedArrow) dmgSrc.getSourceOfDamage(); if (!tippedArrow.worldObj.isRemote) event.entityLiving.addPotionEffect(tippedArrow.getEffect()); } } }
/** * Called when the entity is attacked. */ public boolean attackEntityFrom(DamageSource source, float amount) { if (this.isEntityInvulnerable(source)) { return false; } else if (!this.world.isRemote && !this.isDead) { if (source instanceof EntityDamageSourceIndirect && source.getEntity() != null && this.isPassenger(source.getEntity())) { return false; } else { this.setForwardDirection(-this.getForwardDirection()); this.setTimeSinceHit(10); this.setDamageTaken(this.getDamageTaken() + amount * 10.0F); this.setBeenAttacked(); boolean flag = source.getEntity() instanceof EntityPlayer && ((EntityPlayer)source.getEntity()).capabilities.isCreativeMode; if (flag || this.getDamageTaken() > 40.0F) { if (!flag && this.world.getGameRules().getBoolean("doEntityDrops")) { this.dropItemWithOffset(this.getItemBoat(), 1, 0.0F); } this.setDead(); } return true; } } else { return true; } }
/** * Called when the entity is attacked. */ public boolean attackEntityFrom(DamageSource source, float amount) { if (this.isEntityInvulnerable(source)) { return false; } else if (source instanceof EntityDamageSourceIndirect) { for (int i = 0; i < 64; ++i) { if (this.teleportRandomly()) { return true; } } return false; } else { boolean flag = super.attackEntityFrom(source, amount); if (source.isUnblockable() && this.rand.nextInt(10) != 0) { this.teleportRandomly(); } return flag; } }
/** * Called when the entity is attacked. */ public boolean attackEntityFrom(DamageSource source, float amount) { if (this.isEntityInvulnerable(source)) { return false; } else if (!this.worldObj.isRemote && !this.isDead) { if (source instanceof EntityDamageSourceIndirect && source.getEntity() != null && this.isPassenger(source.getEntity())) { return false; } else { this.setForwardDirection(-this.getForwardDirection()); this.setTimeSinceHit(10); this.setDamageTaken(this.getDamageTaken() + amount * 10.0F); this.setBeenAttacked(); boolean flag = source.getEntity() instanceof EntityPlayer && ((EntityPlayer)source.getEntity()).capabilities.isCreativeMode; if (flag || this.getDamageTaken() > 40.0F) { if (!flag && this.worldObj.getGameRules().getBoolean("doEntityDrops")) { this.dropItemWithOffset(this.getItemBoat(), 1, 0.0F); } this.setDead(); } return true; } } else { return true; } }
public boolean attackEntityFrom(DamageSource source, float amount) { if (this.isEntityInvulnerable(source)) { return false; } if (!world.isRemote) { if (source instanceof EntityDamageSourceIndirect) { redirectArrowAtAttacker(source); } else { redirectAttack(source, amount); } } return false; }
public boolean attackEntityFrom(DamageSource source, float amount) { if (this.isEntityInvulnerable(source)) { return false; } if (source instanceof EntityDamageSourceIndirect) { redirectArrowAtAttacker(source); return false; } else { amount = redirectAttack(source, amount); } return super.attackEntityFrom(source, amount); }
public boolean attackEntityFrom(DamageSource source, float amount) { if (this.isEntityInvulnerable(source)) { return false; } if (source instanceof EntityDamageSourceIndirect) { attackDistantAttackerWithBats(source); } return super.attackEntityFrom(source, amount); }
@SubscribeEvent(priority = EventPriority.LOWEST) public void onLivingHurt(LivingHurtEvent event) { if (event.getSource() instanceof EntityDamageSource && !(event.getSource() instanceof EntityDamageSourceIndirect) && event.getSource().getImmediateSource() instanceof EntityLivingBase) { EntityLivingBase living = (EntityLivingBase) event.getSource().getImmediateSource(); int level = EnchantmentHelper.getEnchantmentLevel(this, living.getHeldItemMainhand()); if (level > 0) living.heal(event.getAmount() * min(SIPHON_COEFFICIENT * level, 1F)); } }
/** * Called when the entity is attacked. */ public boolean attackEntityFrom(DamageSource p_70097_1_, float p_70097_2_) { if (this.isEntityInvulnerable()) { return false; } else { this.setScreaming(true); if (p_70097_1_ instanceof EntityDamageSource && p_70097_1_.getEntity() instanceof EntityPlayer) { this.isAggressive = true; } if (p_70097_1_ instanceof EntityDamageSourceIndirect) { this.isAggressive = false; for (int i = 0; i < 64; ++i) { if (this.teleportRandomly()) { return true; } } return super.attackEntityFrom(p_70097_1_, p_70097_2_); } else { return super.attackEntityFrom(p_70097_1_, p_70097_2_); } } }
/** * Called when the entity is attacked. */ @Override public boolean attackEntityFrom(DamageSource ds, float amount) { // modify the damage if(ds != DamageSource.outOfWorld && ds != DamageSourceAR.dsFallOffShip) { if(ds instanceof EntityDamageSourceIndirect && (((EntityDamageSourceIndirect)ds).getEntity() instanceof EntityCryoArrow)) { amount *= 1.5F; } else { amount /= 2.0F; } } return super.attackEntityFrom(ds, amount); }
/** * Called when the entity is attacked. */ public boolean attackEntityFrom(DamageSource par1DamageSource, float par2) { if (this.isEntityInvulnerable()) { return false; } else { this.setScreaming(true); if (par1DamageSource instanceof EntityDamageSource && par1DamageSource.getEntity() instanceof EntityPlayer) { this.isAggressive = true; } if (par1DamageSource instanceof EntityDamageSourceIndirect) { this.isAggressive = false; for (int var3 = 0; var3 < 64; ++var3) { if (this.teleportRandomly()) { return true; } } return false; } else { return super.attackEntityFrom(par1DamageSource, par2); } } }
/** * Called when the entity is attacked. */ public boolean attackEntityFrom(DamageSource par1DamageSource, float par2) { if (this.isEntityInvulnerable()) { return false; } else { this.setScreaming(true); if (par1DamageSource instanceof EntityDamageSource && par1DamageSource.getEntity() instanceof EntityPlayer) { this.isAggressive = true; } if (par1DamageSource instanceof EntityDamageSourceIndirect) { this.isAggressive = false; for (int i = 0; i < 64; ++i) { if (this.teleportRandomly()) { return true; } } return super.attackEntityFrom(par1DamageSource, par2); } else { return super.attackEntityFrom(par1DamageSource, par2); } } }
public boolean attackEntityFrom(DamageSource par1DamageSource, float par2) { if (this.isEntityInvulnerable()) { return false; } else { this.setScreaming(true); if (par1DamageSource instanceof EntityDamageSource && par1DamageSource.getEntity() instanceof EntityPlayer) { this.isAggressive = true; } if (par1DamageSource instanceof EntityDamageSourceIndirect) { this.isAggressive = false; for (int i = 0; i < 64; ++i) { if (this.teleportRandomly()) { return true; } } return super.attackEntityFrom(par1DamageSource, par2); } else { return super.attackEntityFrom(par1DamageSource, par2); } } }
public boolean attackEntityFrom(DamageSource p_70097_1_, float p_70097_2_) { if (this.isEntityInvulnerable()) { return false; } else { this.setScreaming(true); if (p_70097_1_ instanceof EntityDamageSource && p_70097_1_.getEntity() instanceof EntityPlayer) { this.isAggressive = true; } if (p_70097_1_ instanceof EntityDamageSourceIndirect) { this.isAggressive = false; for (int i = 0; i < 64; ++i) { if (this.teleportRandomly()) { return true; } } return super.attackEntityFrom(p_70097_1_, p_70097_2_); } else { return super.attackEntityFrom(p_70097_1_, p_70097_2_); } } }
/** * Returns the damage source caused by this seed type */ public DamageSource getDamageSource() { switch(getType()) { case BOMB: return new DamageSourceBaseIndirect("slingshot", this, getThrower()).setExplosion().setProjectile(); case DEKU: return new DamageSourceBaseIndirect("slingshot", this, getThrower()).setStunDamage(80, 2, true).setProjectile(); case NETHERWART: return new EntityDamageSourceIndirect("slingshot", this, getThrower()).setFireDamage().setProjectile(); default: return new EntityDamageSourceIndirect("slingshot", this, getThrower()).setProjectile(); } }
/** * If cyclone inflicts damage, searches for entities within the area of effect and attacks them */ private void attackNearbyEntities() { if (getDamage() > 0.0F) { double d = Math.max(0.5D, getArea() - 1.0D); List<EntityLivingBase> entities = worldObj.getEntitiesWithinAABB(EntityLivingBase.class, getEntityBoundingBox().expand(d, d, d)); for (EntityLivingBase entity : entities) { if (affectedEntities.contains(entity.getEntityId()) || (entity == getThrower() && ticksExisted < 8)) { continue; } entity.attackEntityFrom(new EntityDamageSourceIndirect("tornado", this, getThrower()).setProjectile().setMagicDamage(), getDamage()); affectedEntities.add(entity.getEntityId()); } } }
@Override public boolean attackEntityFrom(DamageSource source, float amount) { if (isEntityInvulnerable(source)) { return false; } else { if (!worldObj.isRemote && getIsBatHanging()) { setIsBatHanging(false); } if (getShockTime() > 0) { if (source instanceof EntityDamageSourceIndirect) { if (source.isMagicDamage()) { return super.attackEntityFrom(source, amount); } else if (source.isExplosion()) { ZSSEntityInfo.get(this).stun(20 + rand.nextInt((int)(amount * 5) + 1)); setShockTime(0); } else if (source instanceof IDamageSourceStun) { setShockTime(0); } // Hack to prevent infinite loop when attacked by other electrified mobs (other keese, chus, etc) } else if (source instanceof EntityDamageSource && source.getEntity() instanceof EntityPlayer && !source.damageType.equals("thorns")) { boolean isWood = false; ItemStack stack = ((EntityPlayer) source.getEntity()).getHeldItem(); if (stack != null && stack.getItem() instanceof ItemTool) { isWood = ((ItemTool) stack.getItem()).getToolMaterial() == ToolMaterial.WOOD; } else if (stack != null && stack.getItem() instanceof ItemSword) { isWood = ((ItemSword) stack.getItem()).getToolMaterialName().equals(ToolMaterial.WOOD.toString()); } if (!isWood) { source.getEntity().attackEntityFrom(getDamageSource(), getDamage()); worldObj.playSoundAtEntity(this, Sounds.SHOCK, 1.0F, 1.0F / (rand.nextFloat() * 0.4F + 1.0F)); } } return false; } return super.attackEntityFrom(source, amount); } }
@Override public boolean attackEntityFrom(DamageSource source, float amount) { if (source == DamageSource.inWall) { return false; } else if (getShockTime() > 0) { if (source instanceof EntityDamageSourceIndirect) { if (source.isMagicDamage()) { return super.attackEntityFrom(source, amount); } else if (source.isExplosion()) { ZSSEntityInfo.get(this).stun(20 + rand.nextInt((int)(amount * 5) + 1)); setShockTime(0); } else if (source instanceof IDamageSourceStun) { setShockTime(0); } // Hack to prevent infinite loop when attacked by other electrified mobs (other chus, keese, etc) } else if (source instanceof EntityDamageSource && source.getEntity() instanceof EntityPlayer && !source.damageType.equals("thorns")) { boolean isWood = false; ItemStack stack = ((EntityPlayer) source.getEntity()).getHeldItem(); if (stack != null && stack.getItem() instanceof ItemTool) { isWood = ((ItemTool) stack.getItem()).getToolMaterial() == ToolMaterial.WOOD; } else if (stack != null && stack.getItem() instanceof ItemSword) { isWood = ((ItemSword) stack.getItem()).getToolMaterialName().equals(ToolMaterial.WOOD.toString()); } if (!isWood) { source.getEntity().attackEntityFrom(getDamageSource(), getAttackStrength()); worldObj.playSoundAtEntity(this, Sounds.SHOCK, 1.0F, 1.0F / (rand.nextFloat() * 0.4F + 1.0F)); } } return false; } return super.attackEntityFrom(source, amount); }
/** * Returns an explosion damage source with the thrower of the explosive, if * available, set as the indirect entity. */ public static DamageSource getExplosionSource(CustomExplosion explosion) { if (explosion.exploder instanceof EntityThrowable) { return new EntityDamageSourceIndirect("explosion", explosion.exploder, ((EntityThrowable) explosion.exploder).getThrower()).setExplosion().setDifficultyScaled(); } return DamageSource.setExplosionSource(explosion); }
/** * Called when the entity is attacked. */ @Override public boolean attackEntityFrom(DamageSource par1DamageSource, float par2) { if (this.isEntityInvulnerable()) { return false; } else { this.setScreaming(true); if (par1DamageSource instanceof EntityDamageSource && par1DamageSource.getEntity() instanceof EntityPlayer) { this.isAggressive = true; } if (par1DamageSource instanceof EntityDamageSourceIndirect) { this.isAggressive = false; for (int i = 0; i < 64; ++i) { if (this.teleportRandomly()) { return true; } } return super.attackEntityFrom(par1DamageSource, par2); } else { return super.attackEntityFrom(par1DamageSource, par2); } } }
/** * Called when the entity is attacked. */ public boolean attackEntityFrom(DamageSource source, float amount) { if (this.isEntityInvulnerable(source)) { return false; } else if (!this.worldObj.isRemote && !this.isDead) { if (this.riddenByEntity != null && this.riddenByEntity == source.getEntity() && source instanceof EntityDamageSourceIndirect) { return false; } else { this.setForwardDirection(-this.getForwardDirection()); this.setTimeSinceHit(10); this.setDamageTaken(this.getDamageTaken() + amount * 10.0F); this.setBeenAttacked(); boolean flag = source.getEntity() instanceof EntityPlayer && ((EntityPlayer)source.getEntity()).capabilities.isCreativeMode; if (flag || this.getDamageTaken() > 40.0F) { if (this.riddenByEntity != null) { this.riddenByEntity.mountEntity(this); } if (!flag && this.worldObj.getGameRules().getBoolean("doEntityDrops")) { this.dropItemWithOffset(Items.boat, 1, 0.0F); } this.setDead(); } return true; } } else { return true; } }
/** * Called when the entity is attacked. */ public boolean attackEntityFrom(DamageSource source, float amount) { if (this.isEntityInvulnerable(source)) { return false; } else { if (source.getEntity() == null || !(source.getEntity() instanceof EntityEndermite)) { if (!this.worldObj.isRemote) { this.setScreaming(true); } if (source instanceof EntityDamageSource && source.getEntity() instanceof EntityPlayer) { if (source.getEntity() instanceof EntityPlayerMP && ((EntityPlayerMP)source.getEntity()).theItemInWorldManager.isCreative()) { this.setScreaming(false); } else { this.isAggressive = true; } } if (source instanceof EntityDamageSourceIndirect) { this.isAggressive = false; for (int i = 0; i < 64; ++i) { if (this.teleportRandomly()) { return true; } } return false; } } boolean flag = super.attackEntityFrom(source, amount); if (source.isUnblockable() && this.rand.nextInt(10) != 0) { this.teleportRandomly(); } return flag; } }