use of de.Keyle.MyPet.api.skill.skills.Behavior in project MyPet by xXKeyleXx.
the class BehaviorAggressiveTarget method shouldFinish.
@Override
public boolean shouldFinish() {
if (!petEntity.canMove()) {
return true;
} else if (!this.petEntity.hasTarget()) {
return true;
}
net.minecraft.world.entity.LivingEntity target = ((CraftLivingEntity) petEntity.getMyPetTarget()).getHandle();
if (!target.isAlive()) {
return true;
}
Behavior behaviorSkill = myPet.getSkills().get(Behavior.class);
if (behaviorSkill.getBehavior() != BehaviorMode.Aggressive) {
return true;
} else if (myPet.getDamage() <= 0 && myPet.getRangedDamage() <= 0) {
return true;
} else if (target.level != petEntity.level) {
return true;
} else if (petEntity.distanceToSqr(target) > 400) {
return true;
} else
return petEntity.distanceToSqr(((CraftPlayer) petEntity.getOwner().getPlayer()).getHandle()) > 600;
}
Aggregations