当前位置: 首页>>代码示例>>Java>>正文


Java Player.getLineOfSight方法代码示例

本文整理汇总了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();
}
 
开发者ID:AlphaHelixDev,项目名称:AlphaLibary,代码行数:17,代码来源:FakeAPI.java

示例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;
}
 
开发者ID:AlphaHelixDev,项目名称:AlphaLibary,代码行数:16,代码来源:FakeAPI.java

示例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>();
}
 
开发者ID:RoboTricker,项目名称:Transport-Pipes,代码行数:9,代码来源:HitboxUtils.java

示例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;
}
 
开发者ID:zachbr,项目名称:Debuggery,代码行数:37,代码来源:PlatformUtil.java


注:本文中的org.bukkit.entity.Player.getLineOfSight方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。