本文整理汇总了Java中org.bukkit.entity.Player.getLineOfSight方法的典型用法代码示例。如果您正苦于以下问题:Java Player.getLineOfSight方法的具体用法?Java Player.getLineOfSight怎么用?Java Player.getLineOfSight使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.entity.Player
的用法示例。
在下文中一共展示了Player.getLineOfSight方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getLookedAtFakeEntity
import org.bukkit.entity.Player; //导入方法依赖的package包/类
public static FakeEntity getLookedAtFakeEntity(Player p, int range) throws NoSuchFakeEntityException {
if (!getFakeEntities().containsKey(p.getName())) throw new NoSuchFakeEntityException();
for (Block b : p.getLineOfSight(null, range)) {
for (FakeEntity fakeEntity : getFakeEntities().get(p.getName())) {
if ((b.getX() == fakeEntity.getCurrentlocation().getBlockX()
&& b.getY() == fakeEntity.getCurrentlocation().getBlockY()
&& b.getZ() == fakeEntity.getCurrentlocation().getBlockZ()
|| (b.getX() == fakeEntity.getCurrentlocation().getBlockX()
&& b.getY() == (fakeEntity.getCurrentlocation().getBlockY() + 1)
&& b.getZ() == fakeEntity.getCurrentlocation().getBlockZ())))
return fakeEntity;
}
}
throw new NoSuchFakeEntityException();
}
示例2: isFakeEntityInRange
import org.bukkit.entity.Player; //导入方法依赖的package包/类
public static boolean isFakeEntityInRange(Player p, int range) {
if (!getFakeEntities().containsKey(p.getName())) return false;
for (Block b : p.getLineOfSight(null, range)) {
for (FakeEntity fakeEntity : getFakeEntities().get(p.getName())) {
if ((b.getX() == fakeEntity.getCurrentlocation().getBlockX()
&& b.getY() == fakeEntity.getCurrentlocation().getBlockY()
&& b.getZ() == fakeEntity.getCurrentlocation().getBlockZ()
|| (b.getX() == fakeEntity.getCurrentlocation().getBlockX()
&& b.getY() == (fakeEntity.getCurrentlocation().getBlockY() + 1)
&& b.getZ() == fakeEntity.getCurrentlocation().getBlockZ())))
return true;
}
}
return false;
}
示例3: getLineOfSight
import org.bukkit.entity.Player; //导入方法依赖的package包/类
public static List<Block> getLineOfSight(Player p) {
try {
return p.getLineOfSight(LINE_OF_SIGHT_SET, HITBOX_RANGE);
} catch (IllegalStateException e) {
}
return new ArrayList<Block>();
}
示例4: getEntityPlayerLookingAt
import org.bukkit.entity.Player; //导入方法依赖的package包/类
/**
* Performs a raytrace to check which entity the player is probably looking at
*
* @param player Player to check
* @param range Max distance to search against
* @param tolerance How close we want the search to be
* @return entity player is looking at, or null if we couldn't find one
*/
@Nullable
public static Entity getEntityPlayerLookingAt(Player player, int range, double tolerance) {
List<Entity> entities = player.getNearbyEntities(range, range, range);
for (Block block : player.getLineOfSight(null, range)) {
final Location location = block.getLocation();
for (Entity entity : entities) {
// X
if (!(Math.abs(entity.getLocation().getX() - location.getX()) < tolerance)) {
continue;
}
// Y
if (!(Math.abs(entity.getLocation().getY() - location.getY()) < tolerance)) {
continue;
}
// Z
if (!(Math.abs(entity.getLocation().getX() - location.getX()) < tolerance)) {
continue;
}
return entity;
}
}
return null;
}