Search in sources :

Example 16 with EntityLiving

use of net.minecraft.server.v1_15_R1.EntityLiving in project Citizens2 by CitizensDev.

the class NMSImpl method updatePathfindingRange.

@Override
public void updatePathfindingRange(NPC npc, float pathfindingRange) {
    if (!npc.isSpawned() || !npc.getEntity().getType().isAlive())
        return;
    EntityLiving en = NMSImpl.getHandle((LivingEntity) npc.getEntity());
    if (!(en instanceof EntityInsentient)) {
        if (en instanceof EntityHumanNPC) {
            ((EntityHumanNPC) en).updatePathfindingRange(pathfindingRange);
        }
        return;
    }
    if (PATHFINDING_RANGE == null)
        return;
    EntityInsentient handle = (EntityInsentient) en;
    NavigationAbstract navigation = handle.getNavigation();
    try {
        AttributeInstance inst = (AttributeInstance) PATHFINDING_RANGE.get(navigation);
        inst.setValue(pathfindingRange);
    } catch (IllegalArgumentException e) {
        e.printStackTrace();
    } catch (IllegalAccessException e) {
        e.printStackTrace();
    }
}
Also used : EntityLiving(net.minecraft.server.v1_8_R3.EntityLiving) AttributeInstance(net.minecraft.server.v1_8_R3.AttributeInstance) EntityInsentient(net.minecraft.server.v1_8_R3.EntityInsentient) NavigationAbstract(net.minecraft.server.v1_8_R3.NavigationAbstract) EntityHumanNPC(net.citizensnpcs.nms.v1_8_R3.entity.EntityHumanNPC)

Example 17 with EntityLiving

use of net.minecraft.server.v1_15_R1.EntityLiving in project Citizens2 by CitizensDev.

the class NMSImpl method updatePathfindingRange.

@Override
public void updatePathfindingRange(NPC npc, float pathfindingRange) {
    if (!npc.isSpawned() || !npc.getEntity().getType().isAlive())
        return;
    EntityLiving en = NMSImpl.getHandle((LivingEntity) npc.getEntity());
    if (!(en instanceof EntityInsentient)) {
        if (en instanceof EntityHumanNPC) {
            ((EntityHumanNPC) en).updatePathfindingRange(pathfindingRange);
        }
        return;
    }
    if (PATHFINDING_RANGE == null)
        return;
    EntityInsentient handle = (EntityInsentient) en;
    NavigationAbstract navigation = handle.getNavigation();
    try {
        AttributeInstance inst = (AttributeInstance) PATHFINDING_RANGE.get(navigation);
        inst.setValue(pathfindingRange);
    } catch (IllegalArgumentException e) {
        e.printStackTrace();
    } catch (IllegalAccessException e) {
        e.printStackTrace();
    }
}
Also used : EntityLiving(net.minecraft.server.v1_12_R1.EntityLiving) AttributeInstance(net.minecraft.server.v1_12_R1.AttributeInstance) EntityInsentient(net.minecraft.server.v1_12_R1.EntityInsentient) NavigationAbstract(net.minecraft.server.v1_12_R1.NavigationAbstract) EntityHumanNPC(net.citizensnpcs.nms.v1_12_R1.entity.EntityHumanNPC)

Example 18 with EntityLiving

use of net.minecraft.server.v1_15_R1.EntityLiving in project Citizens2 by CitizensDev.

the class NMSImpl method setHeadYaw.

@Override
public void setHeadYaw(org.bukkit.entity.Entity entity, float yaw) {
    if (!(entity instanceof LivingEntity))
        return;
    EntityLiving handle = (EntityLiving) getHandle(entity);
    yaw = Util.clampYaw(yaw);
    handle.aO = yaw;
    if (!(handle instanceof EntityHuman)) {
        handle.aN = yaw;
    }
    handle.aP = yaw;
}
Also used : LivingEntity(org.bukkit.entity.LivingEntity) EntityHuman(net.minecraft.server.v1_12_R1.EntityHuman) EntityLiving(net.minecraft.server.v1_12_R1.EntityLiving)

Example 19 with EntityLiving

use of net.minecraft.server.v1_15_R1.EntityLiving in project Citizens2 by CitizensDev.

the class NMSImpl method attack.

@Override
public void attack(LivingEntity attacker, LivingEntity btarget) {
    EntityLiving handle = getHandle(attacker);
    EntityLiving target = getHandle(btarget);
    if (handle instanceof EntityPlayer) {
        EntityPlayer humanHandle = (EntityPlayer) handle;
        humanHandle.attack(target);
        PlayerAnimation.ARM_SWING.play(humanHandle.getBukkitEntity());
        return;
    }
    AttributeInstance attackDamage = handle.getAttributeInstance(GenericAttributes.ATTACK_DAMAGE);
    float f = (float) (attackDamage == null ? 1 : attackDamage.getValue());
    int i = 0;
    if (target instanceof EntityLiving) {
        f += EnchantmentManager.a(handle.getItemInMainHand(), target.getMonsterType());
        i += EnchantmentManager.a(Enchantments.KNOCKBACK, handle);
    }
    boolean flag = target.damageEntity(DamageSource.mobAttack(handle), f);
    if (!flag)
        return;
    if (i > 0) {
        target.f(-Math.sin(handle.yaw * Math.PI / 180.0F) * i * 0.5F, 0.1D, Math.cos(handle.yaw * Math.PI / 180.0F) * i * 0.5F);
        handle.motX *= 0.6D;
        handle.motZ *= 0.6D;
    }
    int fireAspectLevel = EnchantmentManager.getFireAspectEnchantmentLevel(handle);
    if (fireAspectLevel > 0) {
        target.setOnFire(fireAspectLevel * 4);
    }
}
Also used : EntityLiving(net.minecraft.server.v1_11_R1.EntityLiving) AttributeInstance(net.minecraft.server.v1_11_R1.AttributeInstance) EntityPlayer(net.minecraft.server.v1_11_R1.EntityPlayer) PathPoint(net.minecraft.server.v1_11_R1.PathPoint)

Example 20 with EntityLiving

use of net.minecraft.server.v1_15_R1.EntityLiving in project Citizens2 by CitizensDev.

the class NMSImpl method setKnockbackResistance.

@Override
public void setKnockbackResistance(LivingEntity entity, double d) {
    EntityLiving handle = NMSImpl.getHandle(entity);
    handle.getAttributeInstance(GenericAttributes.c).setValue(d);
}
Also used : EntityLiving(net.minecraft.server.v1_11_R1.EntityLiving)

Aggregations

Behavior (de.Keyle.MyPet.api.skill.skills.Behavior)21 EntityLiving (net.minecraft.server.v1_12_R1.EntityLiving)16 EntityLiving (net.minecraft.server.v1_8_R3.EntityLiving)13 EntityLiving (net.minecraft.server.v1_11_R1.EntityLiving)12 Player (org.bukkit.entity.Player)12 MyPet (de.Keyle.MyPet.api.entity.MyPet)11 EntityLiving (net.minecraft.server.v1_10_R1.EntityLiving)10 Behavior (de.Keyle.MyPet.skill.skills.Behavior)6 SprintImpl (de.Keyle.MyPet.skill.skills.SprintImpl)5 EntityLiving (net.minecraft.server.v1_16_R1.EntityLiving)5 EntityLiving (net.minecraft.server.v1_9_R1.EntityLiving)5 EntityLiving (net.minecraft.server.v1_9_R2.EntityLiving)5 CraftLivingEntity (org.bukkit.craftbukkit.v1_12_R1.entity.CraftLivingEntity)5 CraftLivingEntity (org.bukkit.craftbukkit.v1_8_R3.entity.CraftLivingEntity)5 LivingEntity (org.bukkit.entity.LivingEntity)5 EntityLiving (net.minecraft.server.v1_16_R3.EntityLiving)4 CraftPlayer (org.bukkit.craftbukkit.v1_12_R1.entity.CraftPlayer)4 CraftLivingEntity (org.bukkit.craftbukkit.v1_16_R1.entity.CraftLivingEntity)4 CraftPlayer (org.bukkit.craftbukkit.v1_16_R1.entity.CraftPlayer)4 CraftLivingEntity (org.bukkit.craftbukkit.v1_9_R2.entity.CraftLivingEntity)4