Search in sources :

Example 6 with CraftLivingEntity

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

Example 7 with CraftLivingEntity

use of org.bukkit.craftbukkit.v1_18_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_11_R1.EntityLiving) CraftLivingEntity(org.bukkit.craftbukkit.v1_11_R1.entity.CraftLivingEntity)

Example 8 with CraftLivingEntity

use of org.bukkit.craftbukkit.v1_18_R1.entity.CraftLivingEntity in project Ublisk by Derkades.

the class V1_12_R1 method setTargetToClosestPlayer.

@Override
public void setTargetToClosestPlayer(Creature creature, Player player) {
    CraftLivingEntity craftLiving = (CraftLivingEntity) player;
    EntityLiving entityLiving = craftLiving.getHandle();
    ((CraftCreature) creature).getHandle().setGoalTarget(entityLiving, TargetReason.CLOSEST_PLAYER, false);
}
Also used : EntityLiving(net.minecraft.server.v1_12_R1.EntityLiving) CraftLivingEntity(org.bukkit.craftbukkit.v1_12_R1.entity.CraftLivingEntity)

Example 9 with CraftLivingEntity

use of org.bukkit.craftbukkit.v1_18_R1.entity.CraftLivingEntity in project Denizen-For-Bukkit by DenizenScript.

the class EntityHelperImpl method getDamageTo.

@Override
public double getDamageTo(LivingEntity attacker, Entity target) {
    MobType monsterType;
    if (target instanceof LivingEntity) {
        monsterType = ((CraftLivingEntity) target).getHandle().getMobType();
    } else {
        monsterType = MobType.UNDEFINED;
    }
    double damage = 0;
    AttributeInstance attrib = attacker.getAttribute(Attribute.GENERIC_ATTACK_DAMAGE);
    if (attrib != null) {
        damage = attrib.getValue();
    }
    if (attacker.getEquipment() != null && attacker.getEquipment().getItemInMainHand() != null) {
        damage += EnchantmentHelper.getDamageBonus(CraftItemStack.asNMSCopy(attacker.getEquipment().getItemInMainHand()), monsterType);
    }
    if (damage <= 0) {
        return 0;
    }
    if (target != null) {
        DamageSource source;
        if (attacker instanceof Player) {
            source = DamageSource.playerAttack(((CraftPlayer) attacker).getHandle());
        } else {
            source = DamageSource.mobAttack(((CraftLivingEntity) attacker).getHandle());
        }
        net.minecraft.world.entity.Entity nmsTarget = ((CraftEntity) target).getHandle();
        if (nmsTarget.isInvulnerableTo(source)) {
            return 0;
        }
        if (!(nmsTarget instanceof net.minecraft.world.entity.LivingEntity)) {
            return damage;
        }
        net.minecraft.world.entity.LivingEntity livingTarget = (net.minecraft.world.entity.LivingEntity) nmsTarget;
        damage = CombatRules.getDamageAfterAbsorb((float) damage, (float) livingTarget.getArmorValue(), (float) livingTarget.getAttributeValue(Attributes.ARMOR_TOUGHNESS));
        int enchantDamageModifier = EnchantmentHelper.getDamageProtection(livingTarget.getArmorSlots(), source);
        if (enchantDamageModifier > 0) {
            damage = CombatRules.getDamageAfterMagicAbsorb((float) damage, (float) enchantDamageModifier);
        }
    }
    return damage;
}
Also used : ServerPlayer(net.minecraft.server.level.ServerPlayer) DamageSource(net.minecraft.world.damagesource.DamageSource) LivingEntity(org.bukkit.entity.LivingEntity) AttributeInstance(org.bukkit.attribute.AttributeInstance) org.bukkit.entity(org.bukkit.entity) org.bukkit.craftbukkit.v1_18_R1.entity(org.bukkit.craftbukkit.v1_18_R1.entity) net.minecraft.world.entity(net.minecraft.world.entity)

Example 10 with CraftLivingEntity

use of org.bukkit.craftbukkit.v1_18_R1.entity.CraftLivingEntity 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_12_R1.EntityLiving) CraftLivingEntity(org.bukkit.craftbukkit.v1_12_R1.entity.CraftLivingEntity) CraftPlayer(org.bukkit.craftbukkit.v1_12_R1.entity.CraftPlayer) 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 ServerPlayer (net.minecraft.server.level.ServerPlayer)5 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 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 EntityLiving (net.minecraft.server.v1_7_R4.EntityLiving)3 ArmorStand (net.minecraft.world.entity.decoration.ArmorStand)3