Search in sources :

Example 31 with EntityLiving

use of net.minecraft.server.v1_9_R2.EntityLiving 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.getTarget()).getHandle();
    if (targetEntity instanceof EntityArmorStand) {
        return false;
    }
    if (petEntity.getMyPet().getRangedDamage() > 0 && this.petEntity.f(targetEntity.locX, targetEntity.getBoundingBox().b, targetEntity.locZ) >= 20) {
        return false;
    }
    this.targetEntity = targetEntity;
    return true;
}
Also used : EntityLiving(net.minecraft.server.v1_10_R1.EntityLiving) CraftLivingEntity(org.bukkit.craftbukkit.v1_10_R1.entity.CraftLivingEntity) EntityArmorStand(net.minecraft.server.v1_10_R1.EntityArmorStand)

Example 32 with EntityLiving

use of net.minecraft.server.v1_9_R2.EntityLiving in project MyPet by xXKeyleXx.

the class Sprint method shouldStart.

@Override
public boolean shouldStart() {
    if (!myPet.getSkills().isSkillActive(de.Keyle.MyPet.skill.skills.Sprint.class)) {
        return false;
    }
    if (petEntity.getMyPet().getDamage() <= 0) {
        return false;
    }
    if (!this.petEntity.hasTarget()) {
        return false;
    }
    EntityLiving targetEntity = ((CraftLivingEntity) this.petEntity.getTarget()).getHandle();
    if (!targetEntity.isAlive()) {
        return false;
    }
    if (lastTarget == targetEntity) {
        return false;
    }
    if (petEntity.getMyPet().getRangedDamage() > 0 && this.petEntity.h(targetEntity) >= 16) {
        return false;
    }
    this.lastTarget = targetEntity;
    return true;
}
Also used : EntityLiving(net.minecraft.server.v1_10_R1.EntityLiving) CraftLivingEntity(org.bukkit.craftbukkit.v1_10_R1.entity.CraftLivingEntity)

Example 33 with EntityLiving

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

Example 34 with EntityLiving

use of net.minecraft.server.v1_9_R2.EntityLiving 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.getTarget()).getHandle();
    if (targetEntity instanceof EntityArmorStand) {
        return false;
    }
    if (petEntity.getMyPet().getRangedDamage() > 0 && this.petEntity.f(targetEntity.locX, targetEntity.getBoundingBox().b, targetEntity.locZ) >= 20) {
        return false;
    }
    this.targetEntity = targetEntity;
    return true;
}
Also used : EntityLiving(net.minecraft.server.v1_8_R1.EntityLiving) CraftLivingEntity(org.bukkit.craftbukkit.v1_8_R1.entity.CraftLivingEntity) EntityArmorStand(net.minecraft.server.v1_8_R1.EntityArmorStand)

Example 35 with EntityLiving

use of net.minecraft.server.v1_9_R2.EntityLiving 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)

Aggregations

EntityLiving (net.minecraft.server.v1_12_R1.EntityLiving)14 EntityLiving (net.minecraft.server.v1_11_R1.EntityLiving)12 EntityLiving (net.minecraft.server.v1_10_R1.EntityLiving)10 EntityLiving (net.minecraft.server.v1_8_R3.EntityLiving)10 MyPet (de.Keyle.MyPet.api.entity.MyPet)9 Behavior (de.Keyle.MyPet.skill.skills.Behavior)9 Player (org.bukkit.entity.Player)9 EntityLiving (net.minecraft.server.v1_9_R1.EntityLiving)5 LivingEntity (org.bukkit.entity.LivingEntity)5 EntityHuman (net.minecraft.server.v1_11_R1.EntityHuman)3 EntityHuman (net.minecraft.server.v1_12_R1.EntityHuman)3 EntityLiving (net.minecraft.server.v1_7_R4.EntityLiving)3 EntityHumanNPC (net.citizensnpcs.nms.v1_12_R1.entity.EntityHumanNPC)2 AttributeInstance (net.minecraft.server.v1_10_R1.AttributeInstance)2 EntityArmorStand (net.minecraft.server.v1_10_R1.EntityArmorStand)2 EntityPlayer (net.minecraft.server.v1_10_R1.EntityPlayer)2 AttributeInstance (net.minecraft.server.v1_11_R1.AttributeInstance)2 Entity (net.minecraft.server.v1_11_R1.Entity)2 EntityArmorStand (net.minecraft.server.v1_11_R1.EntityArmorStand)2 EntityPlayer (net.minecraft.server.v1_11_R1.EntityPlayer)2