Search in sources :

Example 51 with Entity

use of net.minecraft.server.v1_11_R1.Entity in project MyPet by xXKeyleXx.

the class PlatformHelper method applyTagToEntity.

@Override
public void applyTagToEntity(TagCompound tag, Entity bukkitEntity) {
    net.minecraft.server.v1_11_R1.Entity entity = ((CraftEntity) bukkitEntity).getHandle();
    NBTTagCompound vanillaNBT = (NBTTagCompound) ItemStackNBTConverter.compoundToVanillaCompound(tag);
    // Just a temporary fix until I come up with a better solution
    if (bukkitEntity instanceof Villager) {
        EntityVillager villager = (EntityVillager) entity;
        villager.setProfession(vanillaNBT.getInt("Profession"));
        villager.riches = vanillaNBT.getInt("Riches");
        ReflectionUtil.setFieldValue("bJ", villager, vanillaNBT.getInt("Career"));
        ReflectionUtil.setFieldValue("bK", villager, vanillaNBT.getInt("CareerLevel"));
        ReflectionUtil.setFieldValue("bG", villager, vanillaNBT.getBoolean("Willing"));
        if (vanillaNBT.hasKeyOfType("Offers", 10)) {
            NBTTagCompound nbttaglist = vanillaNBT.getCompound("Offers");
            ReflectionUtil.setFieldValue("trades", villager, new MerchantRecipeList(nbttaglist));
        }
        NBTTagList invTag = vanillaNBT.getList("Inventory", 10);
        for (int i = 0; i < invTag.size(); ++i) {
            ItemStack itemstack = new ItemStack(invTag.get(i));
            villager.inventory.a(itemstack);
        }
        villager.m(true);
        if (villager.isBaby()) {
            villager.goalSelector.a(8, new PathfinderGoalPlay(villager, 0.32D));
        } else if (villager.getProfession() == 0) {
            villager.goalSelector.a(6, new PathfinderGoalVillagerFarm(villager, 0.6D));
        }
    }
// can not be used in 1.10
// entity.f(vanillaNBT);
}
Also used : CraftEntity(org.bukkit.craftbukkit.v1_11_R1.entity.CraftEntity) net.minecraft.server.v1_11_R1(net.minecraft.server.v1_11_R1) Villager(org.bukkit.entity.Villager) CraftItemStack(org.bukkit.craftbukkit.v1_11_R1.inventory.CraftItemStack)

Example 52 with Entity

use of net.minecraft.server.v1_11_R1.Entity in project java-docs-samples by GoogleCloudPlatform.

the class Analyze method analyzeEntitiesText.

/**
 * Identifies entities in the string {@code text}.
 */
public static void analyzeEntitiesText(String text) throws Exception {
    // Instantiate the Language client com.google.cloud.language.v1.LanguageServiceClient
    try (LanguageServiceClient language = LanguageServiceClient.create()) {
        Document doc = Document.newBuilder().setContent(text).setType(Type.PLAIN_TEXT).build();
        AnalyzeEntitiesRequest request = AnalyzeEntitiesRequest.newBuilder().setDocument(doc).setEncodingType(EncodingType.UTF16).build();
        AnalyzeEntitiesResponse response = language.analyzeEntities(request);
        // Print the response
        for (Entity entity : response.getEntitiesList()) {
            System.out.printf("Entity: %s", entity.getName());
            System.out.printf("Salience: %.3f\n", entity.getSalience());
            System.out.println("Metadata: ");
            for (Map.Entry<String, String> entry : entity.getMetadataMap().entrySet()) {
                System.out.printf("%s : %s", entry.getKey(), entry.getValue());
            }
            for (EntityMention mention : entity.getMentionsList()) {
                System.out.printf("Begin offset: %d\n", mention.getText().getBeginOffset());
                System.out.printf("Content: %s\n", mention.getText().getContent());
                System.out.printf("Type: %s\n\n", mention.getType());
            }
        }
    }
// [END analyze_entities_text]
}
Also used : LanguageServiceClient(com.google.cloud.language.v1.LanguageServiceClient) Entity(com.google.cloud.language.v1.Entity) AnalyzeEntitiesRequest(com.google.cloud.language.v1.AnalyzeEntitiesRequest) EntityMention(com.google.cloud.language.v1.EntityMention) AnalyzeEntitiesResponse(com.google.cloud.language.v1.AnalyzeEntitiesResponse) Document(com.google.cloud.language.v1.Document) Map(java.util.Map)

Example 53 with Entity

use of net.minecraft.server.v1_11_R1.Entity in project java-docs-samples by GoogleCloudPlatform.

the class Analyze method entitySentimentText.

/**
 * Detects the entity sentiments in the string {@code text} using the Language Beta API.
 */
public static void entitySentimentText(String text) throws Exception {
    // Instantiate the Language client com.google.cloud.language.v1.LanguageServiceClient
    try (LanguageServiceClient language = LanguageServiceClient.create()) {
        Document doc = Document.newBuilder().setContent(text).setType(Type.PLAIN_TEXT).build();
        AnalyzeEntitySentimentRequest request = AnalyzeEntitySentimentRequest.newBuilder().setDocument(doc).setEncodingType(EncodingType.UTF16).build();
        // detect entity sentiments in the given string
        AnalyzeEntitySentimentResponse response = language.analyzeEntitySentiment(request);
        // Print the response
        for (Entity entity : response.getEntitiesList()) {
            System.out.printf("Entity: %s\n", entity.getName());
            System.out.printf("Salience: %.3f\n", entity.getSalience());
            System.out.printf("Sentiment : %s\n", entity.getSentiment());
            for (EntityMention mention : entity.getMentionsList()) {
                System.out.printf("Begin offset: %d\n", mention.getText().getBeginOffset());
                System.out.printf("Content: %s\n", mention.getText().getContent());
                System.out.printf("Magnitude: %.3f\n", mention.getSentiment().getMagnitude());
                System.out.printf("Sentiment score : %.3f\n", mention.getSentiment().getScore());
                System.out.printf("Type: %s\n\n", mention.getType());
            }
        }
    }
// [END entity_sentiment_text]
}
Also used : LanguageServiceClient(com.google.cloud.language.v1.LanguageServiceClient) Entity(com.google.cloud.language.v1.Entity) EntityMention(com.google.cloud.language.v1.EntityMention) AnalyzeEntitySentimentRequest(com.google.cloud.language.v1.AnalyzeEntitySentimentRequest) Document(com.google.cloud.language.v1.Document) AnalyzeEntitySentimentResponse(com.google.cloud.language.v1.AnalyzeEntitySentimentResponse)

Example 54 with Entity

use of net.minecraft.server.v1_11_R1.Entity in project java-docs-samples by GoogleCloudPlatform.

the class Detect method analyzeLabelsFile.

/**
 * Performs label analysis on the video at the provided file path.
 *
 * @param filePath the path to the video file to analyze.
 */
public static void analyzeLabelsFile(String filePath) throws Exception {
    // Instantiate a com.google.cloud.videointelligence.v1.VideoIntelligenceServiceClient
    try (VideoIntelligenceServiceClient client = VideoIntelligenceServiceClient.create()) {
        // Read file and encode into Base64
        Path path = Paths.get(filePath);
        byte[] data = Files.readAllBytes(path);
        byte[] encodedBytes = Base64.encodeBase64(data);
        AnnotateVideoRequest request = AnnotateVideoRequest.newBuilder().setInputContent(ByteString.copyFrom(encodedBytes)).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:%.2f\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:%.2f\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_file]
}
Also used : VideoIntelligenceServiceClient(com.google.cloud.videointelligence.v1.VideoIntelligenceServiceClient) Path(java.nio.file.Path) AnnotateVideoProgress(com.google.cloud.videointelligence.v1.AnnotateVideoProgress) Entity(com.google.cloud.videointelligence.v1.Entity) LabelSegment(com.google.cloud.videointelligence.v1.LabelSegment) AnnotateVideoRequest(com.google.cloud.videointelligence.v1.AnnotateVideoRequest) VideoAnnotationResults(com.google.cloud.videointelligence.v1.VideoAnnotationResults) LabelAnnotation(com.google.cloud.videointelligence.v1.LabelAnnotation) AnnotateVideoResponse(com.google.cloud.videointelligence.v1.AnnotateVideoResponse)

Example 55 with Entity

use of net.minecraft.server.v1_11_R1.Entity in project openflowplugin by opendaylight.

the class ContextChainHolderImpl method ownershipChanged.

@Override
@SuppressFBWarnings("BC_UNCONFIRMED_CAST_OF_RETURN_VALUE")
public void ownershipChanged(EntityOwnershipChange entityOwnershipChange) {
    if (entityOwnershipChange.getState().hasOwner()) {
        return;
    }
    // Findbugs flags a false violation for "Unchecked/unconfirmed cast" from GenericEntity to Entity hence the
    // suppression above. The suppression is temporary until EntityOwnershipChange is modified to eliminate the
    // violation.
    final String entityName = entityOwnershipChange.getEntity().getIdentifier().firstKeyOf(Entity.class).getName();
    if (Objects.nonNull(entityName)) {
        LOG.debug("Entity {} has no owner", entityName);
        try {
            // TODO:Remove notifications
            final KeyedInstanceIdentifier<Node, NodeKey> nodeInstanceIdentifier = DeviceStateUtil.createNodeInstanceIdentifier(new NodeId(entityName));
            deviceManager.sendNodeRemovedNotification(nodeInstanceIdentifier);
            LOG.info("Try to remove device {} from operational DS", entityName);
            deviceManager.removeDeviceFromOperationalDS(nodeInstanceIdentifier).get(REMOVE_DEVICE_FROM_DS_TIMEOUT, TimeUnit.MILLISECONDS);
            LOG.info("Removing device from operational DS {} was successful", entityName);
        } catch (TimeoutException | ExecutionException | NullPointerException | InterruptedException e) {
            LOG.warn("Not able to remove device {} from operational DS. ", entityName, e);
        }
    }
}
Also used : Entity(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.core.general.entity.rev150930.Entity) Node(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node) NodeId(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId) ExecutionException(java.util.concurrent.ExecutionException) NodeKey(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey) TimeoutException(java.util.concurrent.TimeoutException) SuppressFBWarnings(edu.umd.cs.findbugs.annotations.SuppressFBWarnings)

Aggregations

SkinnableEntity (net.citizensnpcs.npc.skin.SkinnableEntity)41 LivingEntity (org.bukkit.entity.LivingEntity)41 CraftEntity (org.bukkit.craftbukkit.v1_11_R1.entity.CraftEntity)17 net.minecraft.world.entity (net.minecraft.world.entity)16 org.bukkit.entity (org.bukkit.entity)16 Entity (net.minecraft.server.v1_12_R1.Entity)13 Entity (com.google.datastore.v1.Entity)12 Entity (net.minecraft.server.v1_11_R1.Entity)12 Entity (net.minecraft.server.v1_8_R3.Entity)11 PathEntity (net.minecraft.server.v1_11_R1.PathEntity)10 NPCHolder (net.citizensnpcs.npc.ai.NPCHolder)9 PathEntity (net.minecraft.server.v1_8_R3.PathEntity)9 CraftEntity (org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity)9 Entity (net.minecraft.server.v1_10_R1.Entity)8 PathEntity (net.minecraft.server.v1_12_R1.PathEntity)8 Mob (net.minecraft.world.entity.Mob)8 CraftWorld (org.bukkit.craftbukkit.v1_11_R1.CraftWorld)8 CraftEntity (org.bukkit.craftbukkit.v1_12_R1.entity.CraftEntity)8 Test (org.junit.Test)8 Key (com.google.datastore.v1.Key)7