Search in sources :

Example 21 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.entityJoinedWorld(entity, true);
            } 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_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) EntityHuman(net.minecraft.server.v1_11_R1.EntityHuman) CrashReportSystemDetails(net.minecraft.server.v1_11_R1.CrashReportSystemDetails) CrashReport(net.minecraft.server.v1_11_R1.CrashReport) NPCHolder(net.citizensnpcs.npc.ai.NPCHolder) ReportedException(net.minecraft.server.v1_11_R1.ReportedException)

Example 22 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, Location to, boolean headOnly, boolean immediate) {
    Entity handle = NMSImpl.getHandle(entity);
    if (immediate || headOnly || BAD_CONTROLLER_LOOK.contains(handle.getBukkitEntity().getType()) || (!(handle instanceof EntityInsentient) && !(handle instanceof EntityHumanNPC))) {
        Location fromLocation = entity.getLocation(FROM_LOCATION);
        double xDiff, yDiff, zDiff;
        xDiff = to.getX() - fromLocation.getX();
        yDiff = to.getY() - fromLocation.getY();
        zDiff = to.getZ() - fromLocation.getZ();
        double distanceXZ = Math.sqrt(xDiff * xDiff + zDiff * zDiff);
        double distanceY = Math.sqrt(distanceXZ * distanceXZ + yDiff * yDiff);
        double yaw = Math.toDegrees(Math.acos(xDiff / distanceXZ));
        double pitch = Math.toDegrees(Math.acos(yDiff / distanceY)) - 90;
        if (zDiff < 0.0)
            yaw += Math.abs(180 - yaw) * 2;
        if (handle instanceof EntityEnderDragon) {
            yaw = getDragonYaw(handle, to.getX(), to.getZ());
        } else {
            yaw = yaw - 90;
        }
        if (headOnly) {
            setHeadYaw(entity, (float) yaw);
        } else {
            look(entity, (float) yaw, (float) pitch);
        }
        return;
    }
    if (handle instanceof EntityInsentient) {
        ((EntityInsentient) handle).getControllerLook().a(to.getX(), to.getY(), to.getZ(), ((EntityInsentient) handle).cL(), ((EntityInsentient) handle).N());
        while (((EntityLiving) handle).aP >= 180F) {
            ((EntityLiving) handle).aP -= 360F;
        }
        while (((EntityLiving) handle).aP < -180F) {
            ((EntityLiving) handle).aP += 360F;
        }
    } else if (handle instanceof EntityHumanNPC) {
        ((EntityHumanNPC) handle).setTargetLook(to);
    }
}
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) EntityEnderDragon(net.minecraft.server.v1_11_R1.EntityEnderDragon) EntityInsentient(net.minecraft.server.v1_11_R1.EntityInsentient) EntityHumanNPC(net.citizensnpcs.nms.v1_11_R1.entity.EntityHumanNPC) Location(org.bukkit.Location)

Example 23 with Entity

use of net.minecraft.server.v1_9_R1.Entity in project NoCheatPlus by NoCheatPlus.

the class MCAccessSpigotCB1_9_R1 method getHeight.

@Override
public double getHeight(final Entity entity) {
    final net.minecraft.server.v1_9_R1.Entity mcEntity = ((CraftEntity) entity).getHandle();
    AxisAlignedBB boundingBox = mcEntity.getBoundingBox();
    final double entityHeight = Math.max(mcEntity.length, Math.max(mcEntity.getHeadHeight(), boundingBox.e - boundingBox.b));
    if (entity instanceof LivingEntity) {
        return Math.max(((LivingEntity) entity).getEyeHeight(), entityHeight);
    } else
        return entityHeight;
}
Also used : AxisAlignedBB(net.minecraft.server.v1_9_R1.AxisAlignedBB) LivingEntity(org.bukkit.entity.LivingEntity) CraftEntity(org.bukkit.craftbukkit.v1_9_R1.entity.CraftEntity)

Example 24 with Entity

use of net.minecraft.server.v1_9_R1.Entity in project beam by apache.

the class V1ReadIT method writeEntitiesToDatastore.

// Creates entities and write them to datastore
private static void writeEntitiesToDatastore(V1TestOptions options, String project, String ancestor, long numEntities) throws Exception {
    Datastore datastore = getDatastore(options, project);
    // Write test entities to datastore
    V1TestWriter writer = new V1TestWriter(datastore, new UpsertMutationBuilder());
    Key ancestorKey = makeAncestorKey(options.getNamespace(), options.getKind(), ancestor);
    for (long i = 0; i < numEntities; i++) {
        Entity entity = makeEntity(i, ancestorKey, options.getKind(), options.getNamespace(), 0);
        writer.write(entity);
    }
    writer.close();
}
Also used : Entity(com.google.datastore.v1.Entity) V1TestUtil.makeEntity(org.apache.beam.sdk.io.gcp.datastore.V1TestUtil.makeEntity) UpsertMutationBuilder(org.apache.beam.sdk.io.gcp.datastore.V1TestUtil.UpsertMutationBuilder) V1TestUtil.getDatastore(org.apache.beam.sdk.io.gcp.datastore.V1TestUtil.getDatastore) Datastore(com.google.datastore.v1.client.Datastore) V1TestWriter(org.apache.beam.sdk.io.gcp.datastore.V1TestUtil.V1TestWriter) V1TestUtil.makeAncestorKey(org.apache.beam.sdk.io.gcp.datastore.V1TestUtil.makeAncestorKey) Key(com.google.datastore.v1.Key)

Example 25 with Entity

use of net.minecraft.server.v1_9_R1.Entity in project beam by apache.

the class V1TestUtil method deleteAllEntities.

/**
   * Delete all entities with the given ancestor.
   */
static void deleteAllEntities(V1TestOptions options, String project, String ancestor) throws Exception {
    Datastore datastore = getDatastore(options, project);
    Query query = V1TestUtil.makeAncestorKindQuery(options.getKind(), options.getNamespace(), ancestor);
    V1TestReader reader = new V1TestReader(datastore, query, options.getNamespace());
    V1TestWriter writer = new V1TestWriter(datastore, new DeleteMutationBuilder());
    long numEntities = 0;
    while (reader.advance()) {
        Entity entity = reader.getCurrent();
        numEntities++;
        writer.write(entity);
    }
    writer.close();
    LOG.info("Successfully deleted {} entities", numEntities);
}
Also used : Entity(com.google.datastore.v1.Entity) Datastore(com.google.datastore.v1.client.Datastore) Query(com.google.datastore.v1.Query)

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