use of net.minecraft.server.v1_16_R2.EntityLiving in project MyPet by xXKeyleXx.
the class BehaviorAggressiveTarget method shouldFinish.
@Override
public boolean shouldFinish() {
if (!petEntity.canMove()) {
return true;
} else if (petEntity.getMyPetTarget() == null) {
return true;
}
EntityLiving 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.world != petEntity.world) {
return true;
} else if (petEntity.h(target) > 400) {
return true;
} else if (petEntity.h(((CraftPlayer) petEntity.getOwner().getPlayer()).getHandle()) > 600) {
return true;
}
return false;
}
use of net.minecraft.server.v1_16_R2.EntityLiving in project MyPet by xXKeyleXx.
the class BehaviorFarmTarget method shouldFinish.
@Override
public boolean shouldFinish() {
if (!petEntity.canMove()) {
return true;
}
if (!this.petEntity.hasTarget()) {
return true;
}
EntityLiving target = ((CraftLivingEntity) this.petEntity.getMyPetTarget()).getHandle();
if (!target.isAlive()) {
return true;
}
Behavior behaviorSkill = myPet.getSkills().get(Behavior.class);
if (behaviorSkill.getBehavior() != BehaviorMode.Farm) {
return true;
} else if (myPet.getDamage() <= 0 && myPet.getRangedDamage() <= 0) {
return true;
} else if (target.world != petEntity.world) {
return true;
} else if (petEntity.h(target) > 400) {
return true;
} else if (petEntity.h(((CraftPlayer) petEntity.getOwner().getPlayer()).getHandle()) > 600) {
return true;
}
return false;
}
use of net.minecraft.server.v1_16_R2.EntityLiving in project MyPet by xXKeyleXx.
the class Sprint method shouldStart.
@Override
public boolean shouldStart() {
if (!myPet.getSkills().isActive(SprintImpl.class)) {
return false;
}
if (petEntity.getMyPet().getDamage() <= 0) {
return false;
}
if (!this.petEntity.hasTarget()) {
return false;
}
EntityLiving targetEntity = ((CraftLivingEntity) this.petEntity.getMyPetTarget()).getHandle();
if (!targetEntity.isAlive()) {
return false;
}
if (lastTarget == targetEntity) {
return false;
}
if (petEntity.getMyPet().getRangedDamage() > 0 && this.petEntity.h(targetEntity) >= 16) {
return false;
}
this.lastTarget = targetEntity;
return true;
}
use of net.minecraft.server.v1_16_R2.EntityLiving in project MyPet by xXKeyleXx.
the class BehaviorAggressiveTarget method shouldFinish.
@Override
public boolean shouldFinish() {
if (!petEntity.canMove()) {
return true;
} else if (petEntity.getMyPetTarget() == null) {
return true;
}
EntityLiving 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.world != petEntity.world) {
return true;
} else if (petEntity.h(target) > 400) {
return true;
} else
return petEntity.h(((CraftPlayer) petEntity.getOwner().getPlayer()).getHandle()) > 600;
}
use of net.minecraft.server.v1_16_R2.EntityLiving in project MyPet by xXKeyleXx.
the class ControlTarget method shouldStart.
@Override
public boolean shouldStart() {
if (controlPathfinderGoal == null) {
if (petEntity.getPathfinder().hasGoal("Control")) {
controlPathfinderGoal = (Control) petEntity.getPathfinder().getGoal("Control");
}
}
if (controlPathfinderGoal == null) {
return false;
}
if (myPet.getDamage() <= 0 && myPet.getRangedDamage() <= 0) {
return false;
}
if (controlPathfinderGoal.moveTo != null && petEntity.canMove()) {
Behavior behaviorSkill = myPet.getSkills().get(Behavior.class);
if (behaviorSkill.isActive()) {
if (behaviorSkill.getBehavior() == BehaviorMode.Friendly) {
return false;
}
}
for (EntityLiving entityLiving : this.petEntity.world.a(EntityLiving.class, this.petEntity.getBoundingBox().grow(this.range, 4.0D, this.range))) {
if (entityLiving != petEntity && !(entityLiving instanceof EntityArmorStand)) {
if (entityLiving instanceof EntityPlayer) {
Player targetPlayer = (Player) entityLiving.getBukkitEntity();
if (myPet.getOwner().equals(targetPlayer)) {
continue;
} else if (!MyPetApi.getHookHelper().canHurt(myPet.getOwner().getPlayer(), targetPlayer, true)) {
continue;
}
} else if (entityLiving instanceof EntityTameableAnimal) {
EntityTameableAnimal tameable = (EntityTameableAnimal) entityLiving;
if (tameable.isTamed() && tameable.getOwner() != null) {
Player tameableOwner = (Player) tameable.getOwner().getBukkitEntity();
if (myPet.getOwner().equals(tameableOwner)) {
continue;
} else if (!MyPetApi.getHookHelper().canHurt(myPet.getOwner().getPlayer(), tameableOwner, true)) {
continue;
}
}
} else if (entityLiving instanceof EntityMyPet) {
MyPet targetMyPet = ((EntityMyPet) entityLiving).getMyPet();
if (!MyPetApi.getHookHelper().canHurt(myPet.getOwner().getPlayer(), targetMyPet.getOwner().getPlayer(), true)) {
continue;
}
}
if (!MyPetApi.getHookHelper().canHurt(myPet.getOwner().getPlayer(), entityLiving.getBukkitEntity())) {
continue;
}
if (behaviorSkill != null) {
if (behaviorSkill.getBehavior() == BehaviorMode.Raid) {
if (entityLiving instanceof EntityTameableAnimal) {
continue;
} else if (entityLiving instanceof EntityMyPet) {
continue;
} else if (entityLiving instanceof EntityPlayer) {
continue;
}
}
}
controlPathfinderGoal.stopControl();
this.target = entityLiving;
return true;
}
}
}
return false;
}
Aggregations