當前位置: 首頁>>代碼示例>>Java>>正文


Java World.isChunkLoaded方法代碼示例

本文整理匯總了Java中org.bukkit.World.isChunkLoaded方法的典型用法代碼示例。如果您正苦於以下問題:Java World.isChunkLoaded方法的具體用法?Java World.isChunkLoaded怎麽用?Java World.isChunkLoaded使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.bukkit.World的用法示例。


在下文中一共展示了World.isChunkLoaded方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: forEveryoneAround

import org.bukkit.World; //導入方法依賴的package包/類
private void forEveryoneAround(Location center, double radius, Consumer<Player> action) {
    int chunkRadius = (int) Math.ceil(radius) >> 4;
    double squared = radius * radius;
    final int x = center.getBlockX() >> 4;
    final int z = center.getBlockZ() >> 4;

    int ix = x - chunkRadius;
    int ex = x + chunkRadius;

    int iz = z - chunkRadius;
    int ez = z + chunkRadius;

    final World world = center.getWorld();
    for (int chX = ix; chX <= ex; chX++) {
        for (int chZ = iz; chZ <= ez; chZ++) {
            if(world.isChunkLoaded(chX, chZ)) {
                for (Entity e : world.getChunkAt(chX, chZ).getEntities()) {
                    if (e instanceof Player && e.getLocation().distanceSquared(center) <= squared) {
                        action.accept((Player) e);
                    }
                }
            }
        }
    }
}
 
開發者ID:upperlevel,項目名稱:uppercore,代碼行數:26,代碼來源:ParticlePacket.java

示例2: getEntities

import org.bukkit.World; //導入方法依賴的package包/類
public static List<Entity> getEntities(Location location, double radius) {
    List<Entity> entities = new ArrayList<Entity>();
    World world = location.getWorld();

    // Find chunck by coordinates
    int smallX = MathHelper.floor((location.getX() - radius) / 16.0D);
    int bigX = MathHelper.floor((location.getX() + radius) / 16.0D);
    int smallZ = MathHelper.floor((location.getZ() - radius) / 16.0D);
    int bigZ = MathHelper.floor((location.getZ() + radius) / 16.0D);

    for (int x = smallX; x <= bigX; x++) 
    	for (int z = smallZ; z <= bigZ; z++) 
    		if (world.isChunkLoaded(x, z)) entities.addAll(Arrays.asList(world.getChunkAt(x, z).getEntities()));

    Iterator<Entity> entityIterator = entities.iterator();
    while (entityIterator.hasNext()) 
    	if (entityIterator.next().getLocation().distanceSquared(location) > radius * radius) entityIterator.remove(); 
    
    return entities;
}
 
開發者ID:EpticMC,項目名稱:Mob-AI,代碼行數:21,代碼來源:CommandHandler.java

示例3: forEveryPlayerAroundManual

import org.bukkit.World; //導入方法依賴的package包/類
private static void forEveryPlayerAroundManual(Player viewer, Location loc, double radius, Consumer<Player> callback) {
    World world = loc.getWorld();
    double minX = loc.getX() - radius;
    double minY = loc.getY() - radius;
    double minZ = loc.getZ() - radius;
    double maxX = loc.getX() + radius;
    double maxY = loc.getY() + radius;
    double maxZ = loc.getZ() + radius;

    int chMinX = (int) Math.floor(minX - 2.0) >> 4;
    int chMaxX = (int) Math.floor(maxX + 2.0) >> 4;
    int chMinZ = (int) Math.floor(minZ - 2.0) >> 4;
    int chMaxZ = (int) Math.floor(maxZ + 2.0) >> 4;

    Object bb = BoundingBoxNms.toNms(minX, minY, minZ, maxX, maxY, maxZ);

    for (int chX = chMinX; chX <= chMaxX; chX++) {
        for (int chZ = chMinZ; chZ <= chMaxZ; chZ++) {
            if (world.isChunkLoaded(chX, chZ)) {
                for (Entity t : world.getChunkAt(chX, chZ).getEntities()) {
                    if (t instanceof Player && viewer != t) {
                        if (BoundingBoxNms.intersect(bb, EntityNms.getBoundingBox(t))) {
                            callback.accept((Player) t);
                        }
                    }
                }
            }
        }
    }
}
 
開發者ID:upperlevel,項目名稱:uppercore,代碼行數:31,代碼來源:PlayerUtil.java

示例4: getBlock

import org.bukkit.World; //導入方法依賴的package包/類
private Block getBlock(World world, int x, int y, int z)
{
    int cx = x >> 4;
    int cz = z >> 4;

    if ((!world.isChunkLoaded(cx, cz)) && (!world.loadChunk(cx, cz, false)))
        return null;

    Chunk chunk = world.getChunkAt(cx, cz);

    if (chunk == null)
        return null;

    return chunk.getBlock(x & 0xF, y, z & 0xF);
}
 
開發者ID:SamaGames,項目名稱:SurvivalAPI,代碼行數:16,代碼來源:OrePopulator.java

示例5: isChunkLoaded

import org.bukkit.World; //導入方法依賴的package包/類
private boolean isChunkLoaded(World world, int x, int z) {
    return world.isChunkLoaded(x, z);
}
 
開發者ID:Vrekt,項目名稱:Arc-v2,代碼行數:4,代碼來源:ChunkPacketProcessor.java


注:本文中的org.bukkit.World.isChunkLoaded方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。