cn.nukkit.math.NukkitRandom Java Examples
The following examples show how to use
cn.nukkit.math.NukkitRandom.
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: DarkOakTreePopulator.java From Nukkit with GNU General Public License v3.0 | 6 votes |
@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 ObjectDarkOakTree().generate(level, random, v.setComponents(x, y, z)); } }
Example #2
Source File: PopulatorCaves.java From Jupiter with GNU General Public License v3.0 | 6 votes |
@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 #3
Source File: PopulatorTallGrass.java From Jupiter with GNU General Public License v3.0 | 6 votes |
@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 #4
Source File: BlockTNT.java From Nukkit with GNU General Public License v3.0 | 6 votes |
public void prime(int fuse) { this.getLevel().setBlock(this, new BlockAir(), true); double mot = (new NukkitRandom()).nextSignedFloat() * Math.PI * 2; CompoundTag nbt = new CompoundTag() .putList(new ListTag<DoubleTag>("Pos") .add(new DoubleTag("", this.x + 0.5)) .add(new DoubleTag("", this.y)) .add(new DoubleTag("", this.z + 0.5))) .putList(new ListTag<DoubleTag>("Motion") .add(new DoubleTag("", -Math.sin(mot) * 0.02)) .add(new DoubleTag("", 0.2)) .add(new DoubleTag("", -Math.cos(mot) * 0.02))) .putList(new ListTag<FloatTag>("Rotation") .add(new FloatTag("", 0)) .add(new FloatTag("", 0))) .putShort("Fuse", fuse); Entity tnt = new EntityPrimedTNT( this.getLevel().getChunk(this.getFloorX() >> 4, this.getFloorZ() >> 4), nbt ); tnt.spawnToAll(); this.level.addSound(this, Sound.RANDOM_FUSE); }
Example #5
Source File: SwampTreePopulator.java From Nukkit with GNU General Public License v3.0 | 6 votes |
@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 #6
Source File: BlockGrass.java From Jupiter with GNU General Public License v3.0 | 6 votes |
@Override public boolean onActivate(Item item, Player player) { if (item.getId() == Item.DYE && item.getDamage() == 0x0F) { item.count--; ObjectTallGrass.growGrass(this.getLevel(), this, new NukkitRandom(), 15, 10); return true; } else if (item.isHoe()) { item.useOn(this); this.getLevel().setBlock(this, new BlockFarmland()); return true; } else if (item.isShovel()) { item.useOn(this); this.getLevel().setBlock(this, new BlockGrassPath()); return true; } return false; }
Example #7
Source File: JungleFloorPopulator.java From Nukkit with GNU General Public License v3.0 | 6 votes |
@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 #8
Source File: Perlin.java From Nukkit with GNU General Public License v3.0 | 6 votes |
public Perlin(NukkitRandom random, double octaves, double persistence, double expansion) { this.octaves = octaves; this.persistence = persistence; this.expansion = expansion; this.offsetX = random.nextFloat() * 256; this.offsetY = random.nextFloat() * 256; this.offsetZ = random.nextFloat() * 256; this.perm = new int[512]; for (int i = 0; i < 256; ++i) { this.perm[i] = random.nextBoundedInt(256); } for (int i = 0; i < 256; ++i) { int pos = random.nextBoundedInt(256 - i) + i; int old = this.perm[i]; this.perm[i] = this.perm[pos]; this.perm[pos] = old; this.perm[i + 256] = this.perm[i]; } }
Example #9
Source File: SimplexD.java From Nukkit with GNU General Public License v3.0 | 6 votes |
public SimplexD(NukkitRandom random, double octaves, double persistence) { super(random, octaves, persistence); this.offsetW = random.nextDouble() * 256; SQRT_3 = Math.sqrt(3); SQRT_5 = Math.sqrt(5); F2 = 0.5 * (SQRT_3 - 1); G2 = (3 - SQRT_3) / 6; G22 = G2 * 2.0 - 1; F3 = 1.0 / 3.0; G3 = 1.0 / 6.0; F4 = (SQRT_5 - 1.0) / 4.0; G4 = (5.0 - SQRT_5) / 20.0; G42 = G4 * 2.0; G43 = G4 * 3.0; G44 = G4 * 4.0 - 1.0; }
Example #10
Source File: PerlinD.java From Nukkit with GNU General Public License v3.0 | 6 votes |
public PerlinD(NukkitRandom random, double octaves, double persistence, double expansion) { this.octaves = octaves; this.persistence = persistence; this.expansion = expansion; this.offsetX = random.nextFloat() * 256; this.offsetY = random.nextFloat() * 256; this.offsetZ = random.nextFloat() * 256; this.perm = new int[512]; for (int i = 0; i < 256; ++i) { this.perm[i] = random.nextBoundedInt(256); } for (int i = 0; i < 256; ++i) { int pos = random.nextBoundedInt(256 - i) + i; int old = this.perm[i]; this.perm[i] = this.perm[pos]; this.perm[pos] = old; this.perm[i + 256] = this.perm[i]; } }
Example #11
Source File: BlockTNT.java From Nukkit with GNU General Public License v3.0 | 6 votes |
public void prime(int fuse, Entity source) { this.getLevel().setBlock(this, Block.get(BlockID.AIR), true); double mot = (new NukkitRandom()).nextSignedFloat() * Math.PI * 2; CompoundTag nbt = new CompoundTag() .putList(new ListTag<DoubleTag>("Pos") .add(new DoubleTag("", this.x + 0.5)) .add(new DoubleTag("", this.y)) .add(new DoubleTag("", this.z + 0.5))) .putList(new ListTag<DoubleTag>("Motion") .add(new DoubleTag("", -Math.sin(mot) * 0.02)) .add(new DoubleTag("", 0.2)) .add(new DoubleTag("", -Math.cos(mot) * 0.02))) .putList(new ListTag<FloatTag>("Rotation") .add(new FloatTag("", 0)) .add(new FloatTag("", 0))) .putShort("Fuse", fuse); Entity tnt = Entity.createEntity("PrimedTnt", this.getLevel().getChunk(this.getFloorX() >> 4, this.getFloorZ() >> 4), nbt, source ); if(tnt == null) { return; } tnt.spawnToAll(); this.level.addSound(this, Sound.RANDOM_FUSE); }
Example #12
Source File: BlockGrass.java From Nukkit with GNU General Public License v3.0 | 6 votes |
@Override public boolean onActivate(Item item, Player player) { if (item.getId() == Item.DYE && item.getDamage() == 0x0F) { item.count--; ObjectTallGrass.growGrass(this.getLevel(), this, new NukkitRandom(), 15, 10); return true; } else if (item.isHoe()) { item.useOn(this); this.getLevel().setBlock(this, new BlockFarmland()); return true; } else if (item.isShovel()) { item.useOn(this); this.getLevel().setBlock(this, new BlockGrassPath()); return true; } return false; }
Example #13
Source File: PopulatorCaves.java From Nukkit with GNU General Public License v3.0 | 6 votes |
@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 #14
Source File: BlockTNT.java From Jupiter with GNU General Public License v3.0 | 6 votes |
public void prime(int fuse) { this.getLevel().setBlock(this, new BlockAir(), true); double mot = (new NukkitRandom()).nextSignedFloat() * Math.PI * 2; CompoundTag nbt = new CompoundTag() .putList(new ListTag<DoubleTag>("Pos") .add(new DoubleTag("", this.x + 0.5)) .add(new DoubleTag("", this.y)) .add(new DoubleTag("", this.z + 0.5))) .putList(new ListTag<DoubleTag>("Motion") .add(new DoubleTag("", -Math.sin(mot) * 0.02)) .add(new DoubleTag("", 0.2)) .add(new DoubleTag("", -Math.cos(mot) * 0.02))) .putList(new ListTag<FloatTag>("Rotation") .add(new FloatTag("", 0)) .add(new FloatTag("", 0))) .putByte("Fuse", fuse); Entity tnt = new EntityPrimedTNT( this.getLevel().getChunk(this.getFloorX() >> 4, this.getFloorZ() >> 4), nbt ); tnt.spawnToAll(); this.level.addSound(new TNTPrimeSound(this)); }
Example #15
Source File: JungleTreePopulator.java From Jupiter with GNU General Public License v3.0 | 6 votes |
@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 #16
Source File: PopulatorFlower.java From Nukkit with GNU General Public License v3.0 | 6 votes |
@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 #17
Source File: Simplex.java From Nukkit with GNU General Public License v3.0 | 6 votes |
public Simplex(NukkitRandom random, double octaves, double persistence, double expansion) { super(random, octaves, persistence, expansion); this.offsetW = random.nextDouble() * 256; SQRT_3 = Math.sqrt(3); SQRT_5 = Math.sqrt(5); F2 = 0.5 * (SQRT_3 - 1); G2 = (3 - SQRT_3) / 6; G22 = G2 * 2.0 - 1; F3 = 1.0 / 3.0; G3 = 1.0 / 6.0; F4 = (SQRT_5 - 1.0) / 4.0; G4 = (5.0 - SQRT_5) / 20.0; G42 = G4 * 2.0; G43 = G4 * 3.0; G44 = G4 * 4.0 - 1.0; }
Example #18
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 #19
Source File: PopulatorCaves.java From Nukkit with GNU General Public License v3.0 | 6 votes |
@Override public void populate(ChunkManager level, int chunkX, int chunkZ, NukkitRandom random, FullChunk chunk) { 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, chunk); } }
Example #20
Source File: ObjectTallGrass.java From Nukkit with GNU General Public License v3.0 | 6 votes |
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 #21
Source File: PopulatorLava.java From Nukkit with GNU General Public License v3.0 | 6 votes |
@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 #22
Source File: MushroomPopulator.java From Jupiter with GNU General Public License v3.0 | 6 votes |
@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 #23
Source File: PopulatorGroundFire.java From Jupiter with GNU General Public License v3.0 | 6 votes |
@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 #24
Source File: ObjectTallGrass.java From Jupiter with GNU General Public License v3.0 | 6 votes |
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 #25
Source File: JungleBigTreePopulator.java From Nukkit with GNU General Public License v3.0 | 6 votes |
@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 ObjectJungleBigTree(10, 20, Block.get(BlockID.WOOD, BlockWood.JUNGLE), Block.get(BlockID.LEAVES, BlockLeaves.JUNGLE)).generate(this.level, random, v.setComponents(x, y, z)); } }
Example #26
Source File: ObjectTree.java From Nukkit with GNU General Public License v3.0 | 6 votes |
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 #27
Source File: SavannaTreePopulator.java From Jupiter with GNU General Public License v3.0 | 6 votes |
@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 ObjectSavannaTree().generate(level, random, v.setComponents(x, y, z)); } }
Example #28
Source File: BlockStemPumpkin.java From Nukkit with GNU General Public License v3.0 | 5 votes |
@Override public Item[] getDrops(Item item) { NukkitRandom random = new NukkitRandom(); return new Item[]{ new ItemSeedsPumpkin(0, random.nextRange(0, 3)) }; }
Example #29
Source File: PopulatorDeadBush.java From Nukkit with GNU General Public License v3.0 | 5 votes |
@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.canDeadBushStay(x, y, z)) { this.level.setBlockIdAt(x, y, z, Block.DEAD_BUSH); this.level.setBlockDataAt(x, y, z, 1); } } }
Example #30
Source File: ObjectTallGrass.java From Nukkit with GNU General Public License v3.0 | 5 votes |
public static void growGrass(ChunkManager level, Vector3 pos, NukkitRandom random) { for (int i = 0; i < 128; ++i) { int num = 0; int x = pos.getFloorX(); int y = pos.getFloorY() + 1; int z = pos.getFloorZ(); while (true) { if (num >= i / 16) { if (level.getBlockIdAt(x, y, z) == Block.AIR) { if (random.nextBoundedInt(8) == 0) { //porktodo: biomes have specific flower types that can grow in them if (random.nextBoolean()) { level.setBlockAt(x, y, z, Block.DANDELION); } else { level.setBlockAt(x, y, z, Block.POPPY); } } else { level.setBlockAt(x, y, z, Block.TALL_GRASS, 1); } } break; } x += random.nextRange(-1, 1); y += random.nextRange(-1, 1) * random.nextBoundedInt(3) / 2; z += random.nextRange(-1, 1); if (level.getBlockIdAt(x, y - 1, z) != Block.GRASS || y > 255 || y < 0) { break; } ++num; } } }