Search in sources :

Example 1 with EntityMyPet

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

the class BehaviorDuelTarget method shouldStart.

@Override
public boolean shouldStart() {
    if (behaviorSkill == null || !behaviorSkill.isActive() || behaviorSkill.getBehavior() != BehaviorState.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 (Object entityObj : this.petEntity.world.a(EntityMyPet.class, this.petOwnerEntity.boundingBox.grow((double) range, (double) range, (double) range))) {
        EntityMyPet entityMyPet = (EntityMyPet) entityObj;
        MyPet targetMyPet = entityMyPet.getMyPet();
        if (entityMyPet != petEntity && entityMyPet.isAlive()) {
            if (!targetMyPet.getSkills().isSkillActive(Behavior.class) || !targetMyPet.getEntity().get().canMove()) {
                continue;
            }
            Behavior targetbehavior = targetMyPet.getSkills().getSkill(Behavior.class).get();
            if (targetbehavior.getBehavior() != BehaviorState.Duel) {
                continue;
            }
            if (targetMyPet.getDamage() == 0) {
                continue;
            }
            this.target = entityMyPet;
            return true;
        }
    }
    return false;
}
Also used : EntityMyPet(de.Keyle.MyPet.compat.v1_7_R4.entity.EntityMyPet) MyPet(de.Keyle.MyPet.api.entity.MyPet) EntityMyPet(de.Keyle.MyPet.compat.v1_7_R4.entity.EntityMyPet) Behavior(de.Keyle.MyPet.skill.skills.Behavior)

Example 2 with EntityMyPet

use of de.Keyle.MyPet.compat.v1_18_R2.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 = null;
        if (myPet.getSkills().isSkillActive(Behavior.class)) {
            behaviorSkill = myPet.getSkills().getSkill(Behavior.class).get();
            if (behaviorSkill.getBehavior() == Behavior.BehaviorState.Friendly) {
                return false;
            }
        }
        for (Object entityObj : this.petEntity.world.a(EntityLiving.class, this.petEntity.boundingBox.grow((double) this.range, 4.0D, (double) this.range))) {
            EntityLiving entityLiving = (EntityLiving) entityObj;
            if (entityLiving != petEntity) {
                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() == BehaviorState.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 : EntityPlayer(net.minecraft.server.v1_7_R4.EntityPlayer) CraftPlayer(org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer) Player(org.bukkit.entity.Player) EntityMyPet(de.Keyle.MyPet.compat.v1_7_R4.entity.EntityMyPet) EntityLiving(net.minecraft.server.v1_7_R4.EntityLiving) MyPet(de.Keyle.MyPet.api.entity.MyPet) EntityMyPet(de.Keyle.MyPet.compat.v1_7_R4.entity.EntityMyPet) EntityPlayer(net.minecraft.server.v1_7_R4.EntityPlayer) EntityTameableAnimal(net.minecraft.server.v1_7_R4.EntityTameableAnimal) Behavior(de.Keyle.MyPet.skill.skills.Behavior)

Example 3 with EntityMyPet

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

the class BehaviorDuelTarget method shouldStart.

@Override
public boolean shouldStart() {
    if (behaviorSkill == null || !behaviorSkill.isActive() || behaviorSkill.getBehavior() != BehaviorState.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 (Object entityObj : this.petEntity.world.a(EntityMyPet.class, this.petOwnerEntity.getBoundingBox().grow((double) range, (double) range, (double) range))) {
        EntityMyPet entityMyPet = (EntityMyPet) entityObj;
        MyPet targetMyPet = entityMyPet.getMyPet();
        if (entityMyPet != petEntity && entityMyPet.isAlive()) {
            if (!targetMyPet.getSkills().isSkillActive(Behavior.class) || !entityMyPet.canMove()) {
                continue;
            }
            Behavior targetbehavior = targetMyPet.getSkills().getSkill(Behavior.class).get();
            if (targetbehavior.getBehavior() != BehaviorState.Duel) {
                continue;
            }
            if (targetMyPet.getDamage() == 0) {
                continue;
            }
            this.target = entityMyPet;
            return true;
        }
    }
    return false;
}
Also used : EntityMyPet(de.Keyle.MyPet.compat.v1_8_R2.entity.EntityMyPet) MyPet(de.Keyle.MyPet.api.entity.MyPet) EntityMyPet(de.Keyle.MyPet.compat.v1_8_R2.entity.EntityMyPet) Behavior(de.Keyle.MyPet.skill.skills.Behavior)

Example 4 with EntityMyPet

use of de.Keyle.MyPet.compat.v1_18_R2.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 = null;
        if (myPet.getSkills().isSkillActive(Behavior.class)) {
            behaviorSkill = myPet.getSkills().getSkill(Behavior.class).get();
            if (behaviorSkill.getBehavior() == Behavior.BehaviorState.Friendly) {
                return false;
            }
        }
        for (Object entityObj : this.petEntity.world.a(EntityLiving.class, this.petEntity.getBoundingBox().grow((double) this.range, 4.0D, (double) this.range))) {
            EntityLiving entityLiving = (EntityLiving) entityObj;
            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() == BehaviorState.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 : EntityPlayer(net.minecraft.server.v1_8_R2.EntityPlayer) Player(org.bukkit.entity.Player) CraftPlayer(org.bukkit.craftbukkit.v1_8_R2.entity.CraftPlayer) EntityMyPet(de.Keyle.MyPet.compat.v1_8_R2.entity.EntityMyPet) EntityLiving(net.minecraft.server.v1_8_R2.EntityLiving) MyPet(de.Keyle.MyPet.api.entity.MyPet) EntityMyPet(de.Keyle.MyPet.compat.v1_8_R2.entity.EntityMyPet) EntityPlayer(net.minecraft.server.v1_8_R2.EntityPlayer) EntityTameableAnimal(net.minecraft.server.v1_8_R2.EntityTameableAnimal) EntityArmorStand(net.minecraft.server.v1_8_R2.EntityArmorStand) Behavior(de.Keyle.MyPet.skill.skills.Behavior)

Example 5 with EntityMyPet

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

the class BehaviorDuelTarget method shouldStart.

@Override
public boolean shouldStart() {
    if (behaviorSkill == null || !behaviorSkill.isActive() || behaviorSkill.getBehavior() != BehaviorState.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 (Object entityObj : this.petEntity.world.a(EntityMyPet.class, this.petOwnerEntity.getBoundingBox().grow((double) range, (double) range, (double) range))) {
        EntityMyPet entityMyPet = (EntityMyPet) entityObj;
        MyPet targetMyPet = entityMyPet.getMyPet();
        if (entityMyPet != petEntity && entityMyPet.isAlive()) {
            if (!targetMyPet.getSkills().isSkillActive(Behavior.class) || !targetMyPet.getEntity().get().canMove()) {
                continue;
            }
            Behavior targetbehavior = targetMyPet.getSkills().getSkill(Behavior.class).get();
            if (targetbehavior.getBehavior() != BehaviorState.Duel) {
                continue;
            }
            if (targetMyPet.getDamage() == 0) {
                continue;
            }
            this.target = entityMyPet;
            return true;
        }
    }
    return false;
}
Also used : EntityMyPet(de.Keyle.MyPet.compat.v1_10_R1.entity.EntityMyPet) MyPet(de.Keyle.MyPet.api.entity.MyPet) EntityMyPet(de.Keyle.MyPet.compat.v1_10_R1.entity.EntityMyPet) Behavior(de.Keyle.MyPet.skill.skills.Behavior)

Aggregations

Behavior (de.Keyle.MyPet.api.skill.skills.Behavior)92 MyPet (de.Keyle.MyPet.api.entity.MyPet)61 Player (org.bukkit.entity.Player)40 Ranged (de.Keyle.MyPet.api.skill.skills.Ranged)30 ServerPlayer (net.minecraft.server.level.ServerPlayer)29 TamableAnimal (net.minecraft.world.entity.TamableAnimal)29 ArmorStand (net.minecraft.world.entity.decoration.ArmorStand)24 EntityMyPet (de.Keyle.MyPet.compat.v1_17_R1.entity.EntityMyPet)18 BehaviorImpl (de.Keyle.MyPet.skill.skills.BehaviorImpl)15 EntityMyPet (de.Keyle.MyPet.compat.v1_18_R1.entity.EntityMyPet)14 EntityMyPet (de.Keyle.MyPet.compat.v1_12_R1.entity.EntityMyPet)12 EntityMyPet (de.Keyle.MyPet.compat.v1_16_R1.entity.EntityMyPet)12 EntityMyPet (de.Keyle.MyPet.compat.v1_16_R3.entity.EntityMyPet)12 EntityMyPet (de.Keyle.MyPet.compat.v1_8_R3.entity.EntityMyPet)12 EntityMyPet (de.Keyle.MyPet.compat.v1_9_R2.entity.EntityMyPet)12 Behavior (de.Keyle.MyPet.skill.skills.Behavior)12 Method (java.lang.reflect.Method)8 EntityMyPet (de.Keyle.MyPet.compat.v1_18_R2.entity.EntityMyPet)7 InvocationTargetException (java.lang.reflect.InvocationTargetException)6 CraftPlayer (org.bukkit.craftbukkit.v1_17_R1.entity.CraftPlayer)6