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

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

源代码1 项目: UhcCore   文件: CaveOresOnlyPopulator.java
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();
                    }
                }

            }
        }
    }
}
 
源代码2 项目: UhcCore   文件: BiomeTypePopulator.java
@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;
}
 
源代码4 项目: Thermos   文件: CraftWorld.java
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);
}