Search in sources :

Example 46 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) {
    WorldServer server = (WorldServer) NMSImpl.getHandle(player).getWorld();
    EntityTrackerEntry entry = server.getTracker().trackedEntities.get(player.getEntityId());
    if (entry == null)
        return;
    PlayerlistTrackerEntry replace = new PlayerlistTrackerEntry(entry);
    server.getTracker().trackedEntities.a(player.getEntityId(), replace);
    if (TRACKED_ENTITY_SET != null) {
        try {
            Set<Object> set = (Set<Object>) TRACKED_ENTITY_SET.get(server.getTracker());
            set.remove(entry);
            set.add(replace);
        } catch (IllegalArgumentException e) {
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        }
    }
    if (getHandle(player) instanceof EntityHumanNPC) {
        ((EntityHumanNPC) getHandle(player)).setTracked(replace);
    }
}
Also used : EntityTrackerEntry(net.minecraft.server.v1_8_R3.EntityTrackerEntry) EnumSet(java.util.EnumSet) Set(java.util.Set) WorldServer(net.minecraft.server.v1_8_R3.WorldServer) EntityHumanNPC(net.citizensnpcs.nms.v1_8_R3.entity.EntityHumanNPC)

Example 47 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_11_R1.PathEntity) LivingEntity(org.bukkit.entity.LivingEntity) CraftEntity(org.bukkit.craftbukkit.v1_11_R1.entity.CraftEntity) SkinnableEntity(net.citizensnpcs.npc.skin.SkinnableEntity) Entity(net.minecraft.server.v1_11_R1.Entity) EntityInsentient(net.minecraft.server.v1_11_R1.EntityInsentient) ControllerJump(net.minecraft.server.v1_11_R1.ControllerJump) EntityHumanNPC(net.citizensnpcs.nms.v1_11_R1.entity.EntityHumanNPC)

Example 48 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(EntityLiving entity) {
    if (entity instanceof EntityInsentient) {
        EntityInsentient handle = (EntityInsentient) entity;
        handle.getEntitySenses().a();
        NMSImpl.updateNavigation(handle.getNavigation());
        handle.getControllerMove().c();
        handle.getControllerLook().a();
        handle.getControllerJump().b();
    } else if (entity instanceof EntityHumanNPC) {
        ((EntityHumanNPC) entity).updateAI();
    }
}
Also used : EntityInsentient(net.minecraft.server.v1_11_R1.EntityInsentient) EntityHumanNPC(net.citizensnpcs.nms.v1_11_R1.entity.EntityHumanNPC)

Example 49 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) {
    WorldServer server = (WorldServer) NMSImpl.getHandle(player).getWorld();
    EntityTrackerEntry entry = server.getTracker().trackedEntities.get(player.getEntityId());
    if (entry == null)
        return;
    PlayerlistTrackerEntry replace = new PlayerlistTrackerEntry(entry);
    server.getTracker().trackedEntities.a(player.getEntityId(), replace);
    if (TRACKED_ENTITY_SET != null) {
        try {
            Set<Object> set = (Set<Object>) TRACKED_ENTITY_SET.get(server.getTracker());
            set.remove(entry);
            set.add(replace);
        } catch (IllegalArgumentException e) {
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        }
    }
    if (getHandle(player) instanceof EntityHumanNPC) {
        ((EntityHumanNPC) getHandle(player)).setTracked();
    }
}
Also used : EntityTrackerEntry(net.minecraft.server.v1_11_R1.EntityTrackerEntry) EnumSet(java.util.EnumSet) Set(java.util.Set) WorldServer(net.minecraft.server.v1_11_R1.WorldServer) DataWatcherObject(net.minecraft.server.v1_11_R1.DataWatcherObject) EntityHumanNPC(net.citizensnpcs.nms.v1_11_R1.entity.EntityHumanNPC)

Example 50 with EntityHumanNPC

use of net.citizensnpcs.nms.v1_13_R2.entity.EntityHumanNPC 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 : PathEntity(net.minecraft.server.v1_11_R1.PathEntity) LivingEntity(org.bukkit.entity.LivingEntity) CraftEntity(org.bukkit.craftbukkit.v1_11_R1.entity.CraftEntity) SkinnableEntity(net.citizensnpcs.npc.skin.SkinnableEntity) Entity(net.minecraft.server.v1_11_R1.Entity) EntityInsentient(net.minecraft.server.v1_11_R1.EntityInsentient) ControllerMove(net.minecraft.server.v1_11_R1.ControllerMove) EntityHumanNPC(net.citizensnpcs.nms.v1_11_R1.entity.EntityHumanNPC) Location(org.bukkit.Location)

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