Search in sources :

Example 31 with EntityHumanNPC

use of net.citizensnpcs.nms.v1_13_R2.entity.EntityHumanNPC in project Citizens2 by CitizensDev.

the class NMSImpl method updateAI.

public static void updateAI(LivingEntity entity) {
    if (entity instanceof Mob) {
        Mob handle = (Mob) entity;
        handle.getSensing().tick();
        handle.getNavigation().tick();
        handle.getMoveControl().tick();
        handle.getLookControl().tick();
        handle.getJumpControl().tick();
    } else if (entity instanceof EntityHumanNPC) {
        ((EntityHumanNPC) entity).updateAI();
    }
}
Also used : Mob(net.minecraft.world.entity.Mob) EntityHumanNPC(net.citizensnpcs.nms.v1_17_R1.entity.EntityHumanNPC)

Example 32 with EntityHumanNPC

use of net.citizensnpcs.nms.v1_13_R2.entity.EntityHumanNPC in project Citizens2 by CitizensDev.

the class NMSImpl method replaceTrackerEntry.

@Override
public void replaceTrackerEntry(Player player) {
    ServerLevel server = (ServerLevel) NMSImpl.getHandle(player).level;
    TrackedEntity entry = server.getChunkProvider().chunkMap.G.get(player.getEntityId());
    if (entry == null)
        return;
    PlayerlistTracker replace = new PlayerlistTracker(server.getChunkProvider().chunkMap, entry);
    server.getChunkProvider().chunkMap.G.put(player.getEntityId(), replace);
    if (getHandle(player) instanceof EntityHumanNPC) {
        ((EntityHumanNPC) getHandle(player)).setTracked(replace);
    }
}
Also used : ServerLevel(net.minecraft.server.level.ServerLevel) TrackedEntity(net.minecraft.server.level.ChunkMap.TrackedEntity) EntityHumanNPC(net.citizensnpcs.nms.v1_17_R1.entity.EntityHumanNPC)

Example 33 with EntityHumanNPC

use of net.citizensnpcs.nms.v1_13_R2.entity.EntityHumanNPC 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 34 with EntityHumanNPC

use of net.citizensnpcs.nms.v1_13_R2.entity.EntityHumanNPC 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.a();
    } else if (handle instanceof EntityHumanNPC) {
        ((EntityHumanNPC) handle).setShouldJump();
    }
}
Also used : PathEntity(net.minecraft.server.v1_8_R3.PathEntity) LivingEntity(org.bukkit.entity.LivingEntity) Entity(net.minecraft.server.v1_8_R3.Entity) CraftEntity(org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity) SkinnableEntity(net.citizensnpcs.npc.skin.SkinnableEntity) EntityInsentient(net.minecraft.server.v1_8_R3.EntityInsentient) ControllerJump(net.minecraft.server.v1_8_R3.ControllerJump) EntityHumanNPC(net.citizensnpcs.nms.v1_8_R3.entity.EntityHumanNPC)

Example 35 with EntityHumanNPC

use of net.citizensnpcs.nms.v1_13_R2.entity.EntityHumanNPC in project Citizens2 by CitizensDev.

the class PlayerControllerMove method c.

@Override
public void c() {
    this.a.ba = 0F;
    if (this.f) {
        this.f = false;
        double dX = this.b - this.a.locX;
        double dZ = this.d - this.a.locZ;
        double dY = this.c - this.a.locY;
        double dXZ = Math.sqrt(dX * dX + dZ * dZ);
        if (Math.abs(dY) < 1.0 && dXZ < 0.025)
            return;
        float f = (float) Math.toDegrees(Math.atan2(dZ, dX)) - 90.0F;
        this.a.yaw = a(this.a.yaw, f, 90.0F);
        NMS.setHeadYaw(a.getBukkitEntity(), this.a.yaw);
        AttributeInstance speed = this.a.getAttributeInstance(GenericAttributes.MOVEMENT_SPEED);
        speed.setValue(0.1D * this.e);
        float movement = (float) (this.e * speed.getValue()) * 10;
        this.a.k(movement);
        this.a.ba = movement;
        if (shouldSlimeJump() || ((dY >= NMS.getStepHeight(a.getBukkitEntity())) && dXZ < 0.4)) {
            this.h = cg();
            this.h /= 3;
            if (this.a instanceof EntityHumanNPC) {
                ((EntityHumanNPC) this.a).getControllerJump().a();
            } else {
                ((EntityInsentient) this.a).getControllerJump().a();
            }
        }
    }
}
Also used : AttributeInstance(net.minecraft.server.v1_8_R3.AttributeInstance) EntityHumanNPC(net.citizensnpcs.nms.v1_8_R3.entity.EntityHumanNPC)

Aggregations

SkinnableEntity (net.citizensnpcs.npc.skin.SkinnableEntity)44 LivingEntity (org.bukkit.entity.LivingEntity)32 Location (org.bukkit.Location)20 Mob (net.minecraft.world.entity.Mob)14 Player (org.bukkit.entity.Player)12 Set (java.util.Set)10 EntityHumanNPC (net.citizensnpcs.nms.v1_12_R1.entity.EntityHumanNPC)10 TrackedEntity (net.minecraft.server.level.ChunkMap.TrackedEntity)10 LivingEntity (net.minecraft.world.entity.LivingEntity)10 CancelReason (net.citizensnpcs.api.ai.event.CancelReason)9 EntityHumanNPC (net.citizensnpcs.nms.v1_10_R1.entity.EntityHumanNPC)9 EntityHumanNPC (net.citizensnpcs.nms.v1_14_R1.entity.EntityHumanNPC)9 EntityHumanNPC (net.citizensnpcs.nms.v1_15_R1.entity.EntityHumanNPC)9 EntityHumanNPC (net.citizensnpcs.nms.v1_17_R1.entity.EntityHumanNPC)9 EntityHumanNPC (net.citizensnpcs.nms.v1_18_R2.entity.EntityHumanNPC)9 EntityHumanNPC (net.citizensnpcs.nms.v1_8_R3.entity.EntityHumanNPC)8 Entity (net.minecraft.world.entity.Entity)8 EntityHumanNPC (net.citizensnpcs.nms.v1_11_R1.entity.EntityHumanNPC)7 EntityHumanNPC (net.citizensnpcs.nms.v1_16_R3.entity.EntityHumanNPC)7 MCNavigator (net.citizensnpcs.npc.ai.MCNavigationStrategy.MCNavigator)7