cn.nukkit.level.ChunkManager Java Examples

The following examples show how to use cn.nukkit.level.ChunkManager. 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: PopulatorLava.java    From Nukkit with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void populate(ChunkManager level, int chunkX, int chunkZ, NukkitRandom random, FullChunk chunk) {
    this.random = random;
    if (random.nextRange(0, 100) < 5) {
        this.level = level;
        int amount = random.nextRange(0, this.randomAmount + 1) + this.baseAmount;
        int bx = chunkX << 4;
        int bz = chunkZ << 4;
        int tx = bx + 15;
        int tz = bz + 15;
        for (int i = 0; i < amount; ++i) {
            int x = random.nextRange(0, 15);
            int z = random.nextRange(0, 15);
            int y = this.getHighestWorkableBlock(chunk, x, z);
            if (y != -1 && chunk.getBlockId(x, y, z) == Block.AIR) {
                chunk.setBlock(x, y, z, Block.LAVA);
                chunk.setBlockLight(x, y, z, Block.light[Block.LAVA]);
                this.lavaSpread(bx + x, y, bz + z);
            }
        }
    }
}
 
Example #2
Source File: ObjectTree.java    From Nukkit with GNU General Public License v3.0 6 votes vote down vote up
public boolean canPlaceObject(ChunkManager level, int x, int y, int z, NukkitRandom random) {
    int radiusToCheck = 0;
    for (int yy = 0; yy < this.getTreeHeight() + 3; ++yy) {
        if (yy == 1 || yy == this.getTreeHeight()) {
            ++radiusToCheck;
        }
        for (int xx = -radiusToCheck; xx < (radiusToCheck + 1); ++xx) {
            for (int zz = -radiusToCheck; zz < (radiusToCheck + 1); ++zz) {
                if (!this.overridable(level.getBlockIdAt(x + xx, y + yy, z + zz))) {
                    return false;
                }
            }
        }
    }

    return true;
}
 
Example #3
Source File: PopulatorLava.java    From Nukkit with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void populate(ChunkManager level, int chunkX, int chunkZ, NukkitRandom random) {
    this.random = random;
    if (random.nextRange(0, 100) < 5) {
        this.level = level;
        int amount = random.nextRange(0, this.randomAmount + 1) + this.baseAmount;
        BaseFullChunk chunk = level.getChunk(chunkX, chunkZ);
        int bx = chunkX << 4;
        int bz = chunkZ << 4;
        int tx = bx + 15;
        int tz = bz + 15;
        for (int i = 0; i < amount; ++i) {
            int x = random.nextRange(0, 15);
            int z = random.nextRange(0, 15);
            int y = this.getHighestWorkableBlock(chunk, x, z);
            if (y != -1 && chunk.getBlockId(x, y, z) == Block.AIR) {
                chunk.setBlock(x, y, z, Block.LAVA);
                chunk.setBlockLight(x, y, z, Block.light[Block.LAVA]);
                this.lavaSpread(bx + x, y, bz + z);
            }
        }
    }
}
 
Example #4
Source File: SavannaTreePopulator.java    From Nukkit with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void populate(ChunkManager level, int chunkX, int chunkZ, NukkitRandom random, FullChunk chunk) {
    this.level = level;
    int amount = random.nextBoundedInt(this.randomAmount + 1) + this.baseAmount;
    Vector3 v = new Vector3();

    for (int i = 0; i < amount; ++i) {
        int x = NukkitMath.randomRange(random, chunkX << 4, (chunkX << 4) + 15);
        int z = NukkitMath.randomRange(random, chunkZ << 4, (chunkZ << 4) + 15);
        int y = this.getHighestWorkableBlock(x, z);
        if (y == -1) {
            continue;
        }
        new ObjectSavannaTree().generate(level, random, v.setComponents(x, y, z));
    }
}
 
Example #5
Source File: JungleTreePopulator.java    From Jupiter with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void populate(ChunkManager level, int chunkX, int chunkZ, NukkitRandom random) {
    this.level = level;
    int amount = random.nextBoundedInt(this.randomAmount + 1) + this.baseAmount;
    Vector3 v = new Vector3();

    for (int i = 0; i < amount; ++i) {
        int x = NukkitMath.randomRange(random, chunkX << 4, (chunkX << 4) + 15);
        int z = NukkitMath.randomRange(random, chunkZ << 4, (chunkZ << 4) + 15);
        int y = this.getHighestWorkableBlock(x, z);
        if (y == -1) {
            continue;
        }
        new NewJungleTree(4 + random.nextBoundedInt(7)).generate(level, random, v.setComponents(x, y, z));
    }
}
 
Example #6
Source File: SwampTreePopulator.java    From Jupiter with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void populate(ChunkManager level, int chunkX, int chunkZ, NukkitRandom random) {
    this.level = level;
    int amount = random.nextBoundedInt(this.randomAmount + 1) + this.baseAmount;
    Vector3 v = new Vector3();

    for (int i = 0; i < amount; ++i) {
        int x = NukkitMath.randomRange(random, chunkX << 4, (chunkX << 4) + 15);
        int z = NukkitMath.randomRange(random, chunkZ << 4, (chunkZ << 4) + 15);
        int y = this.getHighestWorkableBlock(x, z);
        if (y == -1) {
            continue;
        }
        new ObjectSwampTree().generate(level, random, v.setComponents(x, y, z));
    }
}
 
Example #7
Source File: PopulatorCaves.java    From Nukkit with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void populate(ChunkManager level, int chunkX, int chunkZ, NukkitRandom random) {
    this.random = new Random();
    this.random.setSeed(level.getSeed());
    long worldLong1 = this.random.nextLong();
    long worldLong2 = this.random.nextLong();

    int size = this.checkAreaSize;

    for (int x = chunkX - size; x <= chunkX + size; x++)
        for (int z = chunkZ - size; z <= chunkZ + size; z++) {
            long randomX = x * worldLong1;
            long randomZ = z * worldLong2;
            this.random.setSeed(randomX ^ randomZ ^ level.getSeed());
            generateChunk(x, z, level.getChunk(chunkX, chunkZ));
        }
}
 
Example #8
Source File: PopulatorLava.java    From Jupiter with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void populate(ChunkManager level, int chunkX, int chunkZ, NukkitRandom random) {
    this.random = random;
    if (random.nextRange(0, 100) < 5) {
        this.level = level;
        int amount = random.nextRange(0, this.randomAmount + 1) + this.baseAmount;
        BaseFullChunk chunk = level.getChunk(chunkX, chunkZ);
        int bx = chunkX << 4;
        int bz = chunkZ << 4;
        int tx = bx + 15;
        int tz = bz + 15;
        for (int i = 0; i < amount; ++i) {
            int x = random.nextRange(0, 15);
            int z = random.nextRange(0, 15);
            int y = this.getHighestWorkableBlock(chunk, x, z);
            if (y != -1 && chunk.getBlockId(x, y, z) == Block.AIR) {
                chunk.setBlock(x, y, z, Block.LAVA);
                chunk.setBlockLight(x, y, z, Block.light[Block.LAVA]);
                this.lavaSpread(bx + x, y, bz + z);
            }
        }
    }
}
 
Example #9
Source File: PopulatorTallGrass.java    From Nukkit with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void populate(ChunkManager level, int chunkX, int chunkZ, NukkitRandom random) {
    this.level = level;
    int amount = random.nextBoundedInt(this.randomAmount + 1) + this.baseAmount;
    for (int i = 0; i < amount; ++i) {
        int x = NukkitMath.randomRange(random, chunkX * 16, chunkX * 16 + 15);
        int z = NukkitMath.randomRange(random, chunkZ * 16, chunkZ * 16 + 15);
        int y = this.getHighestWorkableBlock(x, z);

        if (y != -1 && this.canTallGrassStay(x, y, z)) {
            this.level.setBlockIdAt(x, y, z, Block.DOUBLE_PLANT);
            this.level.setBlockDataAt(x, y, z, 2);
            this.level.setBlockIdAt(x, y + 1, z, Block.DOUBLE_PLANT);
            this.level.setBlockDataAt(x, y + 1, z, 10);
        }
    }
}
 
Example #10
Source File: MushroomPopulator.java    From Jupiter with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void populate(ChunkManager level, int chunkX, int chunkZ, NukkitRandom random) {
    this.level = level;
    int amount = random.nextBoundedInt(this.randomAmount + 1) + this.baseAmount;
    Vector3 v = new Vector3();

    for (int i = 0; i < amount; ++i) {
        int x = NukkitMath.randomRange(random, chunkX << 4, (chunkX << 4) + 15);
        int z = NukkitMath.randomRange(random, chunkZ << 4, (chunkZ << 4) + 15);
        int y = this.getHighestWorkableBlock(x, z);
        if (y == -1) {
            continue;
        }
        new BigMushroom(type).generate(level, random, v.setComponents(x, y, z));
    }
}
 
Example #11
Source File: PopulatorGroundFire.java    From Jupiter with GNU General Public License v3.0 6 votes vote down vote up
@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;
    int amount = random.nextRange(0, this.randomAmount + 1) + this.baseAmount;
    for (int i = 0; i < amount; ++i) {
        int x = random.nextRange(0, 15);
        int z = random.nextRange(0, 15);
        int y = this.getHighestWorkableBlock(chunk, x, z);
        if (y != -1 && this.canGroundFireStay(chunk, x, y, z)) {
            chunk.setBlock(x, y, z, Block.FIRE);
            chunk.setBlockLight(x, y, z, Block.light[Block.FIRE]);
        }
    }
}
 
Example #12
Source File: ObjectTree.java    From Nukkit with GNU General Public License v3.0 6 votes vote down vote up
public boolean canPlaceObject(ChunkManager level, int x, int y, int z, NukkitRandom random) {
    int radiusToCheck = 0;
    for (int yy = 0; yy < this.getTreeHeight() + 3; ++yy) {
        if (yy == 1 || yy == this.getTreeHeight()) {
            ++radiusToCheck;
        }
        for (int xx = -radiusToCheck; xx < (radiusToCheck + 1); ++xx) {
            for (int zz = -radiusToCheck; zz < (radiusToCheck + 1); ++zz) {
                if (!this.overridable(level.getBlockIdAt(x + xx, y + yy, z + zz))) {
                    return false;
                }
            }
        }
    }

    return true;
}
 
Example #13
Source File: HugeTreesGenerator.java    From Jupiter with GNU General Public License v3.0 6 votes vote down vote up
/**
 * grow leaves in a circle
 */
protected void growLeavesLayer(ChunkManager worldIn, Vector3 layerCenter, int width) {
    int i = width * width;

    for (int j = -width; j <= width; ++j) {
        for (int k = -width; k <= width; ++k) {
            if (j * j + k * k <= i) {
                Vector3 blockpos = layerCenter.add(j, 0, k);
                int id = worldIn.getBlockIdAt((int) blockpos.x, (int) blockpos.y, (int) blockpos.z);

                if (id == Block.AIR || id == Block.LEAVES) {
                    this.setBlockAndNotifyAdequately(worldIn, blockpos, this.leavesMetadata);
                }
            }
        }
    }
}
 
Example #14
Source File: ObjectTree.java    From Jupiter with GNU General Public License v3.0 6 votes vote down vote up
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 #15
Source File: ObjectTree.java    From Nukkit with GNU General Public License v3.0 6 votes vote down vote up
public static void growTree(ChunkManager level, int x, int y, int z, NukkitRandom random, int type) {
    ObjectTree tree;
    switch (type) {
        case BlockSapling.SPRUCE:
            tree = new ObjectSpruceTree();
            break;
        case BlockSapling.BIRCH:
            tree = new ObjectBirchTree();
            break;
        case BlockSapling.JUNGLE:
            tree = new ObjectJungleTree();
            break;
        case BlockSapling.BIRCH_TALL:
            tree = new ObjectTallBirchTree();
            break;
        case BlockSapling.OAK:
        default:
            tree = new ObjectOakTree();
            //todo: more complex treeeeeeeeeeeeeeeee
            break;
    }

    if (tree.canPlaceObject(level, x, y, z, random)) {
        tree.placeObject(level, x, y, z, random);
    }
}
 
Example #16
Source File: JungleFloorPopulator.java    From Nukkit with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void populate(ChunkManager level, int chunkX, int chunkZ, NukkitRandom random, FullChunk chunk) {
    this.level = level;
    int amount = random.nextBoundedInt(this.randomAmount + 1) + this.baseAmount;
    Vector3 v = new Vector3();

    for (int i = 0; i < amount; ++i) {
        int x = NukkitMath.randomRange(random, chunkX << 4, (chunkX << 4) + 15);
        int z = NukkitMath.randomRange(random, chunkZ << 4, (chunkZ << 4) + 15);
        int y = this.getHighestWorkableBlock(x, z);
        if (y == -1) {
            continue;
        }
        new NewJungleTree(1, 0).generate(level, random, v.setComponents(x, y, z));
    }
}
 
Example #17
Source File: PopulatorFlower.java    From Jupiter with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void populate(ChunkManager level, int chunkX, int chunkZ, NukkitRandom random) {
    this.level = level;
    int amount = random.nextBoundedInt(this.randomAmount + 1) + this.baseAmount;

    if (flowerTypes.size() == 0) {
        this.addType(Block.RED_FLOWER, BlockFlower.TYPE_POPPY);
        this.addType(Block.DANDELION, 0);
    }

    int endNum = this.flowerTypes.size();

    for (int i = 0; i < amount; ++i) {
        int x = NukkitMath.randomRange(random, chunkX * 16, chunkX * 16 + 15);
        int z = NukkitMath.randomRange(random, chunkZ * 16, chunkZ * 16 + 15);
        int y = this.getHighestWorkableBlock(x, z);


        if (y != -1 && this.canFlowerStay(x, y, z)) {
            int[] type = this.flowerTypes.get(random.nextRange(0, endNum - 1));
            this.level.setBlockIdAt(x, y, z, type[0]);
            this.level.setBlockDataAt(x, y, z, type[1]);
        }
    }
}
 
Example #18
Source File: SwampTreePopulator.java    From Nukkit with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void populate(ChunkManager level, int chunkX, int chunkZ, NukkitRandom random) {
    this.level = level;
    int amount = random.nextBoundedInt(this.randomAmount + 1) + this.baseAmount;
    Vector3 v = new Vector3();

    for (int i = 0; i < amount; ++i) {
        int x = NukkitMath.randomRange(random, chunkX << 4, (chunkX << 4) + 15);
        int z = NukkitMath.randomRange(random, chunkZ << 4, (chunkZ << 4) + 15);
        int y = this.getHighestWorkableBlock(x, z);
        if (y == -1) {
            continue;
        }
        new ObjectSwampTree().generate(level, random, v.setComponents(x, y, z));
    }
}
 
Example #19
Source File: JungleTreePopulator.java    From Nukkit with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void populate(ChunkManager level, int chunkX, int chunkZ, NukkitRandom random) {
    this.level = level;
    int amount = random.nextBoundedInt(this.randomAmount + 1) + this.baseAmount;
    Vector3 v = new Vector3();

    for (int i = 0; i < amount; ++i) {
        int x = NukkitMath.randomRange(random, chunkX << 4, (chunkX << 4) + 15);
        int z = NukkitMath.randomRange(random, chunkZ << 4, (chunkZ << 4) + 15);
        int y = this.getHighestWorkableBlock(x, z);
        if (y == -1) {
            continue;
        }
        new NewJungleTree(4 + random.nextBoundedInt(7)).generate(level, random, v.setComponents(x, y, z));
    }
}
 
Example #20
Source File: HugeTreesGenerator.java    From Nukkit with GNU General Public License v3.0 6 votes vote down vote up
/**
 * grow leaves in a circle with the outsides being within the circle
 */
protected void growLeavesLayerStrict(ChunkManager worldIn, Vector3 layerCenter, int width) {
    int i = width * width;

    for (int j = -width; j <= width + 1; ++j) {
        for (int k = -width; k <= width + 1; ++k) {
            int l = j - 1;
            int i1 = k - 1;

            if (j * j + k * k <= i || l * l + i1 * i1 <= i || j * j + i1 * i1 <= i || l * l + k * k <= i) {
                Vector3 blockpos = layerCenter.add(j, 0, k);
                int id = worldIn.getBlockIdAt((int) blockpos.x, (int) blockpos.y, (int) blockpos.z);

                if (id == Block.AIR || id == Block.LEAVES) {
                    this.setBlockAndNotifyAdequately(worldIn, blockpos, this.leavesMetadata);
                }
            }
        }
    }
}
 
Example #21
Source File: ObjectTallGrass.java    From Jupiter with GNU General Public License v3.0 6 votes vote down vote up
public static void growGrass(ChunkManager level, Vector3 pos, NukkitRandom random, int count, int radius) {
    int[][] arr = {
            {Block.DANDELION, 0},
            {Block.POPPY, 0},
            {Block.TALL_GRASS, 1},
            {Block.TALL_GRASS, 1},
            {Block.TALL_GRASS, 1},
            {Block.TALL_GRASS, 1}
    };
    int arrC = arr.length - 1;
    for (int c = 0; c < count; c++) {
        int x = random.nextRange((int) (pos.x - radius), (int) (pos.x + radius));
        int z = random.nextRange((int) (pos.z) - radius, (int) (pos.z + radius));

        if (level.getBlockIdAt(x, (int) (pos.y + 1), z) == Block.AIR && level.getBlockIdAt(x, (int) (pos.y), z) == Block.GRASS) {
            int[] t = arr[random.nextRange(0, arrC)];
            level.setBlockIdAt(x, (int) (pos.y + 1), z, t[0]);
            level.setBlockDataAt(x, (int) (pos.y + 1), z, t[1]);
        }
    }
}
 
Example #22
Source File: NewJungleTree.java    From Nukkit with GNU General Public License v3.0 5 votes vote down vote up
private void addHangingVine(ChunkManager worldIn, BlockVector3 pos, int meta) {
    this.addVine(worldIn, pos, meta);
    int i = 4;

    for (pos = pos.down(); i > 0 && worldIn.getBlockIdAt(pos.x, pos.y, pos.z) == Block.AIR; --i) {
        this.addVine(worldIn, pos, meta);
        pos = pos.down();
    }
}
 
Example #23
Source File: PopulatorGroundFire.java    From Nukkit with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected int getHighestWorkableBlock(ChunkManager level, int x, int z, FullChunk chunk) {
    int y;
    for (y = 0; y <= 127; ++y) {
        int b = chunk.getBlockId(x, y, z);
        if (b == Block.AIR) {
            break;
        }
    }
    return y == 0 ? -1 : y;
}
 
Example #24
Source File: PopulatorTree.java    From Nukkit with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void populate(ChunkManager level, int chunkX, int chunkZ, NukkitRandom random) {
    this.level = level;
    int amount = random.nextBoundedInt(this.randomAmount + 1) + this.baseAmount;
    for (int i = 0; i < amount; ++i) {
        int x = NukkitMath.randomRange(random, chunkX << 4, (chunkX << 4) + 15);
        int z = NukkitMath.randomRange(random, chunkZ << 4, (chunkZ << 4) + 15);
        int y = this.getHighestWorkableBlock(x, z);
        if (y == -1) {
            continue;
        }
        ObjectTree.growTree(this.level, x, y, z, random, this.type);
    }
}
 
Example #25
Source File: PopulatorGlowStone.java    From Nukkit with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void populate(ChunkManager level, int chunkX, int chunkZ, NukkitRandom random, FullChunk chunk) {
    int x = NukkitMath.randomRange(random, chunkX << 4, (chunkX << 4) + 15);
    int z = NukkitMath.randomRange(random, chunkZ << 4, (chunkZ << 4) + 15);
    int y = this.getHighestWorkableBlock(chunk, x & 0xF, z & 0xF);
    if (y != -1 && level.getBlockIdAt(x, y, z) != NETHERRACK) {
        int count = NukkitMath.randomRange(random, 40, 60);
        for (int i = 0; i < count; i++) {
            level.setBlockAt(x + (random.nextBoundedInt(7) - 3), y + (random.nextBoundedInt(9) - 4), z + (random.nextBoundedInt(7) - 3), GLOWSTONE);
        }
    }
}
 
Example #26
Source File: ObjectSavannaTree.java    From Nukkit with GNU General Public License v3.0 5 votes vote down vote up
private void placeLeafAt(ChunkManager worldIn, Vector3 pos) {
    int material = worldIn.getBlockIdAt(pos.getFloorX(), pos.getFloorY(), pos.getFloorZ());

    if (material == Block.AIR || material == Block.LEAVES) {
        this.setBlockAndNotifyAdequately(worldIn, pos, LEAF);
    }
}
 
Example #27
Source File: ObjectBigSpruceTree.java    From Nukkit with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void placeObject(ChunkManager level, int x, int y, int z, NukkitRandom random) {
    this.treeHeight = random.nextBoundedInt(15) + 20;

    int topSize = this.treeHeight - (int) (this.treeHeight * leafStartHeightMultiplier);
    int lRadius = baseLeafRadius + random.nextBoundedInt(2);

    this.placeTrunk(level, x, y, z, random, this.getTreeHeight() - random.nextBoundedInt(3));

    this.placeLeaves(level, topSize, lRadius, x, y, z, random);
}
 
Example #28
Source File: ObjectSpruceTree.java    From Nukkit with GNU General Public License v3.0 5 votes vote down vote up
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 #29
Source File: NewJungleTree.java    From Jupiter with GNU General Public License v3.0 5 votes vote down vote up
private void addHangingVine(ChunkManager worldIn, BlockVector3 pos, int meta) {
    this.addVine(worldIn, pos, meta);
    int i = 4;

    for (pos = pos.down(); i > 0 && worldIn.getBlockIdAt(pos.x, pos.y, pos.z) == Block.AIR; --i) {
        this.addVine(worldIn, pos, meta);
        pos = pos.down();
    }
}
 
Example #30
Source File: PopulatorOre.java    From Jupiter with GNU General Public License v3.0 5 votes vote down vote up
@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);
            }
        }
    }
}