本文整理了Java中org.bukkit.entity.Entity.getLocation()
方法的一些代码示例,展示了Entity.getLocation()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Entity.getLocation()
方法的具体详情如下:
包路径:org.bukkit.entity.Entity
类名称:Entity
方法名:getLocation
[英]Gets the entity's current position
[中]获取实体的当前位置
代码示例来源:origin: GlowstoneMC/Glowstone
@Override
public void setSpectatorTarget(Entity entity) {
teleport(entity.getLocation(), PlayerTeleportEvent.TeleportCause.SPECTATE);
spectating = entity;
}
代码示例来源:origin: GlowstoneMC/Glowstone
@Override
public int compare(Entity e1, Entity e2) {
int r = ((Double) (e1.getLocation().distanceSquared(source)))
.compareTo(e2.getLocation().distanceSquared(source));
if (reversed) {
r = -r;
}
return r;
}
}
代码示例来源:origin: GlowstoneMC/Glowstone
@Override
public boolean teleport(Entity destination) {
return teleport(destination.getLocation());
}
代码示例来源:origin: GlowstoneMC/Glowstone
@Override
public boolean teleport(Entity destination, TeleportCause cause) {
return teleport(destination.getLocation(), cause);
}
代码示例来源:origin: EngineHub/WorldEdit
@Override
public Location getLocation() {
org.bukkit.entity.Entity entity = entityRef.get();
if (entity != null) {
return BukkitAdapter.adapt(entity.getLocation());
} else {
return new Location(NullWorld.getInstance());
}
}
代码示例来源:origin: GlowstoneMC/Glowstone
private double distanceTo(Entity entity) {
return RayUtil.getRayBetween(location, entity.getLocation()).length();
}
代码示例来源:origin: GlowstoneMC/Glowstone
private double distanceToSquared(Entity entity) {
return RayUtil.getRayBetween(location, entity.getLocation()).lengthSquared();
}
代码示例来源:origin: EngineHub/WorldEdit
@Override
public List<com.sk89q.worldedit.entity.Entity> getEntities(Region region) {
World world = getWorld();
List<Entity> ents = world.getEntities();
List<com.sk89q.worldedit.entity.Entity> entities = new ArrayList<>();
for (Entity ent : ents) {
if (region.contains(BukkitAdapter.asBlockVector(ent.getLocation()))) {
entities.add(BukkitAdapter.adapt(ent));
}
}
return entities;
}
代码示例来源:origin: GlowstoneMC/Glowstone
private GlowItem getFirstDroppedItem(Location location) {
for (Entity entity : location.getChunk().getEntities()) {
if (location.getBlockX() != entity.getLocation().getBlockX()
|| location.getBlockY() != entity.getLocation().getBlockY()
|| location.getBlockZ() != entity.getLocation().getBlockZ()) {
continue;
}
if (entity.getType() != EntityType.DROPPED_ITEM) {
continue;
}
return ((GlowItem) entity);
}
return null;
}
代码示例来源:origin: GlowstoneMC/Glowstone
/**
* Checks whether the entity is within the specified distance from the block.
*
* @param entity the entity
* @param block the block
* @param x maximum distance on x axis
* @param y maximum distance on y axis
* @param z maximum distance on z axis
* @return Whether the entity is within distance
*/
private boolean isWithinDistance(Entity entity, Block block, int x, int y, int z) {
Location loc = entity.getLocation();
return Math.abs(loc.getX() - block.getX()) <= x
&& Math.abs(loc.getY() - block.getY()) <= y
&& Math.abs(loc.getZ() - block.getZ()) <= z;
}
}
代码示例来源:origin: GlowstoneMC/Glowstone
@Override
public void pulse() {
super.pulse();
radius += radiusPerTick;
waitTime--;
duration--;
if (duration <= 0 || radius <= 0) {
remove();
}
if (waitTime <= 0) {
long currentTick = world.getFullTime();
for (Entity entity : world.getNearbyEntities(location, radius, radius, radius)) {
if (entity instanceof LivingEntity
&& temporaryImmunities.getOrDefault(entity, Long.MIN_VALUE) <= currentTick
&& location.distanceSquared(entity.getLocation()) < radius * radius) {
customEffects.values().forEach(
effect -> EntityUtils.applyPotionEffectWithIntensity(
effect, (LivingEntity) entity, 0.5, 0.25));
temporaryImmunities.put((LivingEntity) entity,
currentTick + reapplicationDelay);
}
}
}
}
代码示例来源:origin: GlowstoneMC/Glowstone
/**
* Gets the location that is "~ ~ ~" for a command sender.
*
* @param sender a command sender
* @return the sender's location if the sender is a block or entity, or the default world's
* coordinate origin otherwise.
*/
public static Location getLocation(CommandSender sender) {
if (sender instanceof Entity) {
return ((Entity) sender).getLocation();
} else if (sender instanceof BlockCommandSender) {
return ((BlockCommandSender) sender).getBlock().getLocation();
}
return new Location(getDefaultWorld(), 0, 0, 0);
}
代码示例来源:origin: GlowstoneMC/Glowstone
@Override
public void start(GlowLivingEntity entity) {
target = null;
List<Entity> nearbyEntities = entity.getNearbyEntities(RANGE, RANGE / 2, RANGE);
double nearestSquared = Double.MAX_VALUE;
for (Entity nearbyEntity : nearbyEntities) {
if (nearbyEntity.getType() != EntityType.PLAYER) {
continue;
}
double dist = nearbyEntity.getLocation().distanceSquared(entity.getLocation());
if (dist < nearestSquared) {
target = (GlowPlayer) nearbyEntity;
nearestSquared = dist;
}
}
}
代码示例来源:origin: GlowstoneMC/Glowstone
@Override
public void start(GlowLivingEntity entity) {
target = null;
List<Entity> nearbyEntities = entity.getNearbyEntities(RANGE, RANGE / 2, RANGE);
double nearestSquared = Double.MAX_VALUE;
for (Entity nearbyEntity : nearbyEntities) {
if (nearbyEntity.getType() != EntityType.PLAYER) {
continue;
}
double dist = nearbyEntity.getLocation().distanceSquared(entity.getLocation());
if (dist < nearestSquared) {
target = (GlowPlayer) nearbyEntity;
nearestSquared = dist;
}
}
}
代码示例来源:origin: GlowstoneMC/Glowstone
.filter(LivingEntity.class::isInstance)
.forEach(entity -> {
Location entityLoc = entity.getLocation();
double distFractionSquared = entityLoc.distanceSquared(location)
/ MAX_DISTANCE_SQUARED;
代码示例来源:origin: GlowstoneMC/Glowstone
.filter(entity -> entity instanceof LivingEntity && !entity.isDead())
.forEach(entity -> {
Vector pos = entity.getLocation().toVector();
int minY = getHighestBlockYAt(pos.getBlockX(), pos.getBlockZ());
if (pos.getBlockY() >= minY) {
代码示例来源:origin: GlowstoneMC/Glowstone
String yaw = args[4];
String pitch = args[5];
targetLocation = CommandUtils.getRotation(target.getLocation(), yaw, pitch);
} else {
targetLocation.setYaw(target.getLocation().getYaw());
targetLocation.setPitch(target.getLocation().getPitch());
代码示例来源:origin: GlowstoneMC/Glowstone
spawnLocation = sender instanceof Entity ? ((Entity) sender).getLocation()
: ((BlockCommandSender) sender).getBlock().getLocation();
} else {
return false;
} else {
senderLocation = sender instanceof Entity ? ((Entity) sender).getLocation()
: ((BlockCommandSender) sender).getBlock().getLocation();
代码示例来源:origin: GlowstoneMC/Glowstone
private void explode() {
if (!EventFactory.getInstance().callEvent(new FireworkExplodeEvent(this)).isCancelled()) {
this.playEffect(EntityEffect.FIREWORK_EXPLODE);
int effectsSize = getFireworkMeta().getEffectsSize();
if (effectsSize > 0) {
if (boostedEntity != null) {
boostedEntity.damage((5 + effectsSize * 2), DamageCause.ENTITY_EXPLOSION);
}
List<Entity> nearbyEntities = this.getNearbyEntities(2.5, 2.5, 2.5);
for (Entity nearbyEntity : nearbyEntities) {
if (!(nearbyEntity instanceof LivingEntity)) {
continue;
}
if (this.getLocation().distanceSquared(nearbyEntity.getLocation()) > 25) {
continue;
}
// "The explosion of firework rockets deals 2.5 hearts of damage, per firework
// star."
((LivingEntity) nearbyEntity)
.damage((effectsSize * 5), DamageCause.ENTITY_EXPLOSION);
}
}
}
remove();
}
代码示例来源:origin: GlowstoneMC/Glowstone
Location destination = getLocation();
Entity entity = (Entity) source;
Location entityLocation = entity.getLocation();
内容来源于网络,如有侵权,请联系作者删除!