Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexModGuy committed Apr 12, 2022
1 parent b3de531 commit 9ecb9f9
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
import net.minecraft.entity.EntityType;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.MobEntity;
import net.minecraft.entity.monster.IMob;
import net.minecraft.entity.monster.MonsterEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.projectile.AbstractArrowEntity;
import net.minecraft.inventory.EquipmentSlotType;
Expand Down Expand Up @@ -81,13 +83,17 @@ public void tick() {
if (target == null || !target.isAlive()) {
double d0 = 10;
List<Entity> list = world.getEntitiesInAABBexcluding(shootingEntity, (new AxisAlignedBB(this.getPosX(), this.getPosY(), this.getPosZ(), this.getPosX() + 1.0D, this.getPosY() + 1.0D, this.getPosZ() + 1.0D)).grow(d0, 10.0D, d0), EntityPredicates.IS_ALIVE);
LivingEntity closest = null;
if (!list.isEmpty()) {
for(Entity e : list){
if(e instanceof LivingEntity && !e.getUniqueID().equals(shootingEntity.getUniqueID())){
target = (LivingEntity) e;
if(e instanceof LivingEntity && !e.getUniqueID().equals(shootingEntity.getUniqueID()) && e instanceof IMob){
if (closest == null || closest.getDistance(shootingEntity) > e.getDistance(shootingEntity)) {
closest = (LivingEntity) e;
}
}
}
}
target = closest;
}
if (target != null && target.isAlive()) {
double minusX = target.getPosX() - this.getPosX();
Expand Down

0 comments on commit 9ecb9f9

Please sign in to comment.