Search in sources :

Example 56 with Behavior

use of de.Keyle.MyPet.api.skill.skills.Behavior 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)

Example 57 with Behavior

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

the class EntityMyVex method doMyPetTick.

@Override
protected void doMyPetTick() {
    super.doMyPetTick();
    BehaviorImpl skill = getMyPet().getSkills().get(BehaviorImpl.class);
    Behavior.BehaviorMode behavior = skill.getBehavior();
    if (behavior == Behavior.BehaviorMode.Aggressive) {
        if (!isAggressive) {
            isAggressive = true;
            this.updateVisuals();
        }
    } else {
        if (isAggressive) {
            isAggressive = false;
            this.updateVisuals();
        }
    }
}
Also used : BehaviorImpl(de.Keyle.MyPet.skill.skills.BehaviorImpl) Behavior(de.Keyle.MyPet.api.skill.skills.Behavior)

Example 58 with Behavior

use of de.Keyle.MyPet.api.skill.skills.Behavior 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_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 59 with Behavior

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

the class EntityMyEnderman method doMyPetTick.

protected void doMyPetTick() {
    super.doMyPetTick();
    BehaviorImpl skill = getMyPet().getSkills().get(BehaviorImpl.class);
    Behavior.BehaviorMode behavior = skill.getBehavior();
    if (behavior == Behavior.BehaviorMode.Aggressive) {
        if (!getMyPet().isScreaming()) {
            getMyPet().setScreaming(true);
        }
    } else {
        if (getMyPet().isScreaming()) {
            getMyPet().setScreaming(false);
        }
    }
}
Also used : BehaviorImpl(de.Keyle.MyPet.skill.skills.BehaviorImpl) Behavior(de.Keyle.MyPet.api.skill.skills.Behavior)

Example 60 with Behavior

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

the class OwnerHurtByTarget method shouldStart.

@Override
public boolean shouldStart() {
    if (!petEntity.canMove()) {
        return false;
    }
    if (myPet.getDamage() <= 0 && myPet.getRangedDamage() <= 0) {
        return false;
    }
    this.lastDamager = owner.getLastDamager();
    if (this.lastDamager == null || !lastDamager.isAlive()) {
        return false;
    }
    if (lastDamager instanceof EntityArmorStand) {
        return false;
    }
    if (lastDamager == petEntity) {
        return false;
    }
    if (lastDamager instanceof EntityPlayer) {
        if (owner == lastDamager) {
            return false;
        }
        Player targetPlayer = (Player) lastDamager.getBukkitEntity();
        if (!MyPetApi.getHookHelper().canHurt(myPet.getOwner().getPlayer(), targetPlayer, true)) {
            return false;
        }
    } else if (lastDamager instanceof EntityMyPet) {
        MyPet targetMyPet = ((EntityMyPet) lastDamager).getMyPet();
        if (!MyPetApi.getHookHelper().canHurt(myPet.getOwner().getPlayer(), targetMyPet.getOwner().getPlayer(), true)) {
            return false;
        }
    } else if (lastDamager instanceof EntityTameableAnimal) {
        EntityTameableAnimal tameable = (EntityTameableAnimal) lastDamager;
        if (tameable.isTamed() && tameable.getOwner() != null) {
            Player tameableOwner = (Player) tameable.getOwner().getBukkitEntity();
            if (myPet.getOwner().equals(tameableOwner)) {
                return false;
            }
        }
    }
    if (!MyPetApi.getHookHelper().canHurt(myPet.getOwner().getPlayer(), lastDamager.getBukkitEntity())) {
        return false;
    }
    Behavior behaviorSkill = myPet.getSkills().get(Behavior.class);
    if (behaviorSkill != null && behaviorSkill.isActive()) {
        if (behaviorSkill.getBehavior() == BehaviorMode.Friendly) {
            return false;
        }
        if (behaviorSkill.getBehavior() == BehaviorMode.Raid) {
            if (lastDamager instanceof EntityTameableAnimal && ((EntityTameableAnimal) lastDamager).isTamed()) {
                return false;
            }
            if (lastDamager instanceof EntityMyPet) {
                return false;
            }
            if (lastDamager instanceof EntityPlayer) {
                return false;
            }
        }
    }
    return true;
}
Also used : Player(org.bukkit.entity.Player) EntityPlayer(net.minecraft.server.v1_9_R2.EntityPlayer) CraftPlayer(org.bukkit.craftbukkit.v1_9_R2.entity.CraftPlayer) EntityMyPet(de.Keyle.MyPet.compat.v1_9_R2.entity.EntityMyPet) MyPet(de.Keyle.MyPet.api.entity.MyPet) EntityMyPet(de.Keyle.MyPet.compat.v1_9_R2.entity.EntityMyPet) EntityPlayer(net.minecraft.server.v1_9_R2.EntityPlayer) EntityTameableAnimal(net.minecraft.server.v1_9_R2.EntityTameableAnimal) EntityArmorStand(net.minecraft.server.v1_9_R2.EntityArmorStand) Behavior(de.Keyle.MyPet.api.skill.skills.Behavior)

Aggregations

Behavior (de.Keyle.MyPet.api.skill.skills.Behavior)81 BehaviorImpl (de.Keyle.MyPet.skill.skills.BehaviorImpl)23 MyPet (de.Keyle.MyPet.api.entity.MyPet)22 Player (org.bukkit.entity.Player)15 Ranged (de.Keyle.MyPet.api.skill.skills.Ranged)13 ServerPlayer (net.minecraft.server.level.ServerPlayer)11 TamableAnimal (net.minecraft.world.entity.TamableAnimal)11 ArmorStand (net.minecraft.world.entity.decoration.ArmorStand)9 EntityMyPet (de.Keyle.MyPet.compat.v1_17_R1.entity.EntityMyPet)7 EntityMyPet (de.Keyle.MyPet.compat.v1_12_R1.entity.EntityMyPet)6 EntityMyPet (de.Keyle.MyPet.compat.v1_18_R1.entity.EntityMyPet)6 EntityMyPet (de.Keyle.MyPet.compat.v1_8_R3.entity.EntityMyPet)6 EntityMyPet (de.Keyle.MyPet.compat.v1_16_R1.entity.EntityMyPet)5 EntityMyPet (de.Keyle.MyPet.compat.v1_16_R3.entity.EntityMyPet)5 EntityMyPet (de.Keyle.MyPet.compat.v1_9_R2.entity.EntityMyPet)5 EntityLiving (net.minecraft.server.v1_8_R3.EntityLiving)5 CraftLivingEntity (org.bukkit.craftbukkit.v1_12_R1.entity.CraftLivingEntity)5 CraftPlayer (org.bukkit.craftbukkit.v1_12_R1.entity.CraftPlayer)5 CraftLivingEntity (org.bukkit.craftbukkit.v1_16_R3.entity.CraftLivingEntity)5 CraftLivingEntity (org.bukkit.craftbukkit.v1_17_R1.entity.CraftLivingEntity)5