Search in sources :

Example 1 with ObjectOre

use of cn.nukkit.level.generator.object.ore.ObjectOre in project Nukkit by Nukkit.

the class PopulatorGlowStone method populate.

@Override
public void populate(ChunkManager level, int chunkX, int chunkZ, NukkitRandom random) {
    this.level = level;
    BaseFullChunk chunk = level.getChunk(chunkX, chunkZ);
    int bx = chunkX << 4;
    int bz = chunkZ << 4;
    int tx = bx + 15;
    int tz = bz + 15;
    ObjectOre ore = new ObjectOre(random, type, Block.AIR);
    for (int i = 0; i < ore.type.clusterCount; ++i) {
        int x = random.nextRange(0, 15);
        int z = random.nextRange(0, 15);
        int y = this.getHighestWorkableBlock(chunk, x, z);
        if (y != -1) {
            ore.placeObject(level, bx + x, y, bz + z);
        }
    }
}
Also used : BaseFullChunk(cn.nukkit.level.format.generic.BaseFullChunk) ObjectOre(cn.nukkit.level.generator.object.ore.ObjectOre)

Example 2 with ObjectOre

use of cn.nukkit.level.generator.object.ore.ObjectOre in project Nukkit by Nukkit.

the class PopulatorOre method populate.

@Override
public void populate(ChunkManager level, int chunkX, int chunkZ, NukkitRandom random) {
    for (OreType type : this.oreTypes) {
        ObjectOre ore = new ObjectOre(random, type, replaceId);
        for (int i = 0; i < ore.type.clusterCount; ++i) {
            int x = NukkitMath.randomRange(random, chunkX << 4, (chunkX << 4) + 15);
            int y = NukkitMath.randomRange(random, ore.type.minHeight, ore.type.maxHeight);
            int z = NukkitMath.randomRange(random, chunkZ << 4, (chunkZ << 4) + 15);
            if (ore.canPlaceObject(level, x, y, z)) {
                ore.placeObject(level, x, y, z);
            }
        }
    }
}
Also used : OreType(cn.nukkit.level.generator.object.ore.OreType) ObjectOre(cn.nukkit.level.generator.object.ore.ObjectOre)

Aggregations

ObjectOre (cn.nukkit.level.generator.object.ore.ObjectOre)2 BaseFullChunk (cn.nukkit.level.format.generic.BaseFullChunk)1 OreType (cn.nukkit.level.generator.object.ore.OreType)1