use of com.google.cloud.videointelligence.v1p3beta1.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);
}
}
}
use of com.google.cloud.videointelligence.v1p3beta1.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);
}
}
use of com.google.cloud.videointelligence.v1p3beta1.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);
}
use of com.google.cloud.videointelligence.v1p3beta1.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());
}
}
}
use of com.google.cloud.videointelligence.v1p3beta1.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());
}
}
Aggregations