下面列出了org.bukkit.Chunk#getBlock ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
private void scanChunk(Chunk chunk){
for (int x = 0; x < 16; x++){
for (int y = 5; y < 30; y++){
for (int z = 0; z < 16; z++){
Block block = chunk.getBlock(x, y, z);
Material type = block.getType();
if (
type == Material.DIAMOND_ORE ||
type == Material.GOLD_ORE ||
type == Material.LAPIS_ORE
){
Vein vein = new Vein();
vein.process(block);
if (!vein.isConnectedToAir()){
vein.setToStone();
}
}
}
}
}
}
@Override
public void populate(World world, Random random, Chunk chunk){
for (int x = 1; x < 15; x++) {
for (int z = 1; z < 15; z++) {
Block block = chunk.getBlock(x, 1, z);
Biome replacementBiome = getReplacementBiome(block.getBiome());
if (UhcCore.getVersion() < 16){
if (replacementBiome != null) {
block.setBiome(replacementBiome);
}
}else {
for (int y = 0; y < 200; y++) {
block = chunk.getBlock(x, y, z);
if (replacementBiome != null) {
block.setBiome(replacementBiome);
}
}
}
}
}
}
@Override
public int getWorldBlockData(UserConnection user, int bx, int by, int bz) {
UUID uuid = user.getProtocolInfo().getUuid();
Player player = Bukkit.getPlayer(uuid);
if (player != null) {
World world = player.getWorld();
int x = bx >> 4;
int z = bz >> 4;
if (world.isChunkLoaded(x, z)) {
Chunk c = getChunk(world, x, z);
Block b = c.getBlock(bx, by, bz);
return b.getTypeId() << 4 | b.getData();
}
}
return 0;
}
public Block getBlockAt(int x, int y, int z) {
Chunk chunk = getChunkAt(x >> 4, z >> 4);
return chunk == null ? null : chunk.getBlock(x & 0xF, y & 0xFF, z & 0xF);
}