Java Code Examples for cn.nukkit.block.Block#solid()
The following examples show how to use
cn.nukkit.block.Block#solid() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ObjectTree.java From Jupiter with GNU General Public License v3.0 | 6 votes |
public void placeObject(ChunkManager level, int x, int y, int z, NukkitRandom random) { this.placeTrunk(level, x, y, z, random, this.getTreeHeight() - 1); for (int yy = y - 3 + this.getTreeHeight(); yy <= y + this.getTreeHeight(); ++yy) { double yOff = yy - (y + this.getTreeHeight()); int mid = (int) (1 - yOff / 2); for (int xx = x - mid; xx <= x + mid; ++xx) { int xOff = Math.abs(xx - x); for (int zz = z - mid; zz <= z + mid; ++zz) { int zOff = Math.abs(zz - z); if (xOff == mid && zOff == mid && (yOff == 0 || random.nextBoundedInt(2) == 0)) { continue; } if (!Block.solid[level.getBlockIdAt(xx, yy, zz)]) { level.setBlockIdAt(xx, yy, zz, this.getLeafBlock()); level.setBlockDataAt(xx, yy, zz, this.getType()); } } } } }
Example 2
Source File: BaseFullChunk.java From Jupiter with GNU General Public License v3.0 | 6 votes |
@Override public void populateSkyLight() { for (int z = 0; z < 16; ++z) { for (int x = 0; x < 16; ++x) { int top = this.getHeightMap(x, z); for (int y = 255; y > top; --y) { this.setBlockSkyLight(x, y, z, 15); } for (int y = top; y >= 0; --y) { if (Block.solid[this.getBlockId(x, y, z)]) { break; } this.setBlockSkyLight(x, y, z, 15); } this.setHeightMap(x, z, this.getHighestBlockAt(x, z, false)); } } }
Example 3
Source File: ObjectTree.java From Nukkit with GNU General Public License v3.0 | 6 votes |
public void placeObject(ChunkManager level, int x, int y, int z, NukkitRandom random) { this.placeTrunk(level, x, y, z, random, this.getTreeHeight() - 1); for (int yy = y - 3 + this.getTreeHeight(); yy <= y + this.getTreeHeight(); ++yy) { double yOff = yy - (y + this.getTreeHeight()); int mid = (int) (1 - yOff / 2); for (int xx = x - mid; xx <= x + mid; ++xx) { int xOff = Math.abs(xx - x); for (int zz = z - mid; zz <= z + mid; ++zz) { int zOff = Math.abs(zz - z); if (xOff == mid && zOff == mid && (yOff == 0 || random.nextBoundedInt(2) == 0)) { continue; } if (!Block.solid[level.getBlockIdAt(xx, yy, zz)]) { level.setBlockAt(xx, yy, zz, this.getLeafBlock(), this.getType()); } } } } }
Example 4
Source File: BaseFullChunk.java From Nukkit with GNU General Public License v3.0 | 6 votes |
@Override public void populateSkyLight() { for (int z = 0; z < 16; ++z) { for (int x = 0; x < 16; ++x) { int top = this.getHeightMap(x, z); for (int y = 255; y > top; --y) { this.setBlockSkyLight(x, y, z, 15); } for (int y = top; y >= 0; --y) { if (Block.solid[this.getBlockId(x, y, z)]) { break; } this.setBlockSkyLight(x, y, z, 15); } this.setHeightMap(x, z, this.getHighestBlockAt(x, z, false)); } } }
Example 5
Source File: ObjectTree.java From Nukkit with GNU General Public License v3.0 | 6 votes |
public void placeObject(ChunkManager level, int x, int y, int z, NukkitRandom random) { this.placeTrunk(level, x, y, z, random, this.getTreeHeight() - 1); for (int yy = y - 3 + this.getTreeHeight(); yy <= y + this.getTreeHeight(); ++yy) { double yOff = yy - (y + this.getTreeHeight()); int mid = (int) (1 - yOff / 2); for (int xx = x - mid; xx <= x + mid; ++xx) { int xOff = Math.abs(xx - x); for (int zz = z - mid; zz <= z + mid; ++zz) { int zOff = Math.abs(zz - z); if (xOff == mid && zOff == mid && (yOff == 0 || random.nextBoundedInt(2) == 0)) { continue; } if (!Block.solid[level.getBlockIdAt(xx, yy, zz)]) { level.setBlockIdAt(xx, yy, zz, this.getLeafBlock()); level.setBlockDataAt(xx, yy, zz, this.getType()); } } } } }
Example 6
Source File: BaseFullChunk.java From Nukkit with GNU General Public License v3.0 | 6 votes |
@Override public void populateSkyLight() { for (int z = 0; z < 16; ++z) { for (int x = 0; x < 16; ++x) { int top = this.getHeightMap(x, z); for (int y = 255; y > top; --y) { this.setBlockSkyLight(x, y, z, 15); } for (int y = top; y >= 0; --y) { if (Block.solid[this.getBlockId(x, y, z)]) { break; } this.setBlockSkyLight(x, y, z, 15); } this.setHeightMap(x, z, this.getHighestBlockAt(x, z, false)); } } }
Example 7
Source File: ObjectSpruceTree.java From Nukkit with GNU General Public License v3.0 | 5 votes |
public void placeLeaves(ChunkManager level, int topSize, int lRadius, int x, int y, int z, NukkitRandom random) { 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.setBlockAt(xx, yyy, zz, this.getLeafBlock(), this.getType()); } } } if (radius >= maxR) { radius = minR; minR = 1; if (++maxR > lRadius) { maxR = lRadius; } } else { ++radius; } } }
Example 8
Source File: ObjectSpruceTree.java From Jupiter with GNU General Public License v3.0 | 4 votes |
@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; } } }
Example 9
Source File: ObjectSpruceTree.java From Nukkit with GNU General Public License v3.0 | 4 votes |
@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; } } }