use of net.minecraft.server.v1_11_R1.Entity in project MyPet by xXKeyleXx.
the class EntityRegistry method registerEntityTypes.
@Override
@SuppressWarnings("unchecked")
public void registerEntityTypes() {
RegistryMaterials registry = getRegistry();
Object[] backup = backupRegistryID(registry);
for (MyPetType type : entityClasses.keySet()) {
try {
registry.a(type.getTypeID(), null, entityClasses.get(type));
} catch (NullPointerException ignored) {
// NPE means that the entity was registered successfully but the key was not
}
}
restoreRegistryID(registry, backup);
}
use of net.minecraft.server.v1_11_R1.Entity in project MyPet by xXKeyleXx.
the class EntityRegistry method createMinecraftEntity.
@Override
public MyPetMinecraftEntity createMinecraftEntity(MyPet pet, org.bukkit.World bukkitWorld) {
EntityMyPet petEntity = null;
Class<? extends MyPetMinecraftEntity> entityClass = entityClasses.get(pet.getPetType());
World world = ((CraftWorld) bukkitWorld).getHandle();
try {
Constructor<?> ctor = entityClass.getConstructor(World.class, MyPet.class);
Object obj = ctor.newInstance(world, pet);
if (obj instanceof EntityMyPet) {
petEntity = (EntityMyPet) obj;
}
} catch (Exception e) {
MyPetApi.getLogger().info(ChatColor.RED + entityClass.getName() + " is no valid MyPet(Entity)!");
e.printStackTrace();
}
return petEntity;
}
use of net.minecraft.server.v1_11_R1.Entity in project java-docs-samples by GoogleCloudPlatform.
the class Detect method analyzeLabels.
/**
* Performs label analysis on the video at the provided Cloud Storage path.
*
* @param gcsUri the path to the video file to analyze.
*/
public static void analyzeLabels(String gcsUri) throws Exception {
// Instantiate a com.google.cloud.videointelligence.v1.VideoIntelligenceServiceClient
try (VideoIntelligenceServiceClient client = VideoIntelligenceServiceClient.create()) {
// Provide path to file hosted on GCS as "gs://bucket-name/..."
AnnotateVideoRequest request = AnnotateVideoRequest.newBuilder().setInputUri(gcsUri).addFeatures(Feature.LABEL_DETECTION).build();
// Create an operation that will contain the response when the operation completes.
OperationFuture<AnnotateVideoResponse, AnnotateVideoProgress> response = client.annotateVideoAsync(request);
System.out.println("Waiting for operation to complete...");
for (VideoAnnotationResults results : response.get().getAnnotationResultsList()) {
// process video / segment level label annotations
System.out.println("Locations: ");
for (LabelAnnotation labelAnnotation : results.getSegmentLabelAnnotationsList()) {
System.out.println("Video label: " + labelAnnotation.getEntity().getDescription());
// categories
for (Entity categoryEntity : labelAnnotation.getCategoryEntitiesList()) {
System.out.println("Video label category: " + categoryEntity.getDescription());
}
// segments
for (LabelSegment segment : labelAnnotation.getSegmentsList()) {
double startTime = segment.getSegment().getStartTimeOffset().getSeconds() + segment.getSegment().getStartTimeOffset().getNanos() / 1e9;
double endTime = segment.getSegment().getEndTimeOffset().getSeconds() + segment.getSegment().getEndTimeOffset().getNanos() / 1e9;
System.out.printf("Segment location: %.3f:%.3f\n", startTime, endTime);
System.out.println("Confidence: " + segment.getConfidence());
}
}
// process shot label annotations
for (LabelAnnotation labelAnnotation : results.getShotLabelAnnotationsList()) {
System.out.println("Shot label: " + labelAnnotation.getEntity().getDescription());
// categories
for (Entity categoryEntity : labelAnnotation.getCategoryEntitiesList()) {
System.out.println("Shot label category: " + categoryEntity.getDescription());
}
// segments
for (LabelSegment segment : labelAnnotation.getSegmentsList()) {
double startTime = segment.getSegment().getStartTimeOffset().getSeconds() + segment.getSegment().getStartTimeOffset().getNanos() / 1e9;
double endTime = segment.getSegment().getEndTimeOffset().getSeconds() + segment.getSegment().getEndTimeOffset().getNanos() / 1e9;
System.out.printf("Segment location: %.3f:%.3f\n", startTime, endTime);
System.out.println("Confidence: " + segment.getConfidence());
}
}
// process frame label annotations
for (LabelAnnotation labelAnnotation : results.getFrameLabelAnnotationsList()) {
System.out.println("Frame label: " + labelAnnotation.getEntity().getDescription());
// categories
for (Entity categoryEntity : labelAnnotation.getCategoryEntitiesList()) {
System.out.println("Frame label category: " + categoryEntity.getDescription());
}
// segments
for (LabelSegment segment : labelAnnotation.getSegmentsList()) {
double startTime = segment.getSegment().getStartTimeOffset().getSeconds() + segment.getSegment().getStartTimeOffset().getNanos() / 1e9;
double endTime = segment.getSegment().getEndTimeOffset().getSeconds() + segment.getSegment().getEndTimeOffset().getNanos() / 1e9;
System.out.printf("Segment location: %.3f:%.2f\n", startTime, endTime);
System.out.println("Confidence: " + segment.getConfidence());
}
}
}
}
// [END detect_labels_gcs]
}
use of net.minecraft.server.v1_11_R1.Entity in project java-docs-samples by GoogleCloudPlatform.
the class QuickstartSample method main.
/**
* Demonstrates using the video intelligence client to detect labels in a video file.
*/
public static void main(String[] args) throws Exception {
// Instantiate a video intelligence client
try (VideoIntelligenceServiceClient client = VideoIntelligenceServiceClient.create()) {
// The Google Cloud Storage path to the video to annotate.
String gcsUri = "gs://demomaker/cat.mp4";
// Create an operation that will contain the response when the operation completes.
AnnotateVideoRequest request = AnnotateVideoRequest.newBuilder().setInputUri(gcsUri).addFeatures(Feature.LABEL_DETECTION).build();
OperationFuture<AnnotateVideoResponse, AnnotateVideoProgress> response = client.annotateVideoAsync(request);
System.out.println("Waiting for operation to complete...");
List<VideoAnnotationResults> results = response.get().getAnnotationResultsList();
if (results.isEmpty()) {
System.out.println("No labels detected in " + gcsUri);
return;
}
for (VideoAnnotationResults result : results) {
System.out.println("Labels:");
// get video segment label annotations
for (LabelAnnotation annotation : result.getSegmentLabelAnnotationsList()) {
System.out.println("Video label description : " + annotation.getEntity().getDescription());
// categories
for (Entity categoryEntity : annotation.getCategoryEntitiesList()) {
System.out.println("Label Category description : " + categoryEntity.getDescription());
}
// segments
for (LabelSegment segment : annotation.getSegmentsList()) {
double startTime = segment.getSegment().getStartTimeOffset().getSeconds() + segment.getSegment().getStartTimeOffset().getNanos() / 1e9;
double endTime = segment.getSegment().getEndTimeOffset().getSeconds() + segment.getSegment().getEndTimeOffset().getNanos() / 1e9;
System.out.printf("Segment location : %.3f:%.3f\n", startTime, endTime);
System.out.println("Confidence : " + segment.getConfidence());
}
}
}
}
}
use of net.minecraft.server.v1_11_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;
}
Aggregations