Search in sources :

Example 96 with Entity

use of com.google.cloud.videointelligence.v1p2beta1.Entity in project Denizen-For-Bukkit by DenizenScript.

the class EntityHelperImpl method sendShowPacket.

@Override
public void sendShowPacket(Player pl, Entity entity) {
    if (entity instanceof Player) {
        pl.showPlayer(Denizen.getInstance(), (Player) entity);
        return;
    }
    CraftPlayer craftPlayer = (CraftPlayer) pl;
    ServerPlayer entityPlayer = craftPlayer.getHandle();
    if (entityPlayer.connection != null && !craftPlayer.equals(entity)) {
        ChunkMap tracker = ((ServerLevel) craftPlayer.getHandle().level).getChunkProvider().chunkMap;
        net.minecraft.world.entity.Entity other = ((CraftEntity) entity).getHandle();
        ChunkMap.TrackedEntity entry = tracker.G.get(other.getId());
        if (entry != null) {
            entry.removePlayer(entityPlayer);
            entry.updatePlayer(entityPlayer);
        }
    }
}
Also used : ServerPlayer(net.minecraft.server.level.ServerPlayer) ChunkMap(net.minecraft.server.level.ChunkMap) ServerPlayer(net.minecraft.server.level.ServerPlayer) org.bukkit.craftbukkit.v1_17_R1.entity(org.bukkit.craftbukkit.v1_17_R1.entity) org.bukkit.entity(org.bukkit.entity) net.minecraft.world.entity(net.minecraft.world.entity)

Example 97 with Entity

use of com.google.cloud.videointelligence.v1p2beta1.Entity in project Denizen-For-Bukkit by DenizenScript.

the class EntityHelperImpl method walkTo.

@Override
public void walkTo(final LivingEntity entity, Location location, Double speed, final Runnable callback) {
    if (entity == null || location == null) {
        return;
    }
    net.minecraft.world.entity.Entity nmsEntityEntity = ((CraftEntity) entity).getHandle();
    if (!(nmsEntityEntity instanceof Mob)) {
        return;
    }
    final Mob nmsEntity = (Mob) nmsEntityEntity;
    final PathNavigation entityNavigation = nmsEntity.getNavigation();
    final Path path;
    final boolean aiDisabled = !entity.hasAI();
    if (aiDisabled) {
        entity.setAI(true);
        try {
            ENTITY_ONGROUND_SETTER.invoke(nmsEntity, true);
        } catch (Throwable ex) {
            Debug.echoError(ex);
        }
    }
    path = entityNavigation.createPath(location.getX(), location.getY(), location.getZ(), 1);
    if (path != null) {
        nmsEntity.goalSelector.enableControlFlag(Goal.Flag.MOVE);
        entityNavigation.moveTo(path, 1D);
        entityNavigation.setSpeedModifier(2D);
        final double oldSpeed = nmsEntity.getAttribute(Attributes.MOVEMENT_SPEED).getBaseValue();
        if (speed != null) {
            nmsEntity.getAttribute(Attributes.MOVEMENT_SPEED).setBaseValue(speed);
        }
        new BukkitRunnable() {

            @Override
            public void run() {
                if (!entity.isValid()) {
                    if (callback != null) {
                        callback.run();
                    }
                    cancel();
                    return;
                }
                if (aiDisabled && entity instanceof Wolf) {
                    ((Wolf) entity).setAngry(false);
                }
                if (entityNavigation.isDone() || path.isDone()) {
                    if (callback != null) {
                        callback.run();
                    }
                    if (speed != null) {
                        nmsEntity.getAttribute(Attributes.MOVEMENT_SPEED).setBaseValue(oldSpeed);
                    }
                    if (aiDisabled) {
                        entity.setAI(false);
                    }
                    cancel();
                }
            }
        }.runTaskTimer(NMSHandler.getJavaPlugin(), 1, 1);
    } else // if (!Utilities.checkLocation(location, entity.getLocation(), 20)) {
    // TODO: generate waypoints to the target location?
    {
        entity.teleport(location);
    }
}
Also used : Path(net.minecraft.world.level.pathfinder.Path) Mob(net.minecraft.world.entity.Mob) BukkitRunnable(org.bukkit.scheduler.BukkitRunnable) PathNavigation(net.minecraft.world.entity.ai.navigation.PathNavigation) org.bukkit.craftbukkit.v1_17_R1.entity(org.bukkit.craftbukkit.v1_17_R1.entity) org.bukkit.entity(org.bukkit.entity) net.minecraft.world.entity(net.minecraft.world.entity)

Example 98 with Entity

use of com.google.cloud.videointelligence.v1p2beta1.Entity in project Denizen-For-Bukkit by DenizenScript.

the class EntityHelperImpl method setSpeed.

@Override
public void setSpeed(Entity entity, double speed) {
    net.minecraft.world.entity.Entity nmsEntityEntity = ((CraftEntity) entity).getHandle();
    if (!(nmsEntityEntity instanceof Mob)) {
        return;
    }
    Mob nmsEntity = (Mob) nmsEntityEntity;
    nmsEntity.getAttribute(Attributes.MOVEMENT_SPEED).setBaseValue(speed);
}
Also used : Mob(net.minecraft.world.entity.Mob) org.bukkit.craftbukkit.v1_17_R1.entity(org.bukkit.craftbukkit.v1_17_R1.entity) org.bukkit.entity(org.bukkit.entity) net.minecraft.world.entity(net.minecraft.world.entity)

Example 99 with Entity

use of com.google.cloud.videointelligence.v1p2beta1.Entity in project atlas by osmlab.

the class OsmPbfCounter method process.

@Override
public void process(final EntityContainer entityContainer) {
    final Entity rawEntity = entityContainer.getEntity();
    if (OsmPbfReader.shouldProcessEntity(this.loadingOption, rawEntity)) {
        // store all node locations for calculating way geometry
        if (rawEntity instanceof Node) {
            final Node node = (Node) rawEntity;
            final Location nodeLocation = new Location(Latitude.degrees(node.getLatitude()), Longitude.degrees(node.getLongitude()));
            this.nodeIdentifierToLocation.put(rawEntity.getId(), nodeLocation);
        }
        if (shouldLoadOsmNode(rawEntity)) {
            // This node is within the boundary, bring it in
            this.nodeIdentifiersToInclude.add(rawEntity.getId());
        } else if (shouldLoadOsmWay(rawEntity)) {
            final Way way = (Way) rawEntity;
            if (wayIntersectsBoundary(way)) {
                // This way contains at least one shape-point within the given bounding box.
                // Bring it and all of its nodes in to the atlas.
                addWayNodes(this.nodeIdentifiersBroughtInByWaysOrRelations, way);
                this.wayIdentifiersToInclude.add(way.getId());
            } else {
                // This way doesn't have any shape-points within the given boundary. Mark it as
                // a way to exclude so it can be revisited during relation processing
                this.waysToExclude.put(way.getId(), way);
            }
        } else if (shouldLoadOsmRelation(rawEntity)) {
            final Relation relation = (Relation) rawEntity;
            if (relationContainsMemberWithinBoundary(relation)) {
                // Shallow check showed that this relation has a member that is inside our
                // boundary, mark all members and relation as inside
                markRelationAndMembersInsideBoundary(relation);
            } else {
                // Stage the relation - it might be added later
                this.stagedRelations.add(relation);
            }
        } else if (rawEntity instanceof Bound) {
            logger.trace("Encountered PBF Bound {}, skipping over it.", rawEntity.getId());
        }
    }
}
Also used : Entity(org.openstreetmap.osmosis.core.domain.v0_6.Entity) Relation(org.openstreetmap.osmosis.core.domain.v0_6.Relation) WayNode(org.openstreetmap.osmosis.core.domain.v0_6.WayNode) Node(org.openstreetmap.osmosis.core.domain.v0_6.Node) Bound(org.openstreetmap.osmosis.core.domain.v0_6.Bound) Way(org.openstreetmap.osmosis.core.domain.v0_6.Way) Location(org.openstreetmap.atlas.geography.Location)

Example 100 with Entity

use of com.google.cloud.videointelligence.v1p2beta1.Entity in project atlas by osmlab.

the class OsmPbfReader method process.

@Override
public void process(final EntityContainer entityContainer) {
    final Entity rawEntity = entityContainer.getEntity();
    if (shouldProcessEntity(this.loadingOption, rawEntity)) {
        if (rawEntity instanceof Node && this.nodeIdentifiersToInclude.contains(rawEntity.getId())) {
            processNode(rawEntity);
        } else if (rawEntity instanceof Way && this.wayIdentifiersToInclude.contains(rawEntity.getId())) {
            processWay(rawEntity);
        } else if (this.loadingOption.isLoadOsmRelation() && rawEntity instanceof Relation) {
            processRelation(rawEntity);
        } else if (rawEntity instanceof Bound) {
            logger.trace("Encountered PBF Bound {}, skipping over it.", rawEntity.getId());
        }
    } else {
        recordNodeIdentifiersFromFilteredEntity(rawEntity);
        logFilteredStatistics(rawEntity);
        logger.trace("Filtering out OSM {} {} from Raw Atlas", rawEntity.getType(), rawEntity.getId());
    }
}
Also used : AtlasEntity(org.openstreetmap.atlas.geography.atlas.items.AtlasEntity) Entity(org.openstreetmap.osmosis.core.domain.v0_6.Entity) Relation(org.openstreetmap.osmosis.core.domain.v0_6.Relation) WayNode(org.openstreetmap.osmosis.core.domain.v0_6.WayNode) Node(org.openstreetmap.osmosis.core.domain.v0_6.Node) Bound(org.openstreetmap.osmosis.core.domain.v0_6.Bound) Way(org.openstreetmap.osmosis.core.domain.v0_6.Way)

Aggregations

Entity (org.hypertrace.entity.data.service.v1.Entity)110 LivingEntity (org.bukkit.entity.LivingEntity)95 Test (org.junit.jupiter.api.Test)95 SkinnableEntity (net.citizensnpcs.npc.skin.SkinnableEntity)88 net.minecraft.world.entity (net.minecraft.world.entity)40 org.bukkit.entity (org.bukkit.entity)40 Entity (com.google.datastore.v1.Entity)33 ArrayList (java.util.ArrayList)33 Location (org.bukkit.Location)33 EnrichedEntity (org.hypertrace.entity.data.service.v1.EnrichedEntity)32 Event (org.hypertrace.core.datamodel.Event)27 AttributeValue (org.hypertrace.core.datamodel.AttributeValue)22 BackendInfo (org.hypertrace.traceenricher.enrichment.enrichers.resolver.backend.BackendInfo)21 Mob (net.minecraft.world.entity.Mob)20 NPCHolder (net.citizensnpcs.npc.ai.NPCHolder)18 Entity (net.minecraft.server.v1_8_R3.Entity)18 AnnotateVideoProgress (com.google.cloud.videointelligence.v1.AnnotateVideoProgress)17 AnnotateVideoRequest (com.google.cloud.videointelligence.v1.AnnotateVideoRequest)17 AnnotateVideoResponse (com.google.cloud.videointelligence.v1.AnnotateVideoResponse)17 Entity (com.google.cloud.videointelligence.v1.Entity)17