Search in sources :

Example 66 with EntityInsentient

use of net.minecraft.server.v1_14_R1.EntityInsentient in project Citizens2 by CitizensDev.

the class NMSImpl method setShouldJump.

@Override
public void setShouldJump(org.bukkit.entity.Entity entity) {
    Entity handle = NMSImpl.getHandle(entity);
    if (handle == null)
        return;
    if (handle instanceof EntityInsentient) {
        ControllerJump controller = ((EntityInsentient) handle).getControllerJump();
        controller.jump();
    } else if (handle instanceof EntityHumanNPC) {
        ((EntityHumanNPC) handle).setShouldJump();
    }
}
Also used : Entity(net.minecraft.server.v1_16_R3.Entity) LivingEntity(org.bukkit.entity.LivingEntity) SkinnableEntity(net.citizensnpcs.npc.skin.SkinnableEntity) CraftEntity(org.bukkit.craftbukkit.v1_16_R3.entity.CraftEntity) PathEntity(net.minecraft.server.v1_16_R3.PathEntity) EntityInsentient(net.minecraft.server.v1_16_R3.EntityInsentient) ControllerJump(net.minecraft.server.v1_16_R3.ControllerJump) EntityHumanNPC(net.citizensnpcs.nms.v1_16_R3.entity.EntityHumanNPC)

Example 67 with EntityInsentient

use of net.minecraft.server.v1_14_R1.EntityInsentient 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 (NAVIGATION_S == null)
        return;
    NavigationAbstract navigation = ((EntityInsentient) en).getNavigation();
    AttributeModifiable inst = en.getAttributeInstance(GenericAttributes.FOLLOW_RANGE);
    inst.setValue(pathfindingRange);
    int mc = MathHelper.floor(en.b(GenericAttributes.FOLLOW_RANGE) * 16.0D);
    try {
        NAVIGATION_S.invoke(navigation, NAVIGATION_A.invoke(navigation, mc));
    } catch (Throwable e) {
        e.printStackTrace();
    }
}
Also used : EntityLiving(net.minecraft.server.v1_16_R3.EntityLiving) AttributeModifiable(net.minecraft.server.v1_16_R3.AttributeModifiable) EntityInsentient(net.minecraft.server.v1_16_R3.EntityInsentient) NavigationAbstract(net.minecraft.server.v1_16_R3.NavigationAbstract) PathPoint(net.minecraft.server.v1_16_R3.PathPoint) EntityHumanNPC(net.citizensnpcs.nms.v1_16_R3.entity.EntityHumanNPC)

Example 68 with EntityInsentient

use of net.minecraft.server.v1_14_R1.EntityInsentient 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) handle).attack(target);
        PlayerAnimation.ARM_SWING.play((Player) handle.getBukkitEntity());
        return;
    }
    if (handle instanceof EntityInsentient) {
        ((EntityInsentient) handle).attackEntity(target);
        return;
    }
    AttributeModifiable 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.setMot(handle.getMot().d(0.6, 1, 0.6));
    }
    int fireAspectLevel = EnchantmentManager.getFireAspectEnchantmentLevel(handle);
    if (fireAspectLevel > 0) {
        target.setOnFire(fireAspectLevel * 4);
    }
}
Also used : EntityLiving(net.minecraft.server.v1_16_R3.EntityLiving) AttributeModifiable(net.minecraft.server.v1_16_R3.AttributeModifiable) EntityPlayer(net.minecraft.server.v1_16_R3.EntityPlayer) EntityInsentient(net.minecraft.server.v1_16_R3.EntityInsentient) PathPoint(net.minecraft.server.v1_16_R3.PathPoint)

Example 69 with EntityInsentient

use of net.minecraft.server.v1_14_R1.EntityInsentient in project Citizens2 by CitizensDev.

the class NMSImpl method getDestination.

@Override
public Location getDestination(org.bukkit.entity.Entity entity) {
    Entity handle = getHandle(entity);
    ControllerMove controller = handle instanceof EntityInsentient ? ((EntityInsentient) handle).getControllerMove() : handle instanceof EntityHumanNPC ? ((EntityHumanNPC) handle).getControllerMove() : null;
    return new Location(entity.getWorld(), controller.d(), controller.e(), controller.f());
}
Also used : Entity(net.minecraft.server.v1_16_R3.Entity) LivingEntity(org.bukkit.entity.LivingEntity) SkinnableEntity(net.citizensnpcs.npc.skin.SkinnableEntity) CraftEntity(org.bukkit.craftbukkit.v1_16_R3.entity.CraftEntity) PathEntity(net.minecraft.server.v1_16_R3.PathEntity) EntityInsentient(net.minecraft.server.v1_16_R3.EntityInsentient) ControllerMove(net.minecraft.server.v1_16_R3.ControllerMove) EntityHumanNPC(net.citizensnpcs.nms.v1_16_R3.entity.EntityHumanNPC) Location(org.bukkit.Location)

Example 70 with EntityInsentient

use of net.minecraft.server.v1_14_R1.EntityInsentient in project Citizens2 by CitizensDev.

the class NMSImpl method updateAI.

public static void updateAI(EntityLiving entity) {
    if (entity instanceof EntityInsentient) {
        EntityInsentient handle = (EntityInsentient) entity;
        handle.getEntitySenses().a();
        NMSImpl.updateNavigation(handle.getNavigation());
        handle.getControllerMove().a();
        handle.getControllerLook().a();
        handle.getControllerJump().b();
    } else if (entity instanceof EntityHumanNPC) {
        ((EntityHumanNPC) entity).updateAI();
    }
}
Also used : EntityInsentient(net.minecraft.server.v1_16_R3.EntityInsentient) EntityHumanNPC(net.citizensnpcs.nms.v1_16_R3.entity.EntityHumanNPC)

Aggregations

LivingEntity (org.bukkit.entity.LivingEntity)43 SkinnableEntity (net.citizensnpcs.npc.skin.SkinnableEntity)42 Location (org.bukkit.Location)19 EntityInsentient (net.minecraft.server.v1_16_R3.EntityInsentient)12 EntityInsentient (net.minecraft.server.v1_15_R1.EntityInsentient)11 NPCHolder (net.citizensnpcs.npc.ai.NPCHolder)9 CommandException (net.citizensnpcs.api.command.exception.CommandException)8 EntityHumanNPC (net.citizensnpcs.nms.v1_14_R1.entity.EntityHumanNPC)8 EntityHumanNPC (net.citizensnpcs.nms.v1_15_R1.entity.EntityHumanNPC)8 EntityHumanNPC (net.citizensnpcs.nms.v1_16_R3.entity.EntityHumanNPC)8 EntityInsentient (net.minecraft.server.v1_12_R1.EntityInsentient)8 EntityInsentient (net.minecraft.server.v1_14_R1.EntityInsentient)8 CancelReason (net.citizensnpcs.api.ai.event.CancelReason)7 EntityHumanNPC (net.citizensnpcs.nms.v1_12_R1.entity.EntityHumanNPC)7 MCNavigator (net.citizensnpcs.npc.ai.MCNavigationStrategy.MCNavigator)7 EntityInsentient (net.minecraft.server.v1_11_R1.EntityInsentient)7 PathEntity (net.minecraft.server.v1_14_R1.PathEntity)7 PathEntity (net.minecraft.server.v1_15_R1.PathEntity)7 PathEntity (net.minecraft.server.v1_16_R3.PathEntity)7 EntityInsentient (net.minecraft.server.v1_8_R3.EntityInsentient)7