Java Code Examples for cn.nukkit.level.format.FullChunk#setFullBlockId()

The following examples show how to use cn.nukkit.level.format.FullChunk#setFullBlockId() . 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 Nukkit with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void setBlockFullIdAt(int x, int y, int z, int fullId) {
    FullChunk chunk = this.getChunk(x >> 4, z >> 4);
    if (chunk != null) {
        chunk.setFullBlockId(x & 0xf, y & 0xff, z & 0xf, fullId);
    }
}
 
Example 2
Source File: PopulatorTallSugarcane.java    From Nukkit with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void placeBlock(int x, int y, int z, int id, FullChunk chunk, NukkitRandom random) {
    int height = ThreadLocalRandom.current().nextInt(3) + 1;
    for (int i = 0; i < height; i++)    {
        chunk.setFullBlockId(x, y + i, z, id);
    }
}
 
Example 3
Source File: PopulatorFlower.java    From Nukkit with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void placeBlock(int x, int y, int z, int id, FullChunk chunk, NukkitRandom random) {
    if (flowerTypes.size() != 0) {
        int[] type = flowerTypes.get(ThreadLocalRandom.current().nextInt(flowerTypes.size()));
        chunk.setFullBlockId(x, y, z, (type[0] << 4) | type[1]);
        if (type[0] == DOUBLE_PLANT) {
            chunk.setFullBlockId(x, y + 1, z, (type[0] << 4) | (8 | type[1]));
        }
    }
}
 
Example 4
Source File: PopulatorGroundCover.java    From Nukkit with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void populate(ChunkManager level, int chunkX, int chunkZ, NukkitRandom random, FullChunk chunk) {
    int realX = chunkX << 4;
    int realZ = chunkZ << 4;
    for (int x = 0; x < 16; ++x) {
        for (int z = 0; z < 16; ++z) {
            Biome realBiome = EnumBiome.getBiome(chunk.getBiomeId(x, z));
            if (realBiome instanceof CoveredBiome) {
                final CoveredBiome biome = (CoveredBiome) realBiome;
                //just in case!
                synchronized (biome.synchronizeCover) {
                    biome.preCover(realX | x, realZ | z);
                    int coverBlock = biome.getCoverBlock() << 4;

                    boolean hasCovered = false;
                    int realY;
                    //start one below build limit in case of cover blocks
                    for (int y = 254; y > 32; y--) {
                        if (chunk.getFullBlock(x, y, z) == STONE) {
                            COVER:
                            if (!hasCovered) {
                                if (y >= Normal.seaHeight) {
                                    chunk.setFullBlockId(x, y + 1, z, coverBlock);
                                    int surfaceDepth = biome.getSurfaceDepth(y);
                                    for (int i = 0; i < surfaceDepth; i++) {
                                        realY = y - i;
                                        if (chunk.getFullBlock(x, realY, z) == STONE) {
                                            chunk.setFullBlockId(x, realY, z, (biome.getSurfaceBlock(realY) << 4) | biome.getSurfaceMeta(realY));
                                        } else break COVER;
                                    }
                                    y -= surfaceDepth;
                                }
                                int groundDepth = biome.getGroundDepth(y);
                                for (int i = 0; i < groundDepth; i++) {
                                    realY = y - i;
                                    if (chunk.getFullBlock(x, realY, z) == STONE) {
                                        chunk.setFullBlockId(x, realY, z, (biome.getGroundBlock(realY) << 4) | biome.getGroundMeta(realY));
                                    } else break COVER;
                                }
                                //don't take all of groundDepth away because we do y-- in the loop
                                y -= groundDepth - 1;
                            }
                            hasCovered = true;
                        } else {
                            if (hasCovered) {
                                //reset it if this isn't a valid stone block (allows us to place ground cover on top and below overhangs)
                                hasCovered = false;
                            }
                        }
                    }
                }
            }
        }
    }
}
 
Example 5
Source File: PopulatorDoublePlant.java    From Nukkit with GNU General Public License v3.0 4 votes vote down vote up
@Override
protected void placeBlock(int x, int y, int z, int id, FullChunk chunk, NukkitRandom random) {
    super.placeBlock(x, y, z, id, chunk, random);
    chunk.setFullBlockId(x, y + 1, z, 8 | id);
}
 
Example 6
Source File: PopulatorSurfaceBlock.java    From Nukkit with GNU General Public License v3.0 4 votes vote down vote up
protected void placeBlock(int x, int y, int z, int id, FullChunk chunk, NukkitRandom random) {
    chunk.setFullBlockId(x, y, z, id);
}