當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。