From 95c9ccefac25a558a6e4680d7bbc0e6ba4b88593 Mon Sep 17 00:00:00 2001 From: Matt Caughey Date: Sun, 27 Oct 2013 22:26:50 -0400 Subject: [PATCH] Added honey generation to the hives (Using water for now) --- .../biomesoplenty/worldgen/WorldGenHive.java | 35 +++++++++++++++---- 1 file changed, 29 insertions(+), 6 deletions(-) diff --git a/common/biomesoplenty/worldgen/WorldGenHive.java b/common/biomesoplenty/worldgen/WorldGenHive.java index a15e0a9dd..0a30b13c3 100644 --- a/common/biomesoplenty/worldgen/WorldGenHive.java +++ b/common/biomesoplenty/worldgen/WorldGenHive.java @@ -41,11 +41,13 @@ public class WorldGenHive extends WorldGenerator break; } + int honeychance = rand.nextInt(2); + //Top generateHiveCubeSmall(world, x, y + cubeno, z, (baseHeight - 8) + (cubeno * 2), (baseWidth - 1) + cubeno, cubeno, chance); //Middle - generateHiveCube(world, x, (y - 2) + cubeno, z, baseHeight + (cubeno * 2), baseWidth + cubeno, cubeno, chance); + generateHiveCube(world, x, (y - 2) + cubeno, z, baseHeight + (cubeno * 2), baseWidth + cubeno, cubeno, chance, honeychance); //Bottom generateHiveCubeSmall(world, x, (y - (baseHeight + 4)) + cubeno, z, (baseHeight - 8) + (cubeno * 2), (baseWidth - 1) + cubeno, cubeno, chance); @@ -56,13 +58,20 @@ public class WorldGenHive extends WorldGenerator //Bottom 3 generateHiveCubeSmall(world, x, (y - (baseHeight + 7)) + cubeno, z, (baseHeight - 7) + (cubeno * 2), (baseWidth - 4) + cubeno, cubeno, chance); - spawnWasps(world, rand, x, y, z); + if (honeychance != 0) + { + spawnWasps(world, rand, x, y, z, 15); + } + else + { + spawnWasps(world, rand, x, y, z, 7); + } } return true; } - public void generateHiveCube(World world, int origx, int origy, int origz, int height, int width, int cubeno, float chance) + public void generateHiveCube(World world, int origx, int origy, int origz, int height, int width, int cubeno, float chance, int honeychance) { for (int hLayer = 0; hLayer < height; hLayer++) { @@ -73,7 +82,21 @@ public class WorldGenHive extends WorldGenerator if ((hLayer == 0 || hLayer == (height - 1)) && (world.rand.nextFloat() <= chance)) world.setBlock(origx + i, origy - hLayer, origz + j, Blocks.hive.get().blockID); else if ((i == -width || i == (width - 1) || j == -width || j == (width - 1)) && (world.rand.nextFloat() <= chance)) world.setBlock(origx + i, origy - hLayer, origz + j, Blocks.hive.get().blockID); - if (cubeno < 2 && world.getBlockId(origx + i, origy - hLayer, origz + j) != Blocks.hive.get().blockID) world.setBlockToAir(origx + i, origy - hLayer, origz + j); + if (honeychance == 0) + { + if (hLayer > (height / 2)) + { + if (cubeno < 2 && world.getBlockId(origx + i, origy - hLayer, origz + j) != Blocks.hive.get().blockID) world.setBlock(origx + i, origy - hLayer, origz + j, Block.waterMoving.blockID); + } + else + { + if (cubeno < 2 && world.getBlockId(origx + i, origy - hLayer, origz + j) != Blocks.hive.get().blockID) world.setBlockToAir(origx + i, origy - hLayer, origz + j); + } + } + else + { + if (cubeno < 2 && world.getBlockId(origx + i, origy - hLayer, origz + j) != Blocks.hive.get().blockID) world.setBlockToAir(origx + i, origy - hLayer, origz + j); + } } } } @@ -94,9 +117,9 @@ public class WorldGenHive extends WorldGenerator } } - public void spawnWasps(World world, Random rand, int x, int y, int z) + public void spawnWasps(World world, Random rand, int x, int y, int z, int amount) { - for (int spawn = 0; spawn < 15; spawn++) + for (int spawn = 0; spawn < amount; spawn++) { int spawnx = (x - 4) + rand.nextInt(8); int spawny = (y - 6) - rand.nextInt(4);