本文整理汇总了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]);
}
}
}
示例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;
}
示例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;
}
}
示例4: getSurfaceBlock
@Override
public int getSurfaceBlock() {
return Block.GRASS;
}
示例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;
}
示例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);
}
示例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;
}
示例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;
}