本文整理汇总了Java中ethanjones.cubes.world.storage.Area.setBlock方法的典型用法代码示例。如果您正苦于以下问题:Java Area.setBlock方法的具体用法?Java Area.setBlock怎么用?Java Area.setBlock使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ethanjones.cubes.world.storage.Area
的用法示例。
在下文中一共展示了Area.setBlock方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setBlocks
import ethanjones.cubes.world.storage.Area; //导入方法依赖的package包/类
public void setBlocks(Block block, int x1, int y1, int z1, int x2, int y2, int z2, int meta) {
int minX = Math.min(x1, x2);
int minY = Math.min(y1, y2);
int minZ = Math.min(z1, z2);
int maxX = Math.max(x1, x2);
int maxY = Math.max(y1, y2);
int maxZ = Math.max(z1, z2);
for (int x = minX; x <= maxX; x++) {
for (int z = minZ; z <= maxZ; z++) {
Area area = getArea(CoordinateConverter.area(x), CoordinateConverter.area(z));
if (area != null) {
for (int y = minY; y <= maxY; y++) {
area.setBlock(block, x - area.minBlockX, y, z - area.minBlockZ, meta);
}
}
}
}
}
示例2: randomTick
import ethanjones.cubes.world.storage.Area; //导入方法依赖的package包/类
@Override
public int randomTick(World world, Area area, int x, int y, int z, int meta) {
if (y < area.maxY) {
if (!validGrass(world, area, x, y, z, true)) {
area.setBlock(Blocks.dirt, x, y, z, 0);
}
}
for (int i = y - 1; i <= y + 1; i++) {
checkDirt(world, area, x + 1, i, z + 1);
checkDirt(world, area, x + 1, i, z);
checkDirt(world, area, x + 1, i, z - 1);
checkDirt(world, area, x, i, z + 1);
checkDirt(world, area, x, i, z - 1);
checkDirt(world, area, x - 1, i, z + 1);
checkDirt(world, area, x - 1, i, z);
checkDirt(world, area, x - 1, i, z - 1);
}
return meta;
}
示例3: randomTick
import ethanjones.cubes.world.storage.Area; //导入方法依赖的package包/类
@Override
public int randomTick(World world, Area area, int x, int y, int z, int meta) {
if (y < area.maxY) {
if (!validGrass(world, area, x, y, z, true)) {
area.setBlock(Blocks.dirt, x, y, z, 0);
}
}
for (int i = y - 1; i <= y + 1; i++) {
checkDirt(world, area, x + 1, i, z + 1);
checkDirt(world, area, x + 1, i, z);
checkDirt(world, area, x + 1, i, z - 1);
checkDirt(world, area, x, i, z + 1);
checkDirt(world, area, x, i, z - 1);
checkDirt(world, area, x - 1, i, z + 1);
checkDirt(world, area, x - 1, i, z);
checkDirt(world, area, x - 1, i, z - 1);
}
return meta;
}
示例4: checkDirt
import ethanjones.cubes.world.storage.Area; //导入方法依赖的package包/类
private void checkDirt(World world, Area area, int x, int y, int z) {
if (x < 0 || x >= Area.SIZE_BLOCKS || z < 0 || z >= Area.SIZE_BLOCKS) {
Area a = area.neighbourBlockCoordinates(x + area.minBlockX, z + area.minBlockZ);
if (a == null) return;
if (Lock.tryToLock(true, a)) {
int bX = (x + area.minBlockX) - a.minBlockX;
int bZ = (z + area.minBlockZ) - a.minBlockZ;
if (a.getBlock(bX, y, bZ) == Blocks.dirt && validGrass(world, a, bX, y, bZ, false)) {
a.setBlock(Blocks.grass, bX, y, bZ, 0);
}
a.lock.writeUnlock();
}
} else {
if (area.getBlock(x, y, z) == Blocks.dirt && validGrass(world, area, x, y, z, false)) {
area.setBlock(Blocks.grass, x, y, z, 0);
}
}
}
示例5: setBlock
import ethanjones.cubes.world.storage.Area; //导入方法依赖的package包/类
protected void setBlock(Area area, Block block, int x, int y, int z, int meta) {
if (area.minBlockX > x || area.minBlockX + Area.SIZE_BLOCKS <= x || area.minBlockZ > z
|| area.minBlockZ + Area.SIZE_BLOCKS <= z) {
area = area.neighbourBlockCoordinates(x, z);
}
area.setBlock(block, x - area.minBlockX, y, z - area.minBlockZ, meta);
}
示例6: kDirtIf1
import ethanjones.cubes.world.storage.Area; //导入方法依赖的package包/类
kDirtIf1(Area a, int x, Area area, int z, int y, World world) {
if (a == null)
return;
if (Lock.tryToLock(true, a)) {
int bX = (x + area.minBlockX) - a.minBlockX;
int bZ = (z + area.minBlockZ) - a.minBlockZ;
if (a.getBlock(bX, y, bZ) == Blocks.dirt && validGrass(world, a, bX, y, bZ, false)) {
a.setBlock(Blocks.grass, bX, y, bZ, 0);
}
a.lock.writeUnlock();
}
}
示例7: setBlocks
import ethanjones.cubes.world.storage.Area; //导入方法依赖的package包/类
public void setBlocks(Block block, int x1, int y1, int z1, int x2, int y2, int z2, int meta) {
int minX = Math.min(x1, x2), minY = Math.min(y1, y2), minZ = Math.min(z1, z2);
int maxX = Math.max(x1, x2), maxY = Math.max(y1, y2), maxZ = Math.max(z1, z2);
for (int x = minX; x <= maxX; x++) {
for (int z = minZ; z <= maxZ; z++) {
Area area = getArea(CoordinateConverter.area(x), CoordinateConverter.area(z));
if (area != null) {
for (int y = minY; y <= maxY; y++) {
area.setBlock(block, x - area.minBlockX, y, z - area.minBlockZ, meta);
}
}
}
}
}
示例8: randomTick
import ethanjones.cubes.world.storage.Area; //导入方法依赖的package包/类
@Override
public int randomTick(World world, Area area, final int blockX, final int blockY, final int blockZ, int meta) {
if (meta == 1) {
HashSet<BlockReference> checked = new HashSet<BlockReference>();
ArrayDeque<BlockReference> todo = new ArrayDeque<BlockReference>();
BlockReference start = new BlockReference().setFromBlockCoordinates(blockX, blockY, blockZ);
todo.add(start.copy().offset(-1, 0, 0));
todo.add(start.copy().offset(1, 0, 0));
todo.add(start.copy().offset(0, -1, 0));
todo.add(start.copy().offset(0, 1, 0));
todo.add(start.copy().offset(0, 0, -1));
todo.add(start.copy().offset(0, 0, 1));
while (!todo.isEmpty()) {
BlockReference poll = todo.poll();
int x = poll.blockX, y = poll.blockY, z = poll.blockZ;
Area a = area;
if (x < 0 || x >= Area.SIZE_BLOCKS || z < 0 || z >= Area.SIZE_BLOCKS) {
a = area.neighbourBlockCoordinates(x + area.minBlockX, z + area.minBlockZ);
if (a == null) return meta; //otherwise leaves may decay if area containing log is not loaded
x = x + area.minBlockX - a.minBlockX;
z = z + area.minBlockZ - a.minBlockZ;
}
if (y < 0 || y > a.maxY) continue;
Block b = a.getBlock(x, y, z);
if (b == Blocks.leaves) {
add(checked, todo, start, poll, -1, 0, 0);
add(checked, todo, start, poll, 1, 0, 0);
add(checked, todo, start, poll, 0, -1, 0);
add(checked, todo, start, poll, 0, 1, 0);
add(checked, todo, start, poll, 0, 0, -1);
add(checked, todo, start, poll, 0, 0, 1);
} else if (b == Blocks.log) {
return meta;
}
}
area.setBlock(null, blockX, blockY, blockZ, 0);
dropItems(Cubes.getServer().world, blockX + area.minBlockX, blockY, blockZ + area.minBlockZ, meta);
}
return meta;
}
示例9: setBlock
import ethanjones.cubes.world.storage.Area; //导入方法依赖的package包/类
public void setBlock(Block block, int x, int y, int z) {
Area area = getArea(CoordinateConverter.area(x), CoordinateConverter.area(z));
if (area != null)
area.setBlock(block, x - area.minBlockX, y, z - area.minBlockZ, 0);
}
示例10: randomTick
import ethanjones.cubes.world.storage.Area; //导入方法依赖的package包/类
@Override
public int randomTick(World world, Area area, final int blockX, final int blockY, final int blockZ, int meta) {
if (meta == 1) {
HashSet<BlockReference> checked = new HashSet<BlockReference>();
ArrayDeque<BlockReference> todo = new ArrayDeque<BlockReference>();
BlockReference start = new BlockReference().setFromBlockCoordinates(blockX, blockY, blockZ);
todo.add(start.copy().offset(-1, 0, 0));
todo.add(start.copy().offset(1, 0, 0));
todo.add(start.copy().offset(0, -1, 0));
todo.add(start.copy().offset(0, 1, 0));
todo.add(start.copy().offset(0, 0, -1));
todo.add(start.copy().offset(0, 0, 1));
while (!todo.isEmpty()) {
BlockReference poll = todo.poll();
int x = poll.blockX;
int y = poll.blockY;
int z = poll.blockZ;
Area a = area;
randomTickMeta(x, z, a, area, meta);
if (y < 0 || y > a.maxY) {
continue;
}
Block b = a.getBlock(x, y, z);
if (b == Blocks.leaves) {
add(checked, todo, start, poll, -1, 0, 0);
add(checked, todo, start, poll, 1, 0, 0);
add(checked, todo, start, poll, 0, -1, 0);
add(checked, todo, start, poll, 0, 1, 0);
add(checked, todo, start, poll, 0, 0, -1);
add(checked, todo, start, poll, 0, 0, 1);
} else if (b == Blocks.log) {
return meta;
}
}
area.setBlock(null, blockX, blockY, blockZ, 0);
dropItems(Cubes.getServer().world, blockX + area.minBlockX, blockY, blockZ + area.minBlockZ, meta);
}
return meta;
}
示例11: setBlock
import ethanjones.cubes.world.storage.Area; //导入方法依赖的package包/类
protected void setBlock(Area area, Block block, int x, int y, int z, int meta) {
if (area.minBlockX > x || area.minBlockX + Area.SIZE_BLOCKS <= x || area.minBlockZ > z || area.minBlockZ + Area.SIZE_BLOCKS <= z) {
area = area.neighbourBlockCoordinates(x, z);
}
area.setBlock(block, x - area.minBlockX, y, z - area.minBlockZ, meta);
}
示例12: setBlock
import ethanjones.cubes.world.storage.Area; //导入方法依赖的package包/类
public void setBlock(Block block, int x, int y, int z) {
Area area = getArea(CoordinateConverter.area(x), CoordinateConverter.area(z));
if (area != null) area.setBlock(block, x - area.minBlockX, y, z - area.minBlockZ, 0);
}