Search in sources :

Example 36 with CraftLivingEntity

use of org.bukkit.craftbukkit.v1_15_R1.entity.CraftLivingEntity 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_8_R2.EntityLiving) CraftLivingEntity(org.bukkit.craftbukkit.v1_8_R2.entity.CraftLivingEntity)

Example 37 with CraftLivingEntity

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

Example 38 with CraftLivingEntity

use of org.bukkit.craftbukkit.v1_15_R1.entity.CraftLivingEntity 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) this.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_9_R2.entity.EntityMyPet) CraftLivingEntity(org.bukkit.craftbukkit.v1_9_R2.entity.CraftLivingEntity) Behavior(de.Keyle.MyPet.api.skill.skills.Behavior)

Example 39 with CraftLivingEntity

use of org.bukkit.craftbukkit.v1_15_R1.entity.CraftLivingEntity in project MyPet by xXKeyleXx.

the class RangedAttack method shouldStart.

@Override
public boolean shouldStart() {
    if (myPet.getRangedDamage() <= 0) {
        return false;
    }
    if (!entityMyPet.canMove()) {
        return false;
    }
    if (!entityMyPet.hasTarget()) {
        return false;
    }
    EntityLiving target = ((CraftLivingEntity) this.entityMyPet.getMyPetTarget()).getHandle();
    if (target instanceof EntityArmorStand) {
        return false;
    }
    double meleeDamage = myPet.getDamage();
    if (meleeDamage > 0 && this.entityMyPet.f(target.locX, target.getBoundingBox().b, target.locZ) < 4) {
        Ranged rangedSkill = myPet.getSkills().get(Ranged.class);
        if (meleeDamage > rangedSkill.getDamage().getValue().doubleValue()) {
            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 (target instanceof EntityTameableAnimal && ((EntityTameableAnimal) target).isTamed()) {
                return false;
            }
            if (target instanceof EntityMyPet) {
                return false;
            }
            if (target instanceof EntityPlayer) {
                return false;
            }
        }
    }
    this.target = target;
    return true;
}
Also used : Ranged(de.Keyle.MyPet.api.skill.skills.Ranged) EntityMyPet(de.Keyle.MyPet.compat.v1_9_R2.entity.EntityMyPet) CraftLivingEntity(org.bukkit.craftbukkit.v1_9_R2.entity.CraftLivingEntity) Behavior(de.Keyle.MyPet.api.skill.skills.Behavior)

Example 40 with CraftLivingEntity

use of org.bukkit.craftbukkit.v1_15_R1.entity.CraftLivingEntity 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;
    }
    net.minecraft.world.entity.LivingEntity targetEntity = ((CraftLivingEntity) this.petEntity.getMyPetTarget()).getHandle();
    if (targetEntity instanceof ArmorStand) {
        return false;
    }
    if (petEntity.getMyPet().getRangedDamage() > 0 && this.petEntity.distanceToSqr(targetEntity.getX(), targetEntity.getBoundingBox().minY, targetEntity.getZ()) >= 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 TamableAnimal && ((TamableAnimal) targetEntity).isTame()) {
                return false;
            }
            if (targetEntity instanceof EntityMyPet) {
                return false;
            }
            if (targetEntity instanceof ServerPlayer) {
                return false;
            }
        }
    }
    this.targetEntity = targetEntity;
    return true;
}
Also used : EntityMyPet(de.Keyle.MyPet.compat.v1_18_R1.entity.EntityMyPet) ArmorStand(net.minecraft.world.entity.decoration.ArmorStand) TamableAnimal(net.minecraft.world.entity.TamableAnimal) ServerPlayer(net.minecraft.server.level.ServerPlayer) CraftLivingEntity(org.bukkit.craftbukkit.v1_18_R1.entity.CraftLivingEntity) Behavior(de.Keyle.MyPet.api.skill.skills.Behavior)

Aggregations

Behavior (de.Keyle.MyPet.api.skill.skills.Behavior)35 Ranged (de.Keyle.MyPet.api.skill.skills.Ranged)7 SprintImpl (de.Keyle.MyPet.skill.skills.SprintImpl)7 CraftLivingEntity (org.bukkit.craftbukkit.v1_12_R1.entity.CraftLivingEntity)7 LivingEntity (net.minecraft.world.entity.LivingEntity)6 CraftLivingEntity (org.bukkit.craftbukkit.v1_16_R1.entity.CraftLivingEntity)6 CraftLivingEntity (org.bukkit.craftbukkit.v1_16_R3.entity.CraftLivingEntity)6 CraftLivingEntity (org.bukkit.craftbukkit.v1_17_R1.entity.CraftLivingEntity)6 CraftLivingEntity (org.bukkit.craftbukkit.v1_8_R3.entity.CraftLivingEntity)6 CraftLivingEntity (org.bukkit.craftbukkit.v1_9_R2.entity.CraftLivingEntity)6 EntityLiving (net.minecraft.server.v1_12_R1.EntityLiving)5 EntityLiving (net.minecraft.server.v1_8_R3.EntityLiving)5 CraftLivingEntity (org.bukkit.craftbukkit.v1_18_R1.entity.CraftLivingEntity)5 ServerPlayer (net.minecraft.server.level.ServerPlayer)4 EntityLiving (net.minecraft.server.v1_16_R1.EntityLiving)4 EntityLiving (net.minecraft.server.v1_16_R3.EntityLiving)4 EntityLiving (net.minecraft.server.v1_9_R2.EntityLiving)4 TamableAnimal (net.minecraft.world.entity.TamableAnimal)4 ArmorStand (net.minecraft.world.entity.decoration.ArmorStand)4 EntityLiving (net.minecraft.server.v1_7_R4.EntityLiving)3