org.bukkit.Chunk#getZ ( )源码实例Demo

下面列出了org.bukkit.Chunk#getZ ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: SkyWarsReloaded   文件: Util.java
public List<Chunk> getChunks(World mapWorld) {
int size = 400;
int maxX = size/2;
int minX = -size/2;
int maxZ = size/2;
int minZ = -size/2;
int minY = 0;
int maxY = 0;
Block min = mapWorld.getBlockAt(minX, minY, minZ);
Block max = mapWorld.getBlockAt(maxX, maxY, maxZ);
Chunk cMin = min.getChunk();
Chunk cMax = max.getChunk();
List<Chunk> chunks = new ArrayList<>();

for(int cx = cMin.getX(); cx < cMax.getX(); cx++) {
	for(int cz = cMin.getZ(); cz < cMax.getZ(); cz++) {
           Chunk currentChunk = mapWorld.getChunkAt(cx, cz);
           chunks.add(currentChunk);
	}
}
return chunks;
  }
 
源代码2 项目: Holograms   文件: HologramListener.java
@EventHandler
public void onChunkUnload(ChunkUnloadEvent event) {
    Chunk chunk = event.getChunk();
    for (Entity entity : chunk.getEntities()) {
        HologramEntity hologramEntity = plugin.getEntityController().getHologramEntity(entity);
        if (hologramEntity != null) {
            hologramEntity.remove();
        }
    }
    Collection<Hologram> holograms = plugin.getHologramManager().getActiveHolograms().values();
    for (Hologram holo : holograms) {
        Location loc = holo.getLocation();
        int chunkX = (int) Math.floor(loc.getBlockX() / 16.0D);
        int chunkZ = (int) Math.floor(loc.getBlockZ() / 16.0D);
        if (chunkX == chunk.getX() && chunkZ == chunk.getZ()) {
            holo.despawn();
        }
    }
}
 
源代码3 项目: BedWars   文件: GameCreator.java
public static boolean isChunkInArea(Chunk l, Location p1, Location p2) {
	if (!p1.getWorld().equals(l.getWorld())) {
		return false;
	}
	
    Chunk min = new Location(p1.getWorld(), Math.min(p1.getX(), p2.getX()), Math.min(p1.getY(), p2.getY()),
            Math.min(p1.getZ(), p2.getZ())).getChunk();
    Chunk max = new Location(p1.getWorld(), Math.max(p1.getX(), p2.getX()), Math.max(p1.getY(), p2.getY()),
            Math.max(p1.getZ(), p2.getZ())).getChunk();
    return (min.getX() <= l.getX() && min.getZ() <= l.getZ() && max.getX() >= l.getX() && max.getZ() >= l.getZ());
}
 
源代码4 项目: BlueMap   文件: EventForwarder.java
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public synchronized void onChunkFinishedGeneration(ChunkPopulateEvent evt) {
	Chunk chunk = evt.getChunk();
	UUID world = chunk.getWorld().getUID();
	Vector2i chunkPos = new Vector2i(chunk.getX(), chunk.getZ());
	listeners.forEach(l -> l.onChunkFinishedGeneration(world, chunkPos));
}
 
源代码5 项目: Carbon   文件: StoneVariantPopulator.java
@Override
public void populate(World world, Random random, Chunk chunk) {
    int x, y, z, i;
    int worldChunkX = chunk.getX() * 16;
    int worldChunkZ = chunk.getZ() * 16;
    for (i = 0; i < pockets; i++) {
        x = worldChunkX + random.nextInt(16);
        z = worldChunkZ + random.nextInt(16);
        y = random.nextInt(257);
        this.createVein(world, max, x, y, z);
    }
}
 
源代码6 项目: BedWars   文件: GameCreator.java
public static boolean isChunkInArea(Chunk l, Location p1, Location p2) {
	if (!p1.getWorld().equals(l.getWorld())) {
		return false;
	}
	
    Chunk min = new Location(p1.getWorld(), Math.min(p1.getX(), p2.getX()), Math.min(p1.getY(), p2.getY()),
            Math.min(p1.getZ(), p2.getZ())).getChunk();
    Chunk max = new Location(p1.getWorld(), Math.max(p1.getX(), p2.getX()), Math.max(p1.getY(), p2.getY()),
            Math.max(p1.getZ(), p2.getZ())).getChunk();
    return (min.getX() <= l.getX() && min.getZ() <= l.getZ() && max.getX() >= l.getX() && max.getZ() >= l.getZ());
}
 
源代码7 项目: Civs   文件: UnloadedInventoryHandler.java
public void syncAllInventoriesInChunk(Chunk chunk) {
    String chunkString = "c:" + chunk.getX() + ":" + chunk.getZ();
    if (!unloadedChestInventories.containsKey(chunkString)) {
        return;
    }
    for (String locationString : unloadedChestInventories.get(chunkString).keySet()) {
        syncInventory(locationString);
    }
}
 
源代码8 项目: ClaimChunk   文件: ChunkEventHelper.java
private static boolean getChunksEqual(Chunk a, Chunk b) {
    if (Objects.equals(a, b)) return true;
    if (a == null || b == null) return false;

    return (Objects.equals(a.getWorld(), b.getWorld())
            && a.getX() == b.getX()
            && a.getZ() == b.getZ());
}
 
源代码9 项目: ObsidianDestroyer   文件: ChunkWrapper.java
/**
 * Wraps a chunk with a ChunkWrapper
 *
 * @param chunk           the chunk to wrap
 * @param durabilitiesDir the directory to store this wrapper in
 */
ChunkWrapper(Chunk chunk, File durabilitiesDir) {
    this.chunkX = chunk.getX();
    this.chunkZ = chunk.getZ();
    this.world = chunk.getWorld().getName();
    this.durabilitiesDir = durabilitiesDir;
}
 
源代码10 项目: Skript   文件: CondIsSlimeChunk.java
@Override
public boolean check(Chunk chunk) {
	Random random = new Random(chunk.getWorld().getSeed() +
			(long) (chunk.getX() * chunk.getX() * 0x4c1906) +
			(long) (chunk.getX() * 0x5ac0db) +
			(long) (chunk.getZ() * chunk.getZ()) * 0x4307a7L +
			(long) (chunk.getZ() * 0x5f24f) ^ 0x3ad8025f);
	return random.nextInt(10) == 0;
}
 
源代码11 项目: PGM   文件: ChunkVector.java
public static ChunkVector of(Chunk chunk) {
  return new ChunkVector(chunk.getX(), chunk.getZ());
}
 
源代码12 项目: PGM   文件: Regions.java
public static Region forChunk(Chunk chunk) {
  Vector min = new Vector(chunk.getX() * 16, 0, chunk.getZ() * 16);
  return new CuboidRegion(min, new Vector(min.getX() + 16, 256, min.getZ() + 16));
}
 
源代码13 项目: GlobalWarming   文件: GChunk.java
public GChunk(Chunk chunk) {
    this.world = chunk.getWorld().getName();
    this.x = chunk.getX();
    this.z = chunk.getZ();
}
 
源代码14 项目: ProjectAres   文件: Regions.java
public static Region forChunk(Chunk chunk) {
    Vector min = new Vector(chunk.getX() * 16, 0, chunk.getZ() * 16);
    return new CuboidRegion(min, new Vector(min.getX() + 16, 256, min.getZ() + 16));
}
 
源代码15 项目: Shopkeepers   文件: Utils.java
public static List<Entity> getNearbyEntities(Location location, double radius, EntityType... types) {
	List<Entity> entities = new ArrayList<Entity>();
	if (location == null) return entities;
	if (radius <= 0.0D) return entities;

	double radius2 = radius * radius;
	int chunkRadius = ((int) (radius / 16)) + 1;
	Chunk center = location.getChunk();
	int startX = center.getX() - chunkRadius;
	int endX = center.getX() + chunkRadius;
	int startZ = center.getZ() - chunkRadius;
	int endZ = center.getZ() + chunkRadius;
	World world = location.getWorld();
	for (int chunkX = startX; chunkX <= endX; chunkX++) {
		for (int chunkZ = startZ; chunkZ <= endZ; chunkZ++) {
			if (!world.isChunkLoaded(chunkX, chunkZ)) continue;
			Chunk chunk = world.getChunkAt(chunkX, chunkZ);
			for (Entity entity : chunk.getEntities()) {
				Location entityLoc = entity.getLocation();
				// TODO: this is a workaround: for some yet unknown reason entities sometimes report to be in a
				// different world..
				if (!entityLoc.getWorld().equals(world)) {
					Log.debug("Found an entity which reports to be in a different world than the chunk we got it from:");
					Log.debug("Location=" + location + ", Chunk=" + chunk + ", ChunkWorld=" + chunk.getWorld()
							+ ", entityType=" + entity.getType() + ", entityLocation=" + entityLoc);
					continue; // skip this entity
				}

				if (entityLoc.distanceSquared(location) <= radius2) {
					if (types == null) {
						entities.add(entity);
					} else {
						EntityType type = entity.getType();
						for (EntityType t : types) {
							if (type.equals(t)) {
								entities.add(entity);
								break;
							}
						}
					}
				}
			}
		}
	}
	return entities;
}
 
源代码16 项目: Shopkeepers   文件: ChunkData.java
public ChunkData(Chunk chunk) {
	Validate.notNull(chunk);
	this.worldName = chunk.getWorld().getName();
	this.chunkX = chunk.getX();
	this.chunkZ = chunk.getZ();
}
 
源代码17 项目: Slimefun4   文件: TickerTask.java
public long getTimings(Chunk c) {
    String id = c.getWorld().getName() + ';' + c.getX() + ';' + c.getZ();
    return chunkTimings.getOrDefault(id, 0L);
}
 
源代码18 项目: ClaimChunk   文件: PlayerMovementHandler.java
@SuppressWarnings("unused")
@EventHandler
public void onPlayerMove(PlayerMoveEvent e) {
    if (e != null && !e.isCancelled() && e.getTo() != null) {
        // Get the previous and current chunks
        Chunk prev = e.getFrom().getChunk();
        Chunk to = e.getTo().getChunk();

        // Make sure the player moved into a new chunk
        if (prev.getX() != to.getX() || prev.getZ() != to.getZ()) {
            // If the claim is currently autoclaiming, try to claim this chunk
            if (AutoClaimHandler.inList(e.getPlayer())) {
                claimChunk.getCommandHandler().mainHandler.claimChunk(e.getPlayer(), to);
                return;
            }

            ChunkHandler ch = claimChunk.getChunkHandler();

            // Check if the previous chunk was already claimed
            boolean lastClaimed = ch.isClaimed(prev.getWorld(), prev.getX(), prev.getZ());

            // Check if the new chunk is already claimed
            if (ch.isClaimed(to.getWorld(), to.getX(), to.getZ())) {
                // If the new chunk and the previous chunk were claimed, check if the owners differ
                if (lastClaimed) {
                    UUID prevOwner = ch.getOwner(prev.getWorld(), prev.getX(), prev.getZ());
                    UUID newOwner = ch.getOwner(to.getWorld(), to.getX(), to.getZ());

                    // Only display the new chunk's owner if they differ from the previous chunk's owner
                    if ((prevOwner == null && newOwner == null) || (prevOwner != null && !prevOwner.equals(newOwner))) {
                        showTitle(e.getPlayer(), to);
                    }
                } else {
                    // Show the player the chunk's owner
                    showTitle(e.getPlayer(), to);
                }
            } else {
                // The player entered an unclaimed chunk from a claimed chunk
                if (lastClaimed) {
                    UUID lastOwner = ch.getOwner(prev.getWorld(), prev.getX(), prev.getZ());
                    String name = claimChunk.getPlayerHandler().getChunkName(lastOwner);
                    String msg = (e.getPlayer().getUniqueId().equals(lastOwner) ? claimChunk.getMessages().chunkLeaveSelf : claimChunk.getMessages().chunkLeave)
                            .replace("%%PLAYER%%",
                                    ((name == null) ? claimChunk.getMessages().chunkLeaveUnknown : name));
                    Utils.toPlayer(e.getPlayer(), msg);
                }
            }
        }
    }
}
 
源代码19 项目: AreaShop   文件: SignsFeature.java
/**
 * Convert a chunk to a string to use as map key.
 * Use a Location argument to prevent chunk loading!
 * @param chunk The location to get the key for
 * @return A string to use in a map for a chunk
 */
public static String chunkToString(Chunk chunk) {
	return chunk.getWorld().getName() + ";" + chunk.getX() + ";" + chunk.getZ();
}
 
源代码20 项目: ClaimChunk   文件: ChunkPos.java
/**
 * Create an instance of a chunk position from Spigot's chunk position
 * representation.
 *
 * @param chunk The Spigot chunk representation.
 */
public ChunkPos(Chunk chunk) {
    this(chunk.getWorld().getName(), chunk.getX(), chunk.getZ());
}