Search in sources :

Example 46 with EntityMyPet

use of de.Keyle.MyPet.compat.v1_16_R1.entity.EntityMyPet in project MyPet by xXKeyleXx.

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((double) range, (double) range, (double) 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;
}
Also used : EntityMyPet(de.Keyle.MyPet.compat.v1_8_R3.entity.EntityMyPet) BehaviorImpl(de.Keyle.MyPet.skill.skills.BehaviorImpl) MyPet(de.Keyle.MyPet.api.entity.MyPet) EntityMyPet(de.Keyle.MyPet.compat.v1_8_R3.entity.EntityMyPet) Behavior(de.Keyle.MyPet.api.skill.skills.Behavior)

Example 47 with EntityMyPet

use of de.Keyle.MyPet.compat.v1_16_R1.entity.EntityMyPet in project MyPet by xXKeyleXx.

the class RangedAttack method shouldFinish.

@Override
public boolean shouldFinish() {
    if (!entityMyPet.hasTarget() || myPet.getRangedDamage() <= 0 || !entityMyPet.canMove()) {
        return true;
    }
    if (this.target.getBukkitEntity() != this.entityMyPet.getMyPetTarget()) {
        return true;
    }
    double meleeDamage = myPet.getDamage();
    if (meleeDamage > 0 && this.entityMyPet.f(target.locX, target.getBoundingBox().b, 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;
            }
            if (this.target instanceof EntityPlayer) {
                return true;
            }
        }
    }
    return false;
}
Also used : Ranged(de.Keyle.MyPet.api.skill.skills.Ranged) EntityMyPet(de.Keyle.MyPet.compat.v1_8_R3.entity.EntityMyPet) Behavior(de.Keyle.MyPet.api.skill.skills.Behavior)

Example 48 with EntityMyPet

use of de.Keyle.MyPet.compat.v1_16_R1.entity.EntityMyPet in project MyPet by xXKeyleXx.

the class MeleeAttack method shouldStart.

@Override
public boolean shouldStart() {
    if (myPet.getDamage() <= 0) {
        return false;
    }
    if (!this.petEntity.hasTarget()) {
        return false;
    }
    EntityLiving targetEntity = ((CraftLivingEntity) this.petEntity.getMyPetTarget()).getHandle();
    if (targetEntity instanceof EntityArmorStand) {
        return false;
    }
    if (petEntity.getMyPet().getRangedDamage() > 0 && this.petEntity.e(targetEntity.locX, targetEntity.getBoundingBox().b, targetEntity.locZ) >= 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 EntityTameableAnimal && ((EntityTameableAnimal) targetEntity).isTamed()) {
                return false;
            }
            if (targetEntity instanceof EntityMyPet) {
                return false;
            }
            if (targetEntity instanceof EntityPlayer) {
                return false;
            }
        }
    }
    this.targetEntity = targetEntity;
    return true;
}
Also used : EntityMyPet(de.Keyle.MyPet.compat.v1_12_R1.entity.EntityMyPet) CraftLivingEntity(org.bukkit.craftbukkit.v1_12_R1.entity.CraftLivingEntity) Behavior(de.Keyle.MyPet.api.skill.skills.Behavior)

Example 49 with EntityMyPet

use of de.Keyle.MyPet.compat.v1_16_R1.entity.EntityMyPet 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((double) this.range, 4.0D, (double) 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;
}
Also used : Player(org.bukkit.entity.Player) EntityPlayer(net.minecraft.server.v1_12_R1.EntityPlayer) CraftPlayer(org.bukkit.craftbukkit.v1_12_R1.entity.CraftPlayer) EntityMyPet(de.Keyle.MyPet.compat.v1_12_R1.entity.EntityMyPet) EntityLiving(net.minecraft.server.v1_12_R1.EntityLiving) MyPet(de.Keyle.MyPet.api.entity.MyPet) EntityMyPet(de.Keyle.MyPet.compat.v1_12_R1.entity.EntityMyPet) EntityPlayer(net.minecraft.server.v1_12_R1.EntityPlayer) EntityTameableAnimal(net.minecraft.server.v1_12_R1.EntityTameableAnimal) EntityArmorStand(net.minecraft.server.v1_12_R1.EntityArmorStand) Behavior(de.Keyle.MyPet.api.skill.skills.Behavior)

Example 50 with EntityMyPet

use of de.Keyle.MyPet.compat.v1_16_R1.entity.EntityMyPet in project MyPet by xXKeyleXx.

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.e(target.locX, target.getBoundingBox().b, 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;
            }
            if (this.target instanceof EntityPlayer) {
                return true;
            }
        }
    }
    return false;
}
Also used : Ranged(de.Keyle.MyPet.api.skill.skills.Ranged) EntityMyPet(de.Keyle.MyPet.compat.v1_12_R1.entity.EntityMyPet) Behavior(de.Keyle.MyPet.api.skill.skills.Behavior)

Aggregations

Behavior (de.Keyle.MyPet.api.skill.skills.Behavior)43 MyPet (de.Keyle.MyPet.api.entity.MyPet)35 Player (org.bukkit.entity.Player)22 Ranged (de.Keyle.MyPet.api.skill.skills.Ranged)14 Behavior (de.Keyle.MyPet.skill.skills.Behavior)12 ServerPlayer (net.minecraft.server.level.ServerPlayer)12 TamableAnimal (net.minecraft.world.entity.TamableAnimal)12 ArmorStand (net.minecraft.world.entity.decoration.ArmorStand)10 EntityMyPet (de.Keyle.MyPet.compat.v1_17_R1.entity.EntityMyPet)9 EntityMyPet (de.Keyle.MyPet.compat.v1_18_R1.entity.EntityMyPet)7 BehaviorImpl (de.Keyle.MyPet.skill.skills.BehaviorImpl)7 EntityMyPet (de.Keyle.MyPet.compat.v1_12_R1.entity.EntityMyPet)6 EntityMyPet (de.Keyle.MyPet.compat.v1_16_R1.entity.EntityMyPet)6 EntityMyPet (de.Keyle.MyPet.compat.v1_16_R3.entity.EntityMyPet)6 EntityMyPet (de.Keyle.MyPet.compat.v1_8_R3.entity.EntityMyPet)6 EntityMyPet (de.Keyle.MyPet.compat.v1_9_R2.entity.EntityMyPet)6 Method (java.lang.reflect.Method)4 InvocationTargetException (java.lang.reflect.InvocationTargetException)3 CraftPlayer (org.bukkit.craftbukkit.v1_17_R1.entity.CraftPlayer)3 EntityMyPet (de.Keyle.MyPet.compat.v1_10_R1.entity.EntityMyPet)2