Search in sources :

Example 16 with EntityTameableAnimal

use of net.minecraft.server.v1_7_R4.EntityTameableAnimal 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) 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.api.skill.skills.Behavior)

Example 17 with EntityTameableAnimal

use of net.minecraft.server.v1_7_R4.EntityTameableAnimal in project MyPet by xXKeyleXx.

the class OwnerHurtByTarget method shouldStart.

@Override
public boolean shouldStart() {
    if (!petEntity.canMove()) {
        return false;
    }
    if (myPet.getDamage() <= 0 && myPet.getRangedDamage() <= 0) {
        return false;
    }
    this.lastDamager = owner.getLastDamager();
    if (this.lastDamager == null || !lastDamager.isAlive()) {
        return false;
    }
    if (lastDamager instanceof EntityArmorStand) {
        return false;
    }
    if (lastDamager == petEntity) {
        return false;
    }
    if (lastDamager instanceof EntityPlayer) {
        if (owner == lastDamager) {
            return false;
        }
        Player targetPlayer = (Player) lastDamager.getBukkitEntity();
        if (!MyPetApi.getHookHelper().canHurt(myPet.getOwner().getPlayer(), targetPlayer, true)) {
            return false;
        }
    } else if (lastDamager instanceof EntityMyPet) {
        MyPet targetMyPet = ((EntityMyPet) lastDamager).getMyPet();
        if (!MyPetApi.getHookHelper().canHurt(myPet.getOwner().getPlayer(), targetMyPet.getOwner().getPlayer(), true)) {
            return false;
        }
    } else if (lastDamager instanceof EntityTameableAnimal) {
        EntityTameableAnimal tameable = (EntityTameableAnimal) lastDamager;
        if (tameable.isTamed() && tameable.getOwner() != null) {
            Player tameableOwner = (Player) tameable.getOwner().getBukkitEntity();
            if (myPet.getOwner().equals(tameableOwner)) {
                return false;
            }
        }
    }
    if (!MyPetApi.getHookHelper().canHurt(myPet.getOwner().getPlayer(), lastDamager.getBukkitEntity())) {
        return false;
    }
    Behavior behaviorSkill = myPet.getSkills().get(Behavior.class);
    if (behaviorSkill != null && behaviorSkill.isActive()) {
        if (behaviorSkill.getBehavior() == BehaviorMode.Friendly) {
            return false;
        }
        if (behaviorSkill.getBehavior() == BehaviorMode.Raid) {
            if (lastDamager instanceof EntityTameableAnimal && ((EntityTameableAnimal) lastDamager).isTamed()) {
                return false;
            }
            if (lastDamager instanceof EntityMyPet) {
                return false;
            }
            if (lastDamager instanceof EntityPlayer) {
                return false;
            }
        }
    }
    return true;
}
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) 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.api.skill.skills.Behavior)

Example 18 with EntityTameableAnimal

use of net.minecraft.server.v1_7_R4.EntityTameableAnimal in project MyPet by xXKeyleXx.

the class OwnerHurtByTarget method shouldStart.

@Override
public boolean shouldStart() {
    if (!petEntity.canMove()) {
        return false;
    }
    if (myPet.getDamage() <= 0 && myPet.getRangedDamage() <= 0) {
        return false;
    }
    this.lastDamager = owner.getLastDamager();
    if (this.lastDamager == null || !lastDamager.isAlive()) {
        return false;
    }
    if (lastDamager instanceof EntityArmorStand) {
        return false;
    }
    if (lastDamager == petEntity) {
        return false;
    }
    if (lastDamager instanceof EntityPlayer) {
        if (owner == lastDamager) {
            return false;
        }
        Player targetPlayer = (Player) lastDamager.getBukkitEntity();
        if (!MyPetApi.getHookHelper().canHurt(myPet.getOwner().getPlayer(), targetPlayer, true)) {
            return false;
        }
    } else if (lastDamager instanceof EntityMyPet) {
        MyPet targetMyPet = ((EntityMyPet) lastDamager).getMyPet();
        if (!MyPetApi.getHookHelper().canHurt(myPet.getOwner().getPlayer(), targetMyPet.getOwner().getPlayer(), true)) {
            return false;
        }
    } else if (lastDamager instanceof EntityTameableAnimal) {
        EntityTameableAnimal tameable = (EntityTameableAnimal) lastDamager;
        if (tameable.isTamed() && tameable.getOwner() != null) {
            Player tameableOwner = (Player) tameable.getOwner().getBukkitEntity();
            if (myPet.getOwner().equals(tameableOwner)) {
                return false;
            }
        }
    }
    if (!MyPetApi.getHookHelper().canHurt(myPet.getOwner().getPlayer(), lastDamager.getBukkitEntity())) {
        return false;
    }
    Behavior behaviorSkill = myPet.getSkills().get(Behavior.class);
    if (behaviorSkill != null && behaviorSkill.isActive()) {
        if (behaviorSkill.getBehavior() == BehaviorMode.Friendly) {
            return false;
        }
        if (behaviorSkill.getBehavior() == BehaviorMode.Raid) {
            if (lastDamager instanceof EntityTameableAnimal && ((EntityTameableAnimal) lastDamager).isTamed()) {
                return false;
            }
            if (lastDamager instanceof EntityMyPet) {
                return false;
            }
            if (lastDamager instanceof EntityPlayer) {
                return false;
            }
        }
    }
    return true;
}
Also used : Player(org.bukkit.entity.Player) EntityPlayer(net.minecraft.server.v1_9_R2.EntityPlayer) CraftPlayer(org.bukkit.craftbukkit.v1_9_R2.entity.CraftPlayer) EntityMyPet(de.Keyle.MyPet.compat.v1_9_R2.entity.EntityMyPet) MyPet(de.Keyle.MyPet.api.entity.MyPet) EntityMyPet(de.Keyle.MyPet.compat.v1_9_R2.entity.EntityMyPet) EntityPlayer(net.minecraft.server.v1_9_R2.EntityPlayer) EntityTameableAnimal(net.minecraft.server.v1_9_R2.EntityTameableAnimal) EntityArmorStand(net.minecraft.server.v1_9_R2.EntityArmorStand) Behavior(de.Keyle.MyPet.api.skill.skills.Behavior)

Example 19 with EntityTameableAnimal

use of net.minecraft.server.v1_7_R4.EntityTameableAnimal in project MyPet by xXKeyleXx.

the class OwnerHurtByTarget method shouldStart.

@Override
public boolean shouldStart() {
    if (!petEntity.canMove()) {
        return false;
    }
    if (myPet.getDamage() <= 0 && myPet.getRangedDamage() <= 0) {
        return false;
    }
    this.lastDamager = owner.getLastDamager();
    if (this.lastDamager == null || !lastDamager.isAlive()) {
        return false;
    }
    if (lastDamager instanceof EntityArmorStand) {
        return false;
    }
    if (lastDamager == petEntity) {
        return false;
    }
    if (lastDamager instanceof EntityPlayer) {
        if (owner == lastDamager) {
            return false;
        }
        Player targetPlayer = (Player) lastDamager.getBukkitEntity();
        if (!MyPetApi.getHookHelper().canHurt(myPet.getOwner().getPlayer(), targetPlayer, true)) {
            return false;
        }
    } else if (lastDamager instanceof EntityMyPet) {
        MyPet targetMyPet = ((EntityMyPet) lastDamager).getMyPet();
        if (!MyPetApi.getHookHelper().canHurt(myPet.getOwner().getPlayer(), targetMyPet.getOwner().getPlayer(), true)) {
            return false;
        }
    } else if (lastDamager instanceof EntityTameableAnimal) {
        EntityTameableAnimal tameable = (EntityTameableAnimal) lastDamager;
        if (tameable.isTamed() && tameable.getOwner() != null) {
            Player tameableOwner = (Player) tameable.getOwner().getBukkitEntity();
            if (myPet.getOwner().equals(tameableOwner)) {
                return false;
            }
        }
    }
    if (!MyPetApi.getHookHelper().canHurt(myPet.getOwner().getPlayer(), lastDamager.getBukkitEntity())) {
        return false;
    }
    Behavior behaviorSkill = myPet.getSkills().get(Behavior.class);
    if (behaviorSkill != null && behaviorSkill.isActive()) {
        if (behaviorSkill.getBehavior() == BehaviorMode.Friendly) {
            return false;
        }
        if (behaviorSkill.getBehavior() == BehaviorMode.Raid) {
            if (lastDamager instanceof EntityTameableAnimal && ((EntityTameableAnimal) lastDamager).isTamed()) {
                return false;
            }
            if (lastDamager instanceof EntityMyPet) {
                return false;
            }
            if (lastDamager instanceof EntityPlayer) {
                return false;
            }
        }
    }
    return true;
}
Also used : Player(org.bukkit.entity.Player) EntityPlayer(net.minecraft.server.v1_16_R1.EntityPlayer) CraftPlayer(org.bukkit.craftbukkit.v1_16_R1.entity.CraftPlayer) EntityMyPet(de.Keyle.MyPet.compat.v1_16_R1.entity.EntityMyPet) MyPet(de.Keyle.MyPet.api.entity.MyPet) EntityMyPet(de.Keyle.MyPet.compat.v1_16_R1.entity.EntityMyPet) EntityPlayer(net.minecraft.server.v1_16_R1.EntityPlayer) EntityTameableAnimal(net.minecraft.server.v1_16_R1.EntityTameableAnimal) EntityArmorStand(net.minecraft.server.v1_16_R1.EntityArmorStand) Behavior(de.Keyle.MyPet.api.skill.skills.Behavior)

Example 20 with EntityTameableAnimal

use of net.minecraft.server.v1_7_R4.EntityTameableAnimal 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)

Aggregations

MyPet (de.Keyle.MyPet.api.entity.MyPet)26 Player (org.bukkit.entity.Player)26 Behavior (de.Keyle.MyPet.api.skill.skills.Behavior)22 EntityMyPet (de.Keyle.MyPet.compat.v1_8_R3.entity.EntityMyPet)6 Behavior (de.Keyle.MyPet.skill.skills.Behavior)6 EntityArmorStand (net.minecraft.server.v1_8_R3.EntityArmorStand)6 EntityPlayer (net.minecraft.server.v1_8_R3.EntityPlayer)6 EntityTameableAnimal (net.minecraft.server.v1_8_R3.EntityTameableAnimal)6 EntityTameableAnimal (net.minecraft.server.v1_12_R1.EntityTameableAnimal)5 EntityMyPet (de.Keyle.MyPet.compat.v1_12_R1.entity.EntityMyPet)4 EntityMyPet (de.Keyle.MyPet.compat.v1_16_R1.entity.EntityMyPet)4 EntityMyPet (de.Keyle.MyPet.compat.v1_16_R3.entity.EntityMyPet)4 EntityMyPet (de.Keyle.MyPet.compat.v1_9_R2.entity.EntityMyPet)4 EntityArmorStand (net.minecraft.server.v1_12_R1.EntityArmorStand)4 EntityArmorStand (net.minecraft.server.v1_16_R1.EntityArmorStand)4 EntityPlayer (net.minecraft.server.v1_16_R1.EntityPlayer)4 EntityTameableAnimal (net.minecraft.server.v1_16_R1.EntityTameableAnimal)4 EntityArmorStand (net.minecraft.server.v1_16_R3.EntityArmorStand)4 EntityPlayer (net.minecraft.server.v1_16_R3.EntityPlayer)4 EntityTameableAnimal (net.minecraft.server.v1_16_R3.EntityTameableAnimal)4