本文整理汇总了Java中org.bukkit.Chunk.getX方法的典型用法代码示例。如果您正苦于以下问题:Java Chunk.getX方法的具体用法?Java Chunk.getX怎么用?Java Chunk.getX使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.Chunk
的用法示例。
在下文中一共展示了Chunk.getX方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onChunkLoad
import org.bukkit.Chunk; //导入方法依赖的package包/类
@EventHandler
public void onChunkLoad(ChunkLoadEvent e) {
if (!e.isNewChunk())
return;
Chunk chunk = e.getChunk();
int x = chunk.getX() * 16;
int z = chunk.getZ() * 16;
int y = chunk.getWorld().getHighestBlockYAt(x + 8, z + 2);
Location loc = new Location(e.getWorld(), x + 8, y, z + 2);
Random r = new Random();
// 0.2% chance of spawning shelter on generating new chunks
if (r.nextInt(1000) < 2) {
FalloutShelter s = new FalloutShelter(loc.clone());
s.generateFalloutShelter();
}
}
示例2: onChunkChange
import org.bukkit.Chunk; //导入方法依赖的package包/类
@SuppressWarnings("deprecation")
@EventHandler
public void onChunkChange(PlayerMoveEvent event) {
Location to = event.getTo();
Location from = event.getFrom();
if (to.getBlockX() == from.getBlockX() && to.getBlockZ() == from.getBlockZ()) {
return;
}
Chunk toChunk = to.getChunk();
Chunk fromChunk = from.getChunk();
if (toChunk.getX() == fromChunk.getX() && toChunk.getZ() == fromChunk.getZ()) {
return;
}
PlayerModule.getInstance().getPlayer(event.getPlayer()).handleViewDistance();
}
示例3: populate
import org.bukkit.Chunk; //导入方法依赖的package包/类
@Override
public void populate(World world, Random random, Chunk chunk)
{
for (int x = chunk.getX(); x < chunk.getX() + 16; x++)
{
for (int z = chunk.getZ(); z < chunk.getZ() + 16; z++)
{
for (int y = 0; y < 250; y++)
{
Block block = chunk.getBlock(x, y, z);
if (this.toRemove.contains(block.getType()))
block.setType(Material.STONE);
}
}
}
}
示例4: populate
import org.bukkit.Chunk; //导入方法依赖的package包/类
@Override
public void populate(World world, Random random, Chunk chunk)
{
if (chunk == null)
return;
CraftWorld handle = (CraftWorld) world;
int xr = this.randInt(random, -200, 200);
if (xr >= 50)
new WorldGenCaves().a(handle.getHandle().chunkProviderServer, handle.getHandle(), chunk.getX(), chunk.getZ(), new ChunkSnapshot());
else if (xr <= -50)
new WorldGenCanyon().a(handle.getHandle().chunkProviderServer, handle.getHandle(), chunk.getX(), chunk.getZ(), new ChunkSnapshot());
for (Rule bloc : this.rules)
{
for (int i = 0; i < bloc.round; i++)
{
int x = chunk.getX() * 16 + random.nextInt(16);
int y = bloc.minY + random.nextInt(bloc.maxY - bloc.minY);
int z = chunk.getZ() * 16 + random.nextInt(16);
this.generate(world, random, x, y, z, bloc.size, bloc);
}
}
}
示例5: unloadChunk
import org.bukkit.Chunk; //导入方法依赖的package包/类
public static void unloadChunk(Chunk chunk) {
long chunk_id = ((long) chunk.getX() << 32L) + (long) chunk.getZ();
UUID world_uuid = chunk.getWorld().getUID();
//CropControl.getPlugin().debug("Registering unload for chunk {0}:{1}", world_uuid, chunk_id);
Map<Long, WorldChunk> chunks = chunkCacheLoc.get(world_uuid);
if (chunks == null) {
return;
}
WorldChunk cacheChunk = chunks.get(chunk_id);
if (cacheChunk != null) {
unloadQueue.offer(cacheChunk);
}
// note we do not actually remove it here.
}
示例6: isSameChunk
import org.bukkit.Chunk; //导入方法依赖的package包/类
public static boolean isSameChunk(Chunk chunk1, Chunk chunk2) {
String c1w = chunk1.getWorld().getName();
String c2w = chunk2.getWorld().getName();
int c1x = chunk1.getX();
int c2x = chunk2.getX();
int c1z = chunk1.getZ();
int c2z = chunk2.getZ();
if (c1w.equals(c2w) && c1x == c2x && c1z == c2z) {
return true;
} else {
return false;
}
}
示例7: getByChunk
import org.bukkit.Chunk; //导入方法依赖的package包/类
/**
* @param chunk
* the chunk to check
* @return
* the faction that owns this chunk
*/
public Faction getByChunk(Chunk chunk) {
for (Faction faction : factions) {
for (LazyChunk fChunk : faction.getChunks()) {
if (chunk.getX() == fChunk.getX() && chunk.getZ() == fChunk.getX()) {
return faction;
}
}
}
return null;
}
示例8: getByChunk
import org.bukkit.Chunk; //导入方法依赖的package包/类
/**
* @param chunk
* the chunk to check
* @return
* the region that contains the chunk
*/
public Region getByChunk(Chunk chunk) {
for (Region region : regions) {
if (region.getWorld().equals(chunk.getWorld())) {
for (LazyChunk rChunk : region.getChunks()) {
if (rChunk.getX() == chunk.getX() && rChunk.getZ() == chunk.getZ()) {
return region;
}
}
}
}
return null;
}
示例9: isSlimeChunk
import org.bukkit.Chunk; //导入方法依赖的package包/类
/**
* Is the supplied chunk a slime chunk? Since there is no bukkit API for this, we have to use the formula ourselves.
* @param chunk
* @return Is the specified chunk a slime chunk?
*/
private static boolean isSlimeChunk(Chunk chunk) {
int x = chunk.getX();
int z = chunk.getZ();
return new Random(chunk.getWorld().getSeed() +
x * x * 4987142 +
x * 5947611 +
z * z * 4392871L +
z * 389711 ^ 0x3AD8025F).nextInt(10) == 0;
}
示例10: serializeChunk
import org.bukkit.Chunk; //导入方法依赖的package包/类
private static String serializeChunk(Chunk chunk) {
return chunk.getWorld().getName() + ";Chunk;" + chunk.getX() + ";" + chunk.getZ();
}
示例11: forChunk
import org.bukkit.Chunk; //导入方法依赖的package包/类
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));
}
示例12: of
import org.bukkit.Chunk; //导入方法依赖的package包/类
public static ChunkVector of(Chunk chunk) {
return new ChunkVector(chunk.getX(), chunk.getZ());
}
示例13: LazyChunk
import org.bukkit.Chunk; //导入方法依赖的package包/类
public LazyChunk(Chunk chunk) {
x = chunk.getX();
z = chunk.getZ();
}
示例14: addChunk
import org.bukkit.Chunk; //导入方法依赖的package包/类
private void addChunk(Player player, Region region, String[] args, int i) {
World world = player.getWorld();
Chunk chunk = player.getLocation().getChunk();
int x = chunk.getX();
int z = chunk.getZ();
boolean override = args.length > i + 2 ? args[i + 2].equalsIgnoreCase("-override") : false;
if (region == null) {
ParsingUtil.sendMessage(player, ChatColor.RED + "/f world addChunk [region name] [radius|line|auto] [value] ([-override])");
return;
}
if (args.length >= i + 1) {
if (args[i].equalsIgnoreCase("radius") || args[i].equalsIgnoreCase("r")) {
int r = args.length > i + 1 ? NumberUtil.parseInt(args[i + 1]) : 1;
x += -1 * r;
z += -1 * r;
while (z <= chunk.getZ() + r) {
if (board.isWilderness(world.getChunkAt(x, z)) || override) {
addChunk(region, world.getChunkAt(x, z), override);
}
x++;
if (x > chunk.getX() + r) {
x = chunk.getX() + -1 * r;
z++;
}
}
} else if (args[i].equalsIgnoreCase("line") || args[i].equalsIgnoreCase("l")) {
int l = args.length > i + 1 ? NumberUtil.parseInt(args[i + 1]) : 1;
BlockFace face = AXIS[Math.round(player.getLocation().getYaw() / 90F) & 0x3];
if (face == BlockFace.NORTH) {
while (l >= 0) {
if (board.isWilderness(world.getChunkAt(x, z + l)) || override) {
addChunk(region, world.getChunkAt(x, z + l), override);
}
l--;
}
} else if (face == BlockFace.EAST) {
while (l >= 0) {
if (board.isWilderness(world.getChunkAt(x - l, z)) || override) {
addChunk(region, world.getChunkAt(x - l, z), override);
}
l--;
}
} else if (face == BlockFace.WEST) {
while (l >= 0) {
if (board.isWilderness(world.getChunkAt(x + l, z)) || override) {
addChunk(region, world.getChunkAt(x + l, z), override);
}
l--;
}
} else if (face == BlockFace.SOUTH) {
while (l >= 0) {
if (board.isWilderness(world.getChunkAt(x, z - l)) || override) {
addChunk(region, world.getChunkAt(x, z - l), override);
}
l--;
}
}
} else if (args[i].equalsIgnoreCase("auto") || args[i].equalsIgnoreCase("a")) {
FPlayer fPlayer = plugin.getFPlayerCache().getByPlayer(player);
if (fPlayer.isAutoclaiming()) {
fPlayer.setAutoclaiming(null);
ParsingUtil.sendMessage(player, FMessage.CMD_WORLD_AUTOCLAIM_END.getMessage());
return;
} else {
fPlayer.setAutoclaiming(region);
ParsingUtil.sendMessage(player, FMessage.CMD_WORLD_AUTOCLAIM_START.getMessage(), region);
}
}
} else {
addChunk(region, chunk, override);
}
ParsingUtil.sendMessage(player, FMessage.CMD_WORLD_CHUNK_ADDED.getMessage(), region);
}
示例15: ChunkPos
import org.bukkit.Chunk; //导入方法依赖的package包/类
public ChunkPos(Chunk chunk) {
this(chunk.getWorld().getName(), chunk.getX(), chunk.getZ());
}