本文整理汇总了Java中cn.nukkit.level.ChunkManager.setBlockDataAt方法的典型用法代码示例。如果您正苦于以下问题:Java ChunkManager.setBlockDataAt方法的具体用法?Java ChunkManager.setBlockDataAt怎么用?Java ChunkManager.setBlockDataAt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cn.nukkit.level.ChunkManager
的用法示例。
在下文中一共展示了ChunkManager.setBlockDataAt方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: growGrass
import cn.nukkit.level.ChunkManager; //导入方法依赖的package包/类
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: placeTrunk
import cn.nukkit.level.ChunkManager; //导入方法依赖的package包/类
protected void placeTrunk(ChunkManager level, int x, int y, int z, NukkitRandom random, int trunkHeight) {
// The base dirt block
level.setBlockIdAt(x, y - 1, z, Block.DIRT);
for (int yy = 0; yy < trunkHeight; ++yy) {
int blockId = level.getBlockIdAt(x, y + yy, z);
if (this.overridable.containsKey(blockId)) {
level.setBlockIdAt(x, y + yy, z, this.getTrunkBlock());
level.setBlockDataAt(x, y + yy, z, this.getType());
}
}
}
示例3: setBlock
import cn.nukkit.level.ChunkManager; //导入方法依赖的package包/类
protected void setBlock(ChunkManager level, Vector3 v, Block b) {
level.setBlockIdAt((int) v.x, (int) v.y, (int) v.z, b.getId());
level.setBlockDataAt((int) v.x, (int) v.y, (int) v.z, b.getDamage());
}
示例4: placeObject
import cn.nukkit.level.ChunkManager; //导入方法依赖的package包/类
@Override
public void placeObject(ChunkManager level, int x, int y, int z, NukkitRandom random) {
this.treeHeight = random.nextBoundedInt(4) + 6;
int topSize = this.getTreeHeight() - (1 + random.nextBoundedInt(2));
int lRadius = 2 + random.nextBoundedInt(2);
this.placeTrunk(level, x, y, z, random, this.getTreeHeight() - random.nextBoundedInt(3));
int radius = random.nextBoundedInt(2);
int maxR = 1;
int minR = 0;
for (int yy = 0; yy <= topSize; ++yy) {
int yyy = y + this.treeHeight - yy;
for (int xx = x - radius; xx <= x + radius; ++xx) {
int xOff = Math.abs(xx - x);
for (int zz = z - radius; zz <= z + radius; ++zz) {
int zOff = Math.abs(zz - z);
if (xOff == radius && zOff == radius && radius > 0) {
continue;
}
if (!Block.solid[level.getBlockIdAt(xx, yyy, zz)]) {
level.setBlockIdAt(xx, yyy, zz, this.getLeafBlock());
level.setBlockDataAt(xx, yyy, zz, this.getType());
}
}
}
if (radius >= maxR) {
radius = minR;
minR = 1;
if (++maxR > lRadius) {
maxR = lRadius;
}
} else {
++radius;
}
}
}
示例5: placeObject
import cn.nukkit.level.ChunkManager; //导入方法依赖的package包/类
public void placeObject(ChunkManager level, int x, int y, int z) {
int clusterSize = this.type.clusterSize;
double angle = this.random.nextFloat() * Math.PI;
Vector2 offset = VectorMath.getDirection2D(angle).multiply(clusterSize).divide(8);
double x1 = x + 8 + offset.x;
double x2 = x + 8 - offset.x;
double z1 = z + 8 + offset.y;
double z2 = z + 8 - offset.y;
double y1 = y + this.random.nextBoundedInt(3) + 2;
double y2 = y + this.random.nextBoundedInt(3) + 2;
for (int count = 0; count <= clusterSize; ++count) {
double seedX = x1 + (x2 - x1) * count / clusterSize;
double seedY = y1 + (y2 - y1) * count / clusterSize;
double seedZ = z1 + (z2 - z1) * count / clusterSize;
double size = ((Math.sin(count * (Math.PI / clusterSize)) + 1) * this.random.nextFloat() * clusterSize / 16 + 1) / 2;
int startX = (int) (seedX - size);
int startY = (int) (seedY - size);
int startZ = (int) (seedZ - size);
int endX = (int) (seedX + size);
int endY = (int) (seedY + size);
int endZ = (int) (seedZ + size);
for (x = startX; x <= endX; ++x) {
double sizeX = (x + 0.5 - seedX) / size;
sizeX *= sizeX;
if (sizeX < 1) {
for (y = startY; y <= endY; ++y) {
double sizeY = (y + 0.5 - seedY) / size;
sizeY *= sizeY;
if (y > 0 && (sizeX + sizeY) < 1) {
for (z = startZ; z <= endZ; ++z) {
double sizeZ = (z + 0.5 - seedZ) / size;
sizeZ *= sizeZ;
if ((sizeX + sizeY + sizeZ) < 1 && level.getBlockIdAt(x, y, z) == replaceId) {
level.setBlockIdAt(x, y, z, this.type.material.getId());
if (this.type.material.getDamage() != 0) {
level.setBlockDataAt(x, y, z, this.type.material.getDamage());
}
}
}
}
}
}
}
}
}