FANDOM


This Entity AI class instantiates attacking the nearest mob that is "applicable":

public boolean isEntityApplicable(Entity p_82704_1_)
{
return !(p_82704_1_ instanceof EntityLivingBase) ? false : (p_i1665_6_ != null && !p_i1665_6_.isEntityApplicable(p_82704_1_) ? false : EntityAINearestAttackableTarget.this.isSuitableTarget((EntityLivingBase)p_82704_1_, false));
}

Finding closest entity Edit

This class finds the closest entity by using the Entity class's getDistanceSqToEntity method, then using a simple method in the subclass Sorter:

           public int compare(Entity p_compare_1_, Entity p_compare_2_)
           {
               double d0 = this.theEntity.getDistanceSqToEntity(p_compare_1_);
               double d1 = this.theEntity.getDistanceSqToEntity(p_compare_2_);
               return d0 < d1 ? -1 : (d0 > d1 ? 1 : 0);
           }

           public int compare(Object p_compare_1_, Object p_compare_2_)
           {
               return this.compare((Entity)p_compare_1_, (Entity)p_compare_2_);
           }

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.