当前位置: 首页>>代码示例>>Java>>正文


Java Block.GRASS属性代码示例

本文整理汇总了Java中cn.nukkit.block.Block.GRASS属性的典型用法代码示例。如果您正苦于以下问题:Java Block.GRASS属性的具体用法?Java Block.GRASS怎么用?Java Block.GRASS使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在cn.nukkit.block.Block的用法示例。


在下文中一共展示了Block.GRASS属性的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: growGrass

public static void growGrass(ChunkManager level, Vector3 pos, NukkitRandom random, int count, int radius) {
    int[][] arr = {
            {Block.DANDELION, 0},
            {Block.POPPY, 0},
            {Block.TALL_GRASS, 1},
            {Block.TALL_GRASS, 1},
            {Block.TALL_GRASS, 1},
            {Block.TALL_GRASS, 1}
    };
    int arrC = arr.length - 1;
    for (int c = 0; c < count; c++) {
        int x = random.nextRange((int) (pos.x - radius), (int) (pos.x + radius));
        int z = random.nextRange((int) (pos.z) - radius, (int) (pos.z + radius));

        if (level.getBlockIdAt(x, (int) (pos.y + 1), z) == Block.AIR && level.getBlockIdAt(x, (int) (pos.y), z) == Block.GRASS) {
            int[] t = arr[random.nextRange(0, arrC)];
            level.setBlockIdAt(x, (int) (pos.y + 1), z, t[0]);
            level.setBlockDataAt(x, (int) (pos.y + 1), z, t[1]);
        }
    }
}
 
开发者ID:Rsplwe,项目名称:Nukkit-Java9,代码行数:21,代码来源:ObjectTallGrass.java

示例2: getHighestWorkableBlock

private int getHighestWorkableBlock(int x, int z) {
    int y;
    for (y = 127; y > 0; --y) {
        int b = this.level.getBlockIdAt(x, y, z);
        if (b == Block.DIRT || b == Block.GRASS) {
            break;
        } else if (b != Block.AIR && b != Block.SNOW_LAYER) {
            return -1;
        }
    }

    return ++y;
}
 
开发者ID:CoreXDevelopment,项目名称:CoreX,代码行数:13,代码来源:DarkOakTreePopulator.java

示例3: ensureDirtsUnderneath

/**
 * returns whether or not there is dirt underneath the block where the tree will be grown.
 * It also generates dirt around the block in a 2x2 square if there is dirt underneath the blockpos.
 */
private boolean ensureDirtsUnderneath(Vector3 pos, ChunkManager worldIn) {
    Vector3 blockpos = pos.down();
    int block = worldIn.getBlockIdAt((int) blockpos.x, (int) blockpos.y, (int) blockpos.z);

    if ((block == Block.GRASS || block == Block.DIRT) && pos.getY() >= 2) {
        this.setDirtAt(worldIn, blockpos);
        this.setDirtAt(worldIn, blockpos.east());
        this.setDirtAt(worldIn, blockpos.south());
        this.setDirtAt(worldIn, blockpos.south().east());
        return true;
    } else {
        return false;
    }
}
 
开发者ID:JupiterDevelopmentTeam,项目名称:Jupiter,代码行数:18,代码来源:HugeTreesGenerator.java

示例4: getSurfaceBlock

@Override
public int getSurfaceBlock() {
    return Block.GRASS;
}
 
开发者ID:FrontierDevs,项目名称:Jenisys3,代码行数:4,代码来源:GrassyBiome.java

示例5: canFlowerStay

private boolean canFlowerStay(int x, int y, int z) {
    int b = this.level.getBlockIdAt(x, y, z);
    return (b == Block.AIR || b == Block.SNOW_LAYER) && this.level.getBlockIdAt(x, y - 1, z) == Block.GRASS;
}
 
开发者ID:JupiterDevelopmentTeam,项目名称:Jupiter,代码行数:4,代码来源:PopulatorFlower.java

示例6: canSugarcaneStay

private boolean canSugarcaneStay(int x, int y, int z) {
    int b = this.level.getBlockIdAt(x, y, z);
    int c = this.level.getBlockIdAt(x, y - 1, z);
    return (b == Block.AIR) && (c == Block.SAND || c == Block.GRASS) && this.findWater(x, y - 1, z);
}
 
开发者ID:CoreXDevelopment,项目名称:CoreX,代码行数:5,代码来源:PopulatorSugarcane.java

示例7: canGrassStay

private boolean canGrassStay(int x, int y, int z) {
    int b = this.level.getBlockIdAt(x, y, z);
    return (b == Block.AIR || b == Block.SNOW_LAYER) && this.level.getBlockIdAt(x, y - 1, z) == Block.GRASS;
}
 
开发者ID:Rsplwe,项目名称:Nukkit-Java9,代码行数:4,代码来源:PopulatorGrass.java

示例8: canTallGrassStay

private boolean canTallGrassStay(int x, int y, int z) {
    int b = this.level.getBlockIdAt(x, y, z);
    return (b == Block.AIR || b == Block.SNOW_LAYER) && this.level.getBlockIdAt(x, y - 1, z) == Block.GRASS && this.level.getBlockIdAt(x, y + 1, z) == Block.AIR;
}
 
开发者ID:JupiterDevelopmentTeam,项目名称:Jupiter,代码行数:4,代码来源:PopulatorTallGrass.java


注:本文中的cn.nukkit.block.Block.GRASS属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。