Search in sources :

Example 16 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.g(target.locX(), this.target.getBoundingBox().minY, 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_16_R1.entity.EntityMyPet) Behavior(de.Keyle.MyPet.api.skill.skills.Behavior)

Example 17 with Ranged

use of de.Keyle.MyPet.api.skill.skills.Ranged 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;
    }
    LivingEntity target = ((CraftLivingEntity) this.entityMyPet.getMyPetTarget()).getHandle();
    if (target instanceof ArmorStand) {
        return false;
    }
    double meleeDamage = myPet.getDamage();
    if (meleeDamage > 0 && this.entityMyPet.distanceToSqr(target.getX(), target.getBoundingBox().minY, target.getZ()) < 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 TamableAnimal && ((TamableAnimal) target).isTame()) {
                return false;
            }
            if (target instanceof EntityMyPet) {
                return false;
            }
            if (target instanceof ServerPlayer) {
                return false;
            }
        }
    }
    this.target = target;
    return true;
}
Also used : LivingEntity(net.minecraft.world.entity.LivingEntity) CraftLivingEntity(org.bukkit.craftbukkit.v1_17_R1.entity.CraftLivingEntity) Ranged(de.Keyle.MyPet.api.skill.skills.Ranged) EntityMyPet(de.Keyle.MyPet.compat.v1_17_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_17_R1.entity.CraftLivingEntity) Behavior(de.Keyle.MyPet.api.skill.skills.Behavior)

Example 18 with Ranged

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

the class RangedAttack method tick.

@Override
public void tick() {
    double distanceToTarget = this.entityMyPet.distanceToSqr(this.target.getX(), this.target.getBoundingBox().minY, this.target.getZ());
    boolean canSee = this.entityMyPet.getSensing().hasLineOfSight(this.target);
    if (canSee) {
        this.lastSeenTimer++;
    } else {
        this.lastSeenTimer = 0;
    }
    if ((distanceToTarget <= this.range) && (this.lastSeenTimer >= 20)) {
        this.entityMyPet.getPetNavigation().getParameters().removeSpeedModifier("RangedAttack");
        this.entityMyPet.getPetNavigation().stop();
    } else {
        this.entityMyPet.getPetNavigation().getParameters().addSpeedModifier("RangedAttack", walkSpeedModifier);
        this.entityMyPet.getPetNavigation().navigateTo(this.target.getBukkitEntity().getLocation());
    }
    this.entityMyPet.getLookControl().setLookAt(this.target, 30.0F, 30.0F);
    if (--this.shootTimer <= 0) {
        if (distanceToTarget < this.range && canSee) {
            shootProjectile(this.target, (float) myPet.getRangedDamage(), getProjectile());
            Ranged rangedSkill = myPet.getSkills().get(Ranged.class);
            this.shootTimer = rangedSkill.getRateOfFire().getValue();
        }
    }
}
Also used : Ranged(de.Keyle.MyPet.api.skill.skills.Ranged)

Example 19 with Ranged

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

the class RangedAttack method tick.

@Override
public void tick() {
    double distanceToTarget = this.entityMyPet.f(this.target.locX, this.target.getBoundingBox().b, this.target.locZ);
    // a -> canSee
    boolean canSee = this.entityMyPet.getEntitySenses().a(this.target);
    if (canSee) {
        this.lastSeenTimer++;
    } else {
        this.lastSeenTimer = 0;
    }
    if ((distanceToTarget <= this.range) && (this.lastSeenTimer >= 20)) {
        this.entityMyPet.getPetNavigation().getParameters().removeSpeedModifier("RangedAttack");
        this.entityMyPet.getPetNavigation().stop();
    } else {
        this.entityMyPet.getPetNavigation().getParameters().addSpeedModifier("RangedAttack", walkSpeedModifier);
        this.entityMyPet.getPetNavigation().navigateTo(this.target.getBukkitEntity().getLocation());
    }
    this.entityMyPet.getControllerLook().a(this.target, 30.0F, 30.0F);
    if (--this.shootTimer <= 0) {
        if (distanceToTarget < this.range && canSee) {
            shootProjectile(this.target, (float) myPet.getRangedDamage(), getProjectile());
            Ranged rangedSkill = myPet.getSkills().get(Ranged.class);
            this.shootTimer = rangedSkill.getRateOfFire().getValue();
        }
    }
}
Also used : Ranged(de.Keyle.MyPet.api.skill.skills.Ranged)

Example 20 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() != this.entityMyPet.getMyPetTarget()) {
        return true;
    }
    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 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_8_R3.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