Java Code Examples for cn.nukkit.level.format.FullChunk#setBlockId()
The following examples show how to use
cn.nukkit.level.format.FullChunk#setBlockId() .
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: SimpleChunkManager.java From Jupiter with GNU General Public License v3.0 | 5 votes |
@Override public void setBlockIdAt(int x, int y, int z, int id) { FullChunk chunk = this.getChunk(x >> 4, z >> 4); if (chunk != null) { chunk.setBlockId(x & 0xf, y & 0xff, z & 0xf, id); } }
Example 2
Source File: Nether.java From Jupiter with GNU General Public License v3.0 | 5 votes |
@Override public void generateChunk(int chunkX, int chunkZ) { this.nukkitRandom.setSeed(chunkX * localSeed1 ^ chunkZ * localSeed2 ^ this.level.getSeed()); double[][][] noise = Generator.getFastNoise3D(this.noiseBase, 16, 128, 16, 4, 8, 4, chunkX * 16, 0, chunkZ * 16); FullChunk chunk = this.level.getChunk(chunkX, chunkZ); for (int x = 0; x < 16; ++x) { for (int z = 0; z < 16; ++z) { Biome biome = Biome.getBiome(Biome.HELL); chunk.setBiomeId(x, z, Biome.HELL); int biomecolor = biome.getColor(); chunk.setBiomeColor(x, z, (biomecolor >> 16), (biomecolor >> 8) & 0xff, (biomecolor & 0xff)); chunk.setBlockId(x, 0, z, Block.BEDROCK); chunk.setBlockId(x, 127, z, Block.BEDROCK); for (int y = 1; y <= bedrockDepth; y++) { if (nukkitRandom.nextRange(1, 5) == 1) { chunk.setBlockId(x, y, z, Block.BEDROCK); chunk.setBlockId(x, 127 - y, z, Block.BEDROCK); } } for (int y = 1; y < 127; ++y) { double noiseValue = (Math.abs(this.emptyHeight - y) / this.emptyHeight) * this.emptyAmplitude - noise[x][z][y]; noiseValue -= 1 - this.density; if (noiseValue > 0) { chunk.setBlockId(x, y, z, Block.NETHERRACK); } else if (y <= this.waterHeight) { chunk.setBlockId(x, y, z, Block.STILL_LAVA); chunk.setBlockLight(x, y + 1, z, 15); } } } } for (Populator populator : this.generationPopulators) { populator.populate(this.level, chunkX, chunkZ, this.nukkitRandom); } }
Example 3
Source File: PopulatorGroundCover.java From Jupiter with GNU General Public License v3.0 | 5 votes |
@Override public void populate(ChunkManager level, int chunkX, int chunkZ, NukkitRandom random) { FullChunk chunk = level.getChunk(chunkX, chunkZ); for (int x = 0; x < 16; ++x) { for (int z = 0; z < 16; ++z) { Biome biome = Biome.getBiome(chunk.getBiomeId(x, z)); Block[] cover = biome.getGroundCover(); if (cover != null && cover.length > 0) { int diffY = 0; if (!cover[0].isSolid()) { diffY = 1; } byte[] column = chunk.getBlockIdColumn(x, z); int y; for (y = 127; y > 0; --y) { if (column[y] != 0x00 && !Block.get(column[y] & 0xff).isTransparent()) { break; } } int startY = Math.min(127, y + diffY); int endY = startY - cover.length; for (y = startY; y > endY && y >= 0; --y) { Block b = cover[startY - y]; if (column[y] == 0x00 && b.isSolid()) { break; } if (b.getDamage() == 0) { chunk.setBlockId(x, y, z, b.getId()); } else { chunk.setBlock(x, y, z, b.getId(), b.getDamage()); } } } } } }
Example 4
Source File: SimpleChunkManager.java From Nukkit with GNU General Public License v3.0 | 5 votes |
@Override public void setBlockIdAt(int x, int y, int z, int id) { FullChunk chunk = this.getChunk(x >> 4, z >> 4); if (chunk != null) { chunk.setBlockId(x & 0xf, y & 0xff, z & 0xf, id); } }
Example 5
Source File: WaterIcePopulator.java From Nukkit with GNU General Public License v3.0 | 5 votes |
@Override public void populate(ChunkManager level, int chunkX, int chunkZ, NukkitRandom random, FullChunk chunk) { for (int x = 0; x < 16; x++) { for (int z = 0; z < 16; z++) { Biome biome = EnumBiome.getBiome(chunk.getBiomeId(x, z)); if (biome.isFreezing()) { int topBlock = chunk.getHighestBlockAt(x, z); if (chunk.getBlockId(x, topBlock, z) == STILL_WATER) { chunk.setBlockId(x, topBlock, z, ICE); } } } } }
Example 6
Source File: PopulatorBedrock.java From Nukkit with GNU General Public License v3.0 | 5 votes |
@Override public void populate(ChunkManager level, int chunkX, int chunkZ, NukkitRandom random, FullChunk chunk) { for (int x = 0; x < 16; x++) { for (int z = 0; z < 16; z++) { chunk.setBlockId(x, 0, z, BEDROCK); for (int i = 1; i < 5; i++) { if (random.nextBoundedInt(i) == 0) { //decreasing amount chunk.setBlockId(x, i, z, BEDROCK); } } } } }
Example 7
Source File: SimpleChunkManager.java From Nukkit with GNU General Public License v3.0 | 5 votes |
@Override public void setBlockIdAt(int x, int y, int z, int id) { FullChunk chunk = this.getChunk(x >> 4, z >> 4); if (chunk != null) { chunk.setBlockId(x & 0xf, y & 0xff, z & 0xf, id); } }
Example 8
Source File: Nether.java From Nukkit with GNU General Public License v3.0 | 5 votes |
@Override public void generateChunk(int chunkX, int chunkZ) { this.nukkitRandom.setSeed(chunkX * localSeed1 ^ chunkZ * localSeed2 ^ this.level.getSeed()); double[][][] noise = Generator.getFastNoise3D(this.noiseBase, 16, 128, 16, 4, 8, 4, chunkX * 16, 0, chunkZ * 16); FullChunk chunk = this.level.getChunk(chunkX, chunkZ); for (int x = 0; x < 16; ++x) { for (int z = 0; z < 16; ++z) { Biome biome = Biome.getBiome(Biome.HELL); chunk.setBiomeId(x, z, Biome.HELL); int biomecolor = biome.getColor(); chunk.setBiomeColor(x, z, (biomecolor >> 16), (biomecolor >> 8) & 0xff, (biomecolor & 0xff)); chunk.setBlockId(x, 0, z, Block.BEDROCK); chunk.setBlockId(x, 127, z, Block.BEDROCK); for (int y = 1; y <= bedrockDepth; y++) { if (nukkitRandom.nextRange(1, 5) == 1) { chunk.setBlockId(x, y, z, Block.BEDROCK); chunk.setBlockId(x, 127 - y, z, Block.BEDROCK); } } for (int y = 1; y < 127; ++y) { double noiseValue = (Math.abs(this.emptyHeight - y) / this.emptyHeight) * this.emptyAmplitude - noise[x][z][y]; noiseValue -= 1 - this.density; if (noiseValue > 0) { chunk.setBlockId(x, y, z, Block.NETHERRACK); } else if (y <= this.waterHeight) { chunk.setBlockId(x, y, z, Block.STILL_LAVA); chunk.setBlockLight(x, y + 1, z, 15); } } } } for (Populator populator : this.generationPopulators) { populator.populate(this.level, chunkX, chunkZ, this.nukkitRandom); } }
Example 9
Source File: PopulatorGroundCover.java From Nukkit with GNU General Public License v3.0 | 4 votes |
@Override public void populate(ChunkManager level, int chunkX, int chunkZ, NukkitRandom random) { FullChunk chunk = level.getChunk(chunkX, chunkZ); for (int x = 0; x < 16; ++x) { for (int z = 0; z < 16; ++z) { Biome biome = Biome.getBiome(chunk.getBiomeId(x, z)); Block[] cover = biome.getGroundCover(); if (cover != null && cover.length > 0) { int diffY = 0; if (!cover[0].isSolid()) { diffY = 1; } int height = chunk.getHeightMap(x, z); if (height == 0 || height == 255) height = 126; int y; for (y = height + 1; y > 0; --y) { int fullId = chunk.getFullBlock(x, y, z); if (fullId != 0 && !Block.get(fullId >> 4).isTransparent()) { break; } } int startY = Math.min(127, y + diffY); int endY = startY - cover.length; for (y = startY; y > endY && y >= 0; --y) { Block b = cover[startY - y]; int blockId = chunk.getBlockId(x, y, z); if (blockId == 0 && b.isSolid()) { break; } if (b.getDamage() == 0) { chunk.setBlockId(x, y, z, b.getId()); } else { chunk.setBlock(x, y, z, b.getId(), b.getDamage()); } } } } } }