本文整理汇总了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);
}
}
}
}
}
}
示例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;
}
示例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);
}
}
}
}
}
}
}
示例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);
}
示例5: isChunkLoaded
import org.bukkit.World; //导入方法依赖的package包/类
private boolean isChunkLoaded(World world, int x, int z) {
return world.isChunkLoaded(x, z);
}