public EntityAIFindEntityNearestSkins(EntityLiving entityLivingIn) { this.taskOwner = entityLivingIn; if (entityLivingIn instanceof EntityCreature) { LOGGER.warn("Use NearestAttackableTargetGoal.class for PathfinderMob mobs!"); } this.predicate = p_apply_1_ -> { if (!(p_apply_1_ instanceof EntityArmyMember)) { return false; } else if (p_apply_1_.getIsInvulnerable()) { return false; } else { double maxTargetRange = EntityAIFindEntityNearestSkins.this.maxTargetRange(); return !((double) p_apply_1_.getDistanceToEntity(EntityAIFindEntityNearestSkins.this.taskOwner) > maxTargetRange) && (EntityAITarget.isSuitableTarget(EntityAIFindEntityNearestSkins.this.taskOwner, (EntityLivingBase) p_apply_1_, false, true) && CAN_ATTACK_ARMY_MEMBER.test((EntityArmyMember) p_apply_1_)); } }; this.sorter = new EntityAINearestAttackableTarget.Sorter(entityLivingIn); }
public boolean isEntityValidToAttack(EntityMinionWarrior minion, EntityLivingBase entity) { if(entity == minion || entity == minion.getRidingEntity() || !EntityAITarget.isSuitableTarget(minion, entity, false, false) || entity.getClass() == EntityCreeper.class) return false; if (entity instanceof EntityMob && (getTargetBehavior() == EnumCombatBehaviors.TARGET_HOSTILE_MOBS || getTargetBehavior() == EnumCombatBehaviors.TARGET_PASSIVE_OR_HOSTILE_MOBS)) { return true; } else if (entity instanceof EntityAnimal && (getTargetBehavior() == EnumCombatBehaviors.TARGET_PASSIVE_MOBS || getTargetBehavior() == EnumCombatBehaviors.TARGET_PASSIVE_OR_HOSTILE_MOBS)) { return true; } else { return false; } }
public EntityAIFindOtherSlimeNearest(final EntitySlime mobIn) { super(mobIn, EntitySlime.class); this.slime = mobIn; Predicate<EntityLivingBase> predicate = entity -> { double range = EntityAIFindOtherSlimeNearest.this.getFollowRange(); return entity != null && entity != mobIn && entity.getClass() == mobIn.getClass() && entity.ticksExisted > AGE_LIMIT && !entity.isInvisible() && entity.getDistance(mobIn) <= range && ((EntitySlime) entity).getSlimeSize() == mobIn.getSlimeSize() && EntityAITarget.isSuitableTarget(mobIn, entity, false, true); }; try { predicateField.set(this, predicate); } catch (IllegalAccessException e) { throw new ReportedException(new CrashReport("Could not set private field '" + predicateField.getName() + "'", e)); } }
@Override public void updateTask() { EntityLivingBase target=this.host.getAttackTarget(); World world=this.host.world; this.host.getLookHelper().setLookPositionWithEntity(target, 30F, 90F); if(attackDuration<20){ this.host.getNavigator().tryMoveToEntityLiving(target, 1f); } if(--this.attackDuration<=0){ this.host.swingArm(EnumHand.MAIN_HAND); if(this.attacksMade>0&&this.attacksMade%13==0){ this.host.setBombSpell(true); this.host.bombDuration=200; BlockPos pos = this.host.world.getTopSolidOrLiquidBlock(this.host.getPosition()); this.host.topBlock=pos.getY()+7+this.host.rand.nextInt(3); this.attackDuration=200; } else if(this.attacksMade%2==0){ this.attackDuration=20-this.host.level/4; if(this.host.getDistanceSqToEntity(target)<6){ if(this.host.attackEntityAsMob(target)){ target.knockBack(this.host, (float)1.5f, (double)MathHelper.sin(this.host.rotationYaw * 0.017453292F), (double)(-MathHelper.cos(this.host.rotationYaw * 0.017453292F))); } } else{ ((ItemProjectileWeapon) this.host.getHeldItemMainhand().getItem()).shoot( this.host.getHeldItemMainhand(), this.host, world, 0, EnumHand.MAIN_HAND); } } else{ this.attackDuration=(int) (55/(0.92+this.host.level*0.08f)); this.host.getNavigator().clearPathEntity(); this.host.playSound(TF2Sounds.MOB_MERASMUS_SPELL, 2F, 1F); boolean attacked=false; for(EntityLivingBase living:world.getEntitiesWithinAABB(EntityLivingBase.class, this.host.getEntityBoundingBox().grow(12, 5, 12), new Predicate<EntityLivingBase>(){ @Override public boolean apply(EntityLivingBase input) { // TODO Auto-generated method stub return input.getDistanceSqToEntity(host)<144&&!TF2Util.isOnSameTeam(host, input)&&EntityAITarget.isSuitableTarget(host, input, false, false); } })){ living.attackEntityFrom(new EntityDamageSource("magicm",this.host).setMagicDamage().setDifficultyScaled(), 6); living.addVelocity(0, 1.25, 0); living.fallDistance=-10; attacked=true; } if(!attacked) this.host.teleportCooldown-=20; } this.attacksMade++; } }
public boolean isEntityValidToAttack(EntityBombomb bombomb, EntityLivingBase entity) { if(entity == bombomb || entity == bombomb.getRidingEntity() || !EntityAITarget.isSuitableTarget(bombomb, entity, false, false) || entity.getClass() == EntityCreeper.class) return false; return true; }