Search in sources :

Example 11 with EntityMyPet

use of de.Keyle.MyPet.compat.v1_8_R3.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_R1.entity.EntityMyPet) EntityMyPet(de.Keyle.MyPet.compat.v1_8_R1.entity.EntityMyPet) MyPet(de.Keyle.MyPet.api.entity.MyPet) Behavior(de.Keyle.MyPet.skill.skills.Behavior)

Example 12 with EntityMyPet

use of de.Keyle.MyPet.compat.v1_8_R3.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 : CraftPlayer(org.bukkit.craftbukkit.v1_8_R1.entity.CraftPlayer) EntityPlayer(net.minecraft.server.v1_8_R1.EntityPlayer) Player(org.bukkit.entity.Player) EntityMyPet(de.Keyle.MyPet.compat.v1_8_R1.entity.EntityMyPet) EntityLiving(net.minecraft.server.v1_8_R1.EntityLiving) EntityMyPet(de.Keyle.MyPet.compat.v1_8_R1.entity.EntityMyPet) MyPet(de.Keyle.MyPet.api.entity.MyPet) EntityPlayer(net.minecraft.server.v1_8_R1.EntityPlayer) EntityTameableAnimal(net.minecraft.server.v1_8_R1.EntityTameableAnimal) EntityArmorStand(net.minecraft.server.v1_8_R1.EntityArmorStand) Behavior(de.Keyle.MyPet.skill.skills.Behavior)

Example 13 with EntityMyPet

use of de.Keyle.MyPet.compat.v1_8_R3.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 : 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.skill.skills.Behavior)

Example 14 with EntityMyPet

use of de.Keyle.MyPet.compat.v1_8_R3.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_8_R3.entity.EntityMyPet) MyPet(de.Keyle.MyPet.api.entity.MyPet) EntityMyPet(de.Keyle.MyPet.compat.v1_8_R3.entity.EntityMyPet) Behavior(de.Keyle.MyPet.skill.skills.Behavior)

Example 15 with EntityMyPet

use of de.Keyle.MyPet.compat.v1_8_R3.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 : Player(org.bukkit.entity.Player) CraftPlayer(org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer) EntityPlayer(net.minecraft.server.v1_8_R3.EntityPlayer) EntityMyPet(de.Keyle.MyPet.compat.v1_8_R3.entity.EntityMyPet) EntityLiving(net.minecraft.server.v1_8_R3.EntityLiving) MyPet(de.Keyle.MyPet.api.entity.MyPet) EntityMyPet(de.Keyle.MyPet.compat.v1_8_R3.entity.EntityMyPet) EntityPlayer(net.minecraft.server.v1_8_R3.EntityPlayer) EntityTameableAnimal(net.minecraft.server.v1_8_R3.EntityTameableAnimal) EntityArmorStand(net.minecraft.server.v1_8_R3.EntityArmorStand) Behavior(de.Keyle.MyPet.skill.skills.Behavior)

Aggregations

MyPet (de.Keyle.MyPet.api.entity.MyPet)18 Behavior (de.Keyle.MyPet.skill.skills.Behavior)18 Player (org.bukkit.entity.Player)9 EntityMyPet (de.Keyle.MyPet.compat.v1_10_R1.entity.EntityMyPet)2 EntityMyPet (de.Keyle.MyPet.compat.v1_11_R1.entity.EntityMyPet)2 EntityMyPet (de.Keyle.MyPet.compat.v1_12_R1.entity.EntityMyPet)2 EntityMyPet (de.Keyle.MyPet.compat.v1_7_R4.entity.EntityMyPet)2 EntityMyPet (de.Keyle.MyPet.compat.v1_8_R1.entity.EntityMyPet)2 EntityMyPet (de.Keyle.MyPet.compat.v1_8_R2.entity.EntityMyPet)2 EntityMyPet (de.Keyle.MyPet.compat.v1_8_R3.entity.EntityMyPet)2 EntityMyPet (de.Keyle.MyPet.compat.v1_9_R1.entity.EntityMyPet)2 EntityMyPet (de.Keyle.MyPet.compat.v1_9_R2.entity.EntityMyPet)2 EntityArmorStand (net.minecraft.server.v1_10_R1.EntityArmorStand)1 EntityLiving (net.minecraft.server.v1_10_R1.EntityLiving)1 EntityPlayer (net.minecraft.server.v1_10_R1.EntityPlayer)1 EntityTameableAnimal (net.minecraft.server.v1_10_R1.EntityTameableAnimal)1 EntityArmorStand (net.minecraft.server.v1_11_R1.EntityArmorStand)1 EntityLiving (net.minecraft.server.v1_11_R1.EntityLiving)1 EntityPlayer (net.minecraft.server.v1_11_R1.EntityPlayer)1 EntityTameableAnimal (net.minecraft.server.v1_11_R1.EntityTameableAnimal)1