Search in sources :

Example 61 with Entity

use of net.minecraft.server.v1_10_R1.Entity in project Citizens2 by CitizensDev.

the class NMSImpl method getBossBar.

public static BossBar getBossBar(org.bukkit.entity.Entity entity) {
    BossBattleServer bserver = null;
    try {
        if (entity.getType() == EntityType.WITHER) {
            bserver = (BossBattleServer) WITHER_BOSS_BAR_FIELD.get(NMSImpl.getHandle(entity));
        } else if (entity.getType() == EntityType.ENDER_DRAGON) {
            bserver = (BossBattleServer) ENDERDRAGON_BATTLE_BAR_FIELD.get(ENDERDRAGON_BATTLE_FIELD.get(NMSImpl.getHandle(entity)));
        }
    } catch (Exception e) {
    }
    if (bserver == null) {
        return null;
    }
    BossBar ret = Bukkit.createBossBar("", BarColor.BLUE, BarStyle.SEGMENTED_10);
    try {
        CRAFT_BOSSBAR_HANDLE_FIELD.set(ret, bserver);
    } catch (Exception e) {
    }
    return ret;
}
Also used : BossBar(org.bukkit.boss.BossBar) CraftBossBar(org.bukkit.craftbukkit.v1_10_R1.boss.CraftBossBar) BossBattleServer(net.minecraft.server.v1_10_R1.BossBattleServer) ReportedException(net.minecraft.server.v1_10_R1.ReportedException) CommandException(net.citizensnpcs.api.command.exception.CommandException)

Example 62 with Entity

use of net.minecraft.server.v1_10_R1.Entity 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_10_R1.EntityInsentient) EntityHumanNPC(net.citizensnpcs.nms.v1_10_R1.entity.EntityHumanNPC)

Example 63 with Entity

use of net.minecraft.server.v1_10_R1.Entity in project Citizens2 by CitizensDev.

the class NMSImpl method registerEntityClass.

@Override
public void registerEntityClass(Class<?> clazz) {
    if (ENTITY_CLASS_TO_INT == null || ENTITY_CLASS_TO_INT.containsKey(clazz))
        return;
    Class<?> search = clazz;
    while ((search = search.getSuperclass()) != null && Entity.class.isAssignableFrom(search)) {
        if (!ENTITY_CLASS_TO_INT.containsKey(search))
            continue;
        int code = ENTITY_CLASS_TO_INT.get(search);
        ENTITY_CLASS_TO_INT.put(clazz, code);
        ENTITY_CLASS_TO_NAME.put(clazz, ENTITY_CLASS_TO_NAME.get(search));
        return;
    }
    throw new IllegalArgumentException("unable to find valid entity superclass for class " + clazz.toString());
}
Also used : PathEntity(net.minecraft.server.v1_10_R1.PathEntity) LivingEntity(org.bukkit.entity.LivingEntity) SkinnableEntity(net.citizensnpcs.npc.skin.SkinnableEntity) CraftEntity(org.bukkit.craftbukkit.v1_10_R1.entity.CraftEntity) Entity(net.minecraft.server.v1_10_R1.Entity) PathPoint(net.minecraft.server.v1_10_R1.PathPoint)

Example 64 with Entity

use of net.minecraft.server.v1_10_R1.Entity in project Citizens2 by CitizensDev.

the class NMSImpl method getTargetNavigator.

private MCNavigator getTargetNavigator(final org.bukkit.entity.Entity entity, final NavigatorParameters params, final Function<NavigationAbstract, Boolean> function) {
    net.minecraft.server.v1_10_R1.Entity raw = getHandle(entity);
    raw.onGround = true;
    // not sure of a better way around this - if onGround is false, then
    // navigation won't execute, and calling entity.move doesn't
    // entirely fix the problem.
    final NavigationAbstract navigation = NMSImpl.getNavigation(entity);
    return new MCNavigator() {

        float lastSpeed;

        CancelReason reason;

        @Override
        public CancelReason getCancelReason() {
            return reason;
        }

        @Override
        public Iterable<Vector> getPath() {
            return new NavigationIterable(navigation);
        }

        @Override
        public void stop() {
            stopNavigation(navigation);
        }

        @Override
        public boolean update() {
            if (params.speed() != lastSpeed) {
                if (Messaging.isDebugging()) {
                    Messaging.debug("Repathfinding " + ((NPCHolder) entity).getNPC().getId() + " due to speed change");
                }
                Entity handle = getHandle(entity);
                float oldWidth = handle.width;
                if (handle instanceof EntityHorse) {
                    handle.width = Math.min(0.99f, oldWidth);
                }
                if (!function.apply(navigation)) {
                    reason = CancelReason.STUCK;
                }
                // minecraft requires that an entity fit onto both blocks if width >= 1f,
                handle.width = oldWidth;
                // but we'd prefer to make it just fit on 1 so hack around it a bit.
                lastSpeed = params.speed();
            }
            navigation.a(params.speed());
            return NMSImpl.isNavigationFinished(navigation);
        }
    };
}
Also used : PathEntity(net.minecraft.server.v1_10_R1.PathEntity) LivingEntity(org.bukkit.entity.LivingEntity) SkinnableEntity(net.citizensnpcs.npc.skin.SkinnableEntity) CraftEntity(org.bukkit.craftbukkit.v1_10_R1.entity.CraftEntity) Entity(net.minecraft.server.v1_10_R1.Entity) MCNavigator(net.citizensnpcs.npc.ai.MCNavigationStrategy.MCNavigator) EntityHorse(net.minecraft.server.v1_10_R1.EntityHorse) CancelReason(net.citizensnpcs.api.ai.event.CancelReason) NPCHolder(net.citizensnpcs.npc.ai.NPCHolder) NavigationAbstract(net.minecraft.server.v1_10_R1.NavigationAbstract) Entity(net.minecraft.server.v1_10_R1.Entity) Vector(org.bukkit.util.Vector)

Example 65 with Entity

use of net.minecraft.server.v1_10_R1.Entity in project Citizens2 by CitizensDev.

the class NMSImpl method look.

@Override
public void look(org.bukkit.entity.Entity entity, float yaw, float pitch) {
    Entity handle = NMSImpl.getHandle(entity);
    if (handle == null)
        return;
    yaw = Util.clampYaw(yaw);
    handle.yaw = yaw;
    setHeadYaw(entity, yaw);
    handle.pitch = pitch;
}
Also used : PathEntity(net.minecraft.server.v1_10_R1.PathEntity) LivingEntity(org.bukkit.entity.LivingEntity) SkinnableEntity(net.citizensnpcs.npc.skin.SkinnableEntity) CraftEntity(org.bukkit.craftbukkit.v1_10_R1.entity.CraftEntity) Entity(net.minecraft.server.v1_10_R1.Entity)

Aggregations

SkinnableEntity (net.citizensnpcs.npc.skin.SkinnableEntity)41 LivingEntity (org.bukkit.entity.LivingEntity)39 CraftEntity (org.bukkit.craftbukkit.v1_10_R1.entity.CraftEntity)17 Entity (net.minecraft.server.v1_12_R1.Entity)13 Entity (net.minecraft.server.v1_11_R1.Entity)12 Entity (net.minecraft.server.v1_8_R3.Entity)11 Entity (net.minecraft.server.v1_10_R1.Entity)10 PathEntity (net.minecraft.server.v1_12_R1.PathEntity)10 NPCHolder (net.citizensnpcs.npc.ai.NPCHolder)9 PathEntity (net.minecraft.server.v1_10_R1.PathEntity)9 PathEntity (net.minecraft.server.v1_11_R1.PathEntity)9 PathEntity (net.minecraft.server.v1_8_R3.PathEntity)9 CraftEntity (org.bukkit.craftbukkit.v1_11_R1.entity.CraftEntity)9 CraftEntity (org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity)9 Entity (com.google.datastore.v1.Entity)8 CraftEntity (org.bukkit.craftbukkit.v1_12_R1.entity.CraftEntity)8 DeleteEntity (org.apache.beam.sdk.io.gcp.datastore.DatastoreV1.DeleteEntity)6 CommandException (net.citizensnpcs.api.command.exception.CommandException)5 CraftWorld (org.bukkit.craftbukkit.v1_10_R1.CraftWorld)5 Player (org.bukkit.entity.Player)5