Search in sources :

Example 21 with Ranged

use of de.Keyle.MyPet.api.skill.skills.Ranged in project MyPet by xXKeyleXx.

the class RangedAttack method shouldFinish.

@Override
public boolean shouldFinish() {
    if (!entityMyPet.hasTarget() || myPet.getRangedDamage() <= 0 || !entityMyPet.canMove()) {
        return true;
    }
    if (this.target.getBukkitEntity() != entityMyPet.getMyPetTarget()) {
        return true;
    }
    double meleeDamage = myPet.getDamage();
    if (meleeDamage > 0 && this.entityMyPet.e(target.locX, target.getBoundingBox().b, target.locZ) < 4) {
        Ranged rangedSkill = myPet.getSkills().get(Ranged.class);
        if (meleeDamage > rangedSkill.getDamage().getValue().doubleValue()) {
            return true;
        }
    }
    Behavior behaviorSkill = myPet.getSkills().get(Behavior.class);
    if (behaviorSkill != null && behaviorSkill.isActive()) {
        if (behaviorSkill.getBehavior() == Behavior.BehaviorMode.Friendly) {
            return true;
        }
        if (behaviorSkill.getBehavior() == Behavior.BehaviorMode.Raid) {
            if (this.target instanceof EntityTameableAnimal && ((EntityTameableAnimal) this.target).isTamed()) {
                return true;
            }
            if (this.target instanceof EntityMyPet) {
                return true;
            }
            if (this.target instanceof EntityPlayer) {
                return true;
            }
        }
    }
    return false;
}
Also used : Ranged(de.Keyle.MyPet.api.skill.skills.Ranged) EntityMyPet(de.Keyle.MyPet.compat.v1_12_R1.entity.EntityMyPet) Behavior(de.Keyle.MyPet.api.skill.skills.Behavior)

Aggregations

Ranged (de.Keyle.MyPet.api.skill.skills.Ranged)21 Behavior (de.Keyle.MyPet.api.skill.skills.Behavior)14 ServerPlayer (net.minecraft.server.level.ServerPlayer)4 TamableAnimal (net.minecraft.world.entity.TamableAnimal)4 EntityMyPet (de.Keyle.MyPet.compat.v1_12_R1.entity.EntityMyPet)2 EntityMyPet (de.Keyle.MyPet.compat.v1_16_R1.entity.EntityMyPet)2 EntityMyPet (de.Keyle.MyPet.compat.v1_16_R3.entity.EntityMyPet)2 EntityMyPet (de.Keyle.MyPet.compat.v1_17_R1.entity.EntityMyPet)2 EntityMyPet (de.Keyle.MyPet.compat.v1_18_R1.entity.EntityMyPet)2 EntityMyPet (de.Keyle.MyPet.compat.v1_8_R3.entity.EntityMyPet)2 EntityMyPet (de.Keyle.MyPet.compat.v1_9_R2.entity.EntityMyPet)2 LivingEntity (net.minecraft.world.entity.LivingEntity)2 ArmorStand (net.minecraft.world.entity.decoration.ArmorStand)2 CraftLivingEntity (org.bukkit.craftbukkit.v1_12_R1.entity.CraftLivingEntity)1 CraftLivingEntity (org.bukkit.craftbukkit.v1_16_R1.entity.CraftLivingEntity)1 CraftLivingEntity (org.bukkit.craftbukkit.v1_16_R3.entity.CraftLivingEntity)1 CraftLivingEntity (org.bukkit.craftbukkit.v1_17_R1.entity.CraftLivingEntity)1 CraftLivingEntity (org.bukkit.craftbukkit.v1_18_R1.entity.CraftLivingEntity)1 CraftLivingEntity (org.bukkit.craftbukkit.v1_8_R3.entity.CraftLivingEntity)1 CraftLivingEntity (org.bukkit.craftbukkit.v1_9_R2.entity.CraftLivingEntity)1