use of de.Keyle.MyPet.compat.v1_16_R1.entity.EntityMyPet in project MyPet by MyPetORG.
the class BehaviorDuelTarget method shouldStart.
@Override
public boolean shouldStart() {
Behavior behaviorSkill = myPet.getSkills().get(Behavior.class);
if (!behaviorSkill.isActive() || behaviorSkill.getBehavior() != BehaviorMode.Duel) {
return false;
}
if (myPet.getDamage() <= 0 && myPet.getRangedDamage() <= 0) {
return false;
}
if (!petEntity.canMove()) {
return false;
}
if (petEntity.hasTarget()) {
return false;
}
if (duelOpponent != null) {
this.target = duelOpponent;
return true;
}
for (EntityMyPet entityMyPet : this.petEntity.world.a(EntityMyPet.class, this.petOwnerEntity.getBoundingBox().grow(range, range, range))) {
MyPet targetMyPet = entityMyPet.getMyPet();
if (entityMyPet != petEntity && entityMyPet.isAlive()) {
if (!targetMyPet.getSkills().isActive(BehaviorImpl.class) || !targetMyPet.getEntity().get().canMove()) {
continue;
}
BehaviorImpl targetbehavior = targetMyPet.getSkills().get(BehaviorImpl.class);
if (targetbehavior.getBehavior() != BehaviorMode.Duel) {
continue;
}
if (targetMyPet.getDamage() == 0) {
continue;
}
this.target = entityMyPet;
return true;
}
}
return false;
}
use of de.Keyle.MyPet.compat.v1_16_R1.entity.EntityMyPet in project MyPet by MyPetORG.
the class RangedAttack method shouldFinish.
@Override
public boolean shouldFinish() {
if (!entityMyPet.hasTarget() || myPet.getRangedDamage() <= 0 || !entityMyPet.canMove()) {
return true;
}
if (this.target.getBukkitEntity() != entityMyPet.getMyPetTarget()) {
return true;
}
double meleeDamage = myPet.getDamage();
if (meleeDamage > 0 && this.entityMyPet.h(target.locX(), this.target.getBoundingBox().minY, target.locZ()) < 4) {
Ranged rangedSkill = myPet.getSkills().get(Ranged.class);
if (meleeDamage > rangedSkill.getDamage().getValue().doubleValue()) {
return true;
}
}
Behavior behaviorSkill = myPet.getSkills().get(Behavior.class);
if (behaviorSkill != null && behaviorSkill.isActive()) {
if (behaviorSkill.getBehavior() == Behavior.BehaviorMode.Friendly) {
return true;
}
if (behaviorSkill.getBehavior() == Behavior.BehaviorMode.Raid) {
if (this.target instanceof EntityTameableAnimal && ((EntityTameableAnimal) this.target).isTamed()) {
return true;
}
if (this.target instanceof EntityMyPet) {
return true;
}
return this.target instanceof EntityPlayer;
}
}
return false;
}
use of de.Keyle.MyPet.compat.v1_16_R1.entity.EntityMyPet in project MyPet by MyPetORG.
the class MeleeAttack method shouldStart.
@Override
public boolean shouldStart() {
if (myPet.getDamage() <= 0) {
return false;
}
if (!this.petEntity.hasTarget()) {
return false;
}
net.minecraft.world.entity.LivingEntity targetEntity = ((CraftLivingEntity) this.petEntity.getMyPetTarget()).getHandle();
if (targetEntity instanceof ArmorStand) {
return false;
}
if (petEntity.getMyPet().getRangedDamage() > 0 && this.petEntity.distanceToSqr(targetEntity.getX(), targetEntity.getBoundingBox().minY, targetEntity.getZ()) >= 20) {
return false;
}
Behavior behaviorSkill = myPet.getSkills().get(Behavior.class);
if (behaviorSkill != null && behaviorSkill.isActive()) {
if (behaviorSkill.getBehavior() == Behavior.BehaviorMode.Friendly) {
return false;
}
if (behaviorSkill.getBehavior() == Behavior.BehaviorMode.Raid) {
if (targetEntity instanceof TamableAnimal && ((TamableAnimal) targetEntity).isTame()) {
return false;
}
if (targetEntity instanceof EntityMyPet) {
return false;
}
if (targetEntity instanceof ServerPlayer) {
return false;
}
}
}
this.targetEntity = targetEntity;
return true;
}
use of de.Keyle.MyPet.compat.v1_16_R1.entity.EntityMyPet in project MyPet by MyPetORG.
the class RangedAttack method shouldStart.
@Override
public boolean shouldStart() {
if (myPet.getRangedDamage() <= 0) {
return false;
}
if (!entityMyPet.canMove()) {
return false;
}
if (!entityMyPet.hasTarget()) {
return false;
}
LivingEntity target = ((CraftLivingEntity) this.entityMyPet.getMyPetTarget()).getHandle();
if (target instanceof ArmorStand) {
return false;
}
double meleeDamage = myPet.getDamage();
if (meleeDamage > 0 && this.entityMyPet.distanceToSqr(target.getX(), target.getBoundingBox().minY, target.getZ()) < 4) {
Ranged rangedSkill = myPet.getSkills().get(Ranged.class);
if (meleeDamage > rangedSkill.getDamage().getValue().doubleValue()) {
return false;
}
}
Behavior behaviorSkill = myPet.getSkills().get(Behavior.class);
if (behaviorSkill != null && behaviorSkill.isActive()) {
if (behaviorSkill.getBehavior() == Behavior.BehaviorMode.Friendly) {
return false;
}
if (behaviorSkill.getBehavior() == Behavior.BehaviorMode.Raid) {
if (target instanceof TamableAnimal && ((TamableAnimal) target).isTame()) {
return false;
}
if (target instanceof EntityMyPet) {
return false;
}
if (target instanceof ServerPlayer) {
return false;
}
}
}
this.target = target;
return true;
}
use of de.Keyle.MyPet.compat.v1_16_R1.entity.EntityMyPet in project MyPet by MyPetORG.
the class RangedAttack method shouldFinish.
@Override
public boolean shouldFinish() {
if (!entityMyPet.hasTarget() || myPet.getRangedDamage() <= 0 || !entityMyPet.canMove()) {
return true;
}
if (this.target.getBukkitEntity() != entityMyPet.getMyPetTarget()) {
return true;
}
double meleeDamage = myPet.getDamage();
if (meleeDamage > 0 && this.entityMyPet.distanceToSqr(target.getX(), this.target.getBoundingBox().minY, target.getZ()) < 4) {
Ranged rangedSkill = myPet.getSkills().get(Ranged.class);
if (meleeDamage > rangedSkill.getDamage().getValue().doubleValue()) {
return true;
}
}
Behavior behaviorSkill = myPet.getSkills().get(Behavior.class);
if (behaviorSkill != null && behaviorSkill.isActive()) {
if (behaviorSkill.getBehavior() == Behavior.BehaviorMode.Friendly) {
return true;
}
if (behaviorSkill.getBehavior() == Behavior.BehaviorMode.Raid) {
if (this.target instanceof TamableAnimal && ((TamableAnimal) this.target).isTame()) {
return true;
}
if (this.target instanceof EntityMyPet) {
return true;
}
return this.target instanceof ServerPlayer;
}
}
return false;
}
Aggregations