Search in sources :

Example 21 with org.bukkit.craftbukkit.v1_18_R2.entity

use of org.bukkit.craftbukkit.v1_18_R2.entity in project MagicPlugin by elBukkit.

the class CompatibilityUtils method getHitbox.

@Override
public BoundingBox getHitbox(Entity entity) {
    net.minecraft.world.entity.Entity nmsEntity = ((CraftEntity) entity).getHandle();
    AABB aabb = nmsEntity.getBoundingBox();
    if (aabb == null) {
        return null;
    }
    return new BoundingBox(aabb.minX, aabb.maxX, aabb.minY, aabb.maxY, aabb.minZ, aabb.maxZ);
}
Also used : BoundingBox(com.elmakers.mine.bukkit.utility.BoundingBox) CraftEntity(org.bukkit.craftbukkit.v1_18_R2.entity.CraftEntity) AABB(net.minecraft.world.phys.AABB)

Example 22 with org.bukkit.craftbukkit.v1_18_R2.entity

use of org.bukkit.craftbukkit.v1_18_R2.entity in project MagicPlugin by elBukkit.

the class CompatibilityUtils method getHangingLocation.

@Override
public Location getHangingLocation(Entity entity) {
    Location location = entity.getLocation();
    if (!(entity instanceof Hanging))
        return location;
    HangingEntity nms = ((CraftHanging) entity).getHandle();
    BlockPos position = nms.blockPosition();
    location.setX(position.getX());
    location.setY(position.getY());
    location.setZ(position.getZ());
    return location;
}
Also used : HangingEntity(net.minecraft.world.entity.decoration.HangingEntity) Hanging(org.bukkit.entity.Hanging) CraftHanging(org.bukkit.craftbukkit.v1_18_R2.entity.CraftHanging) BlockPos(net.minecraft.core.BlockPos) CraftHanging(org.bukkit.craftbukkit.v1_18_R2.entity.CraftHanging) Location(org.bukkit.Location)

Example 23 with org.bukkit.craftbukkit.v1_18_R2.entity

use of org.bukkit.craftbukkit.v1_18_R2.entity in project MagicPlugin by elBukkit.

the class CompatibilityUtils method magicDamage.

@Override
public void magicDamage(Damageable target, double amount, Entity source) {
    try {
        if (target == null || target.isDead())
            return;
        // Might need to config-drive this, or just go back to defaulting to normal damage
        if (!USE_MAGIC_DAMAGE || target instanceof Witch || target instanceof Enderman || target instanceof ArmorStand || !(target instanceof LivingEntity)) {
            damage(target, amount, source);
            return;
        }
        net.minecraft.world.entity.Entity targetHandle = ((CraftEntity) target).getHandle();
        if (targetHandle == null)
            return;
        net.minecraft.world.entity.Entity sourceHandle = source == null ? null : ((CraftEntity) source).getHandle();
        // Bukkit won't allow magic damage from anything but a potion..
        if (sourceHandle != null && source instanceof LivingEntity) {
            Location location = target.getLocation();
            ThrownPotion potion = getOrCreatePotionEntity(location);
            net.minecraft.world.entity.Entity potionHandle = ((CraftEntity) potion).getHandle();
            potion.setShooter((LivingEntity) source);
            DamageSource magicSource = DamageSource.indirectMagic(potionHandle, sourceHandle);
            // This is a bit of hack that lets us damage the ender dragon, who is a weird and annoying collection
            // of various non-living entity pieces.
            ((EntityDamageSource) magicSource).setThorns();
            try (EnteredStateTracker.Touchable damaging = isDamaging.enter()) {
                damaging.touch();
                targetHandle.hurt(magicSource, (float) amount);
            }
        } else {
            try (EnteredStateTracker.Touchable damaging = isDamaging.enter()) {
                damaging.touch();
                targetHandle.hurt(DamageSource.MAGIC, (float) amount);
            }
        }
    } catch (Exception ex) {
        ex.printStackTrace();
    }
}
Also used : EntityDamageSource(net.minecraft.world.damagesource.EntityDamageSource) DamageSource(net.minecraft.world.damagesource.DamageSource) CraftEntity(org.bukkit.craftbukkit.v1_18_R2.entity.CraftEntity) EntityDamageSource(net.minecraft.world.damagesource.EntityDamageSource) CraftLivingEntity(org.bukkit.craftbukkit.v1_18_R2.entity.CraftLivingEntity) LivingEntity(org.bukkit.entity.LivingEntity) ArmorStand(org.bukkit.entity.ArmorStand) CraftArmorStand(org.bukkit.craftbukkit.v1_18_R2.entity.CraftArmorStand) Enderman(org.bukkit.entity.Enderman) ThrownPotion(org.bukkit.entity.ThrownPotion) EnteredStateTracker(com.elmakers.mine.bukkit.utility.EnteredStateTracker) Witch(org.bukkit.entity.Witch) Location(org.bukkit.Location)

Example 24 with org.bukkit.craftbukkit.v1_18_R2.entity

use of org.bukkit.craftbukkit.v1_18_R2.entity in project java-docs-samples by GoogleCloudPlatform.

the class Analyze method analyzeEntitiesFile.

/**
 * Identifies entities in the contents of the object at the given GCS {@code path}.
 */
public static void analyzeEntitiesFile(String gcsUri) throws Exception {
    // Instantiate the Language client com.google.cloud.language.v1.LanguageServiceClient
    try (LanguageServiceClient language = LanguageServiceClient.create()) {
        // set the GCS Content URI path to the file to be analyzed
        Document doc = Document.newBuilder().setGcsContentUri(gcsUri).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\n", 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 language_entities_gcs]
}
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 25 with org.bukkit.craftbukkit.v1_18_R2.entity

use of org.bukkit.craftbukkit.v1_18_R2.entity in project java-docs-samples by GoogleCloudPlatform.

the class Analyze method entitySentimentFile.

/**
 * Identifies the entity sentiments in the the GCS hosted file using the Language Beta API.
 */
public static void entitySentimentFile(String gcsUri) throws Exception {
    // Instantiate the Language client com.google.cloud.language.v1.LanguageServiceClient
    try (LanguageServiceClient language = LanguageServiceClient.create()) {
        Document doc = Document.newBuilder().setGcsContentUri(gcsUri).setType(Type.PLAIN_TEXT).build();
        AnalyzeEntitySentimentRequest request = AnalyzeEntitySentimentRequest.newBuilder().setDocument(doc).setEncodingType(EncodingType.UTF16).build();
        // Detect entity sentiments in the given file
        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 language_entity_sentiment_gcs]
}
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)

Aggregations

LivingEntity (org.bukkit.entity.LivingEntity)114 Entity (org.hypertrace.entity.data.service.v1.Entity)110 SkinnableEntity (net.citizensnpcs.npc.skin.SkinnableEntity)102 Test (org.junit.jupiter.api.Test)95 CraftEntity (org.bukkit.craftbukkit.v1_18_R2.entity.CraftEntity)53 Entity (net.minecraft.world.entity.Entity)42 Location (org.bukkit.Location)41 ArrayList (java.util.ArrayList)39 Entity (com.google.datastore.v1.Entity)33 net.minecraft.world.entity (net.minecraft.world.entity)33 org.bukkit.entity (org.bukkit.entity)32 EnrichedEntity (org.hypertrace.entity.data.service.v1.EnrichedEntity)32 Player (org.bukkit.entity.Player)29 ServerPlayer (net.minecraft.server.level.ServerPlayer)28 LivingEntity (net.minecraft.world.entity.LivingEntity)28 CraftWorld (org.bukkit.craftbukkit.v1_18_R2.CraftWorld)28 CraftPlayer (org.bukkit.craftbukkit.v1_18_R2.entity.CraftPlayer)27 Event (org.hypertrace.core.datamodel.Event)27 Mob (net.minecraft.world.entity.Mob)25 NPCHolder (net.citizensnpcs.npc.ai.NPCHolder)23