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


Java Chunk.getX方法代碼示例

本文整理匯總了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();
	}
}
 
開發者ID:kadeska,項目名稱:MT_Core,代碼行數:20,代碼來源:WorldListener.java

示例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(); 
		}
 
開發者ID:ThEWiZ76,項目名稱:KingdomFactions,代碼行數:17,代碼來源:ChunkChangeEvent.java

示例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);
            }
        }
    }
}
 
開發者ID:SamaGames,項目名稱:SurvivalAPI,代碼行數:18,代碼來源:OreRemoverPopulator.java

示例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);
        }
    }

}
 
開發者ID:SamaGames,項目名稱:SurvivalAPI,代碼行數:27,代碼來源:OrePopulator.java

示例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.
}
 
開發者ID:DevotedMC,項目名稱:CropControl,代碼行數:15,代碼來源:WorldChunk.java

示例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;
	}
}
 
開發者ID:GelandiAssociation,項目名稱:EscapeLag,代碼行數:14,代碼來源:Utils.java

示例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;
}
 
開發者ID:DRE2N,項目名稱:FactionsXL,代碼行數:17,代碼來源:FactionCache.java

示例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;
}
 
開發者ID:DRE2N,項目名稱:FactionsXL,代碼行數:19,代碼來源:Board.java

示例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;
}
 
開發者ID:Kneesnap,項目名稱:Kineticraft,代碼行數:15,代碼來源:SlimeFinder.java

示例10: serializeChunk

import org.bukkit.Chunk; //導入方法依賴的package包/類
private static String serializeChunk(Chunk chunk) {
	return chunk.getWorld().getName() + ";Chunk;" + chunk.getX() + ";" + chunk.getZ();
}
 
開發者ID:StarWishsama,項目名稱:Slimefun4-Chinese-Version,代碼行數:4,代碼來源:BlockStorage.java

示例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));
}
 
開發者ID:OvercastNetwork,項目名稱:ProjectAres,代碼行數:5,代碼來源:Regions.java

示例12: of

import org.bukkit.Chunk; //導入方法依賴的package包/類
public static ChunkVector of(Chunk chunk) {
    return new ChunkVector(chunk.getX(), chunk.getZ());
}
 
開發者ID:OvercastNetwork,項目名稱:ProjectAres,代碼行數:4,代碼來源:ChunkVector.java

示例13: LazyChunk

import org.bukkit.Chunk; //導入方法依賴的package包/類
public LazyChunk(Chunk chunk) {
    x = chunk.getX();
    z = chunk.getZ();
}
 
開發者ID:DRE2N,項目名稱:FactionsXL,代碼行數:5,代碼來源:LazyChunk.java

示例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);
}
 
開發者ID:DRE2N,項目名稱:FactionsXL,代碼行數:78,代碼來源:WorldCommand.java

示例15: ChunkPos

import org.bukkit.Chunk; //導入方法依賴的package包/類
public ChunkPos(Chunk chunk) {
	this(chunk.getWorld().getName(), chunk.getX(), chunk.getZ());
}
 
開發者ID:cjburkey01,項目名稱:ClaimChunk,代碼行數:4,代碼來源:ChunkPos.java


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