Search in sources :

Example 11 with Entity

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

the class NMSImpl method tick.

@Override
public boolean tick(org.bukkit.entity.Entity next) {
    Entity entity = NMSImpl.getHandle(next);
    Entity entity1 = entity.bB();
    if (entity1 != null) {
        if ((entity1.dead) || (!entity1.w(entity))) {
            entity.stopRiding();
        }
    } else {
        if (!entity.dead) {
            try {
                entity.world.g(entity);
            } catch (Throwable throwable) {
                CrashReport crashreport = CrashReport.a(throwable, "Ticking player");
                CrashReportSystemDetails crashreportsystemdetails = crashreport.a("Player being ticked");
                entity.appendEntityCrashDetails(crashreportsystemdetails);
                throw new ReportedException(crashreport);
            }
        }
        boolean removeFromPlayerList = ((NPCHolder) entity).getNPC().data().get("removefromplayerlist", Setting.REMOVE_PLAYERS_FROM_PLAYER_LIST.asBoolean());
        if (entity.dead) {
            entity.world.removeEntity(entity);
            return true;
        } else if (!removeFromPlayerList) {
            if (!entity.world.players.contains(entity)) {
                entity.world.players.add((EntityHuman) entity);
            }
            return true;
        } else {
            entity.world.players.remove(entity);
        }
    }
    return false;
}
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) EntityHuman(net.minecraft.server.v1_10_R1.EntityHuman) CrashReportSystemDetails(net.minecraft.server.v1_10_R1.CrashReportSystemDetails) CrashReport(net.minecraft.server.v1_10_R1.CrashReport) NPCHolder(net.citizensnpcs.npc.ai.NPCHolder) ReportedException(net.minecraft.server.v1_10_R1.ReportedException)

Example 12 with Entity

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

the class NMSImpl method removeFromWorld.

@Override
public void removeFromWorld(org.bukkit.entity.Entity entity) {
    Preconditions.checkNotNull(entity);
    Entity nmsEntity = ((CraftEntity) entity).getHandle();
    nmsEntity.world.removeEntity(nmsEntity);
}
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) CraftEntity(org.bukkit.craftbukkit.v1_10_R1.entity.CraftEntity)

Example 13 with Entity

use of net.minecraft.server.v1_9_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_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)

Example 14 with Entity

use of net.minecraft.server.v1_9_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_8_R3.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_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) MCNavigator(net.citizensnpcs.npc.ai.MCNavigationStrategy.MCNavigator) EntityHorse(net.minecraft.server.v1_8_R3.EntityHorse) CancelReason(net.citizensnpcs.api.ai.event.CancelReason) NPCHolder(net.citizensnpcs.npc.ai.NPCHolder) NavigationAbstract(net.minecraft.server.v1_8_R3.NavigationAbstract) Vector(org.bukkit.util.Vector) Entity(net.minecraft.server.v1_8_R3.Entity)

Example 15 with Entity

use of net.minecraft.server.v1_9_R1.Entity 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)

Aggregations

SkinnableEntity (net.citizensnpcs.npc.skin.SkinnableEntity)41 LivingEntity (org.bukkit.entity.LivingEntity)38 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 CraftEntity (org.bukkit.craftbukkit.v1_12_R1.entity.CraftEntity)10 Entity (com.google.datastore.v1.Entity)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_10_R1.entity.CraftEntity)9 CraftEntity (org.bukkit.craftbukkit.v1_11_R1.entity.CraftEntity)9 CraftEntity (org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity)9 NPCHolder (net.citizensnpcs.npc.ai.NPCHolder)8 DeleteEntity (org.apache.beam.sdk.io.gcp.datastore.DatastoreV1.DeleteEntity)6 Key (com.google.datastore.v1.Key)5 Player (org.bukkit.entity.Player)5 Document (com.google.cloud.language.v1.Document)4