Search in sources :

Example 41 with EntityLiving

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

the class BehaviorAggressiveTarget method shouldFinish.

@Override
public boolean shouldFinish() {
    if (!petEntity.canMove()) {
        return true;
    } else if (petEntity.getMyPetTarget() == null) {
        return true;
    }
    EntityLiving target = ((CraftLivingEntity) petEntity.getMyPetTarget()).getHandle();
    if (!target.isAlive()) {
        return true;
    }
    Behavior behaviorSkill = myPet.getSkills().get(Behavior.class);
    if (behaviorSkill.getBehavior() != BehaviorMode.Aggressive) {
        return true;
    } else if (myPet.getDamage() <= 0 && myPet.getRangedDamage() <= 0) {
        return true;
    } else if (target.world != petEntity.world) {
        return true;
    } else if (petEntity.h(target) > 400) {
        return true;
    } else if (petEntity.h(((CraftPlayer) petEntity.getOwner().getPlayer()).getHandle()) > 600) {
        return true;
    }
    return false;
}
Also used : EntityLiving(net.minecraft.server.v1_9_R2.EntityLiving) CraftLivingEntity(org.bukkit.craftbukkit.v1_9_R2.entity.CraftLivingEntity) CraftPlayer(org.bukkit.craftbukkit.v1_9_R2.entity.CraftPlayer) Behavior(de.Keyle.MyPet.api.skill.skills.Behavior)

Example 42 with EntityLiving

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

the class Sprint method shouldStart.

@Override
public boolean shouldStart() {
    if (!myPet.getSkills().isActive(SprintImpl.class)) {
        return false;
    }
    if (petEntity.getMyPet().getDamage() <= 0) {
        return false;
    }
    if (!this.petEntity.hasTarget()) {
        return false;
    }
    EntityLiving targetEntity = ((CraftLivingEntity) this.petEntity.getMyPetTarget()).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_8_R3.EntityLiving) SprintImpl(de.Keyle.MyPet.skill.skills.SprintImpl) CraftLivingEntity(org.bukkit.craftbukkit.v1_8_R3.entity.CraftLivingEntity)

Example 43 with EntityLiving

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

the class BehaviorFarmTarget method shouldFinish.

@Override
public boolean shouldFinish() {
    if (!petEntity.canMove()) {
        return true;
    }
    if (!this.petEntity.hasTarget()) {
        return true;
    }
    EntityLiving target = ((CraftLivingEntity) this.petEntity.getMyPetTarget()).getHandle();
    if (!target.isAlive()) {
        return true;
    }
    Behavior behaviorSkill = myPet.getSkills().get(Behavior.class);
    if (behaviorSkill.getBehavior() != BehaviorMode.Farm) {
        return true;
    } else if (myPet.getDamage() <= 0 && myPet.getRangedDamage() <= 0) {
        return true;
    } else if (target.world != petEntity.world) {
        return true;
    } else if (petEntity.h(target) > 400) {
        return true;
    } else if (petEntity.h(((CraftPlayer) petEntity.getOwner().getPlayer()).getHandle()) > 600) {
        return true;
    }
    return false;
}
Also used : EntityLiving(net.minecraft.server.v1_8_R3.EntityLiving) CraftLivingEntity(org.bukkit.craftbukkit.v1_8_R3.entity.CraftLivingEntity) CraftPlayer(org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer) Behavior(de.Keyle.MyPet.api.skill.skills.Behavior)

Example 44 with EntityLiving

use of net.minecraft.server.v1_15_R1.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.getMyPetTarget()).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;
    }
    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_8_R3.entity.EntityMyPet) EntityLiving(net.minecraft.server.v1_8_R3.EntityLiving) EntityTameableAnimal(net.minecraft.server.v1_8_R3.EntityTameableAnimal) EntityPlayer(net.minecraft.server.v1_8_R3.EntityPlayer) CraftLivingEntity(org.bukkit.craftbukkit.v1_8_R3.entity.CraftLivingEntity) EntityArmorStand(net.minecraft.server.v1_8_R3.EntityArmorStand) Behavior(de.Keyle.MyPet.api.skill.skills.Behavior)

Example 45 with EntityLiving

use of net.minecraft.server.v1_15_R1.EntityLiving in project solinia3-core by mixxit.

the class EntityUtils method DistanceOverAggroLimit.

public static double DistanceOverAggroLimit(LivingEntity attacker, LivingEntity aggroCheckEntity) {
    double distance = attacker.getLocation().distance(aggroCheckEntity.getLocation());
    if (distance > 100D)
        return 100D - distance;
    net.minecraft.server.v1_15_R1.EntityLiving entity = ((org.bukkit.craftbukkit.v1_15_R1.entity.CraftLivingEntity) aggroCheckEntity).getHandle();
    if (entity == null)
        return 0D;
    if (entity.getAttributeInstance(GenericAttributes.FOLLOW_RANGE) == null)
        return 0D;
    double distanceLimit = entity.getAttributeInstance(GenericAttributes.FOLLOW_RANGE).getValue();
    if (distance > distanceLimit)
        return distance - distanceLimit;
    return 0D;
}
Also used : EntityLiving(net.minecraft.server.v1_15_R1.EntityLiving) CraftLivingEntity(org.bukkit.craftbukkit.v1_15_R1.entity.CraftLivingEntity)

Aggregations

Behavior (de.Keyle.MyPet.api.skill.skills.Behavior)21 EntityLiving (net.minecraft.server.v1_12_R1.EntityLiving)16 EntityLiving (net.minecraft.server.v1_8_R3.EntityLiving)13 EntityLiving (net.minecraft.server.v1_11_R1.EntityLiving)12 Player (org.bukkit.entity.Player)12 MyPet (de.Keyle.MyPet.api.entity.MyPet)11 EntityLiving (net.minecraft.server.v1_10_R1.EntityLiving)10 Behavior (de.Keyle.MyPet.skill.skills.Behavior)6 SprintImpl (de.Keyle.MyPet.skill.skills.SprintImpl)5 EntityLiving (net.minecraft.server.v1_16_R1.EntityLiving)5 EntityLiving (net.minecraft.server.v1_9_R1.EntityLiving)5 EntityLiving (net.minecraft.server.v1_9_R2.EntityLiving)5 CraftLivingEntity (org.bukkit.craftbukkit.v1_12_R1.entity.CraftLivingEntity)5 CraftLivingEntity (org.bukkit.craftbukkit.v1_8_R3.entity.CraftLivingEntity)5 LivingEntity (org.bukkit.entity.LivingEntity)5 EntityLiving (net.minecraft.server.v1_16_R3.EntityLiving)4 CraftPlayer (org.bukkit.craftbukkit.v1_12_R1.entity.CraftPlayer)4 CraftLivingEntity (org.bukkit.craftbukkit.v1_16_R1.entity.CraftLivingEntity)4 CraftPlayer (org.bukkit.craftbukkit.v1_16_R1.entity.CraftPlayer)4 CraftLivingEntity (org.bukkit.craftbukkit.v1_9_R2.entity.CraftLivingEntity)4