From ddbf1c70174b363498f735b4489373b8fc4c9f98 Mon Sep 17 00:00:00 2001 From: Matt Caughey Date: Sun, 27 Oct 2013 14:54:35 -0400 Subject: [PATCH] Fixed up hive generation --- .../biomes/BiomeDecoratorBOP.java | 10 +++ .../biomes/nether/BiomeGenNetherHive.java | 6 +- .../configuration/BOPBiomes.java | 2 +- .../configfile/BOPConfigurationBiomeGen.java | 4 +- .../configfile/BOPConfigurationIDs.java | 2 +- .../world/layer/BiomeLayerBiomes.java | 2 +- .../biomesoplenty/worldgen/WorldGenHive.java | 14 ++-- .../worldgen/WorldGenNetherHive.java | 79 +++++++++++++++++++ 8 files changed, 105 insertions(+), 14 deletions(-) create mode 100644 common/biomesoplenty/worldgen/WorldGenNetherHive.java diff --git a/common/biomesoplenty/biomes/BiomeDecoratorBOP.java b/common/biomesoplenty/biomes/BiomeDecoratorBOP.java index 6ea6b7634..82700beca 100644 --- a/common/biomesoplenty/biomes/BiomeDecoratorBOP.java +++ b/common/biomesoplenty/biomes/BiomeDecoratorBOP.java @@ -80,6 +80,7 @@ import biomesoplenty.worldgen.WorldGenMesa; import biomesoplenty.worldgen.WorldGenMud; import biomesoplenty.worldgen.WorldGenMycelium; import biomesoplenty.worldgen.WorldGenNetherGrass; +import biomesoplenty.worldgen.WorldGenNetherHive; import biomesoplenty.worldgen.WorldGenNetherLava; import biomesoplenty.worldgen.WorldGenNetherVines; import biomesoplenty.worldgen.WorldGenNetherWart; @@ -150,6 +151,7 @@ public class BiomeDecoratorBOP extends BiomeDecorator public WorldGenerator clayInStone2Gen; public WorldGenerator quagmireGen; public WorldGenerator quicksandGen; + public WorldGenerator hiveGen; public WorldGenerator spongeGen; public WorldGenerator canyonGen; public WorldGenerator cloudGen; @@ -429,6 +431,7 @@ public class BiomeDecoratorBOP extends BiomeDecorator public boolean generateClouds; public boolean generateQuicksand; public boolean generateSponge; + public boolean generateHive; public BiomeDecoratorBOP(BiomeGenBase par1BiomeGenBase) { @@ -453,6 +456,7 @@ public class BiomeDecoratorBOP extends BiomeDecorator clayInStoneGen = new WorldGenBadlands3(Block.stainedClay.blockID, 32); clayInStone2Gen = new WorldGenBadlands(Block.stainedClay.blockID, 32); quagmireGen = new WorldGenQuagmire(Block.grass.blockID, 48); + hiveGen = new WorldGenNetherHive(Blocks.hive.get().blockID, 48); quicksandGen = new WorldGenQuicksand(Blocks.mud.get().blockID, 24); spongeGen = new WorldGenSponge(Block.sponge.blockID, 24); canyonGen = new WorldGenCanyon(Blocks.redRock.get().blockID, 48); @@ -657,6 +661,7 @@ public class BiomeDecoratorBOP extends BiomeDecorator generateClouds = false; generateQuicksand = false; generateSponge = false; + generateHive = false; biome = par1BiomeGenBase; } @@ -849,6 +854,11 @@ public class BiomeDecoratorBOP extends BiomeDecorator { this.genStandardOre1(15, quagmireGen, 64, 128); } + + if (generateHive) + { + this.genStandardOre1(5, hiveGen, 0, 128); + } if (generateCanyon) { diff --git a/common/biomesoplenty/biomes/nether/BiomeGenNetherHive.java b/common/biomesoplenty/biomes/nether/BiomeGenNetherHive.java index f72217a01..df3235929 100644 --- a/common/biomesoplenty/biomes/nether/BiomeGenNetherHive.java +++ b/common/biomesoplenty/biomes/nether/BiomeGenNetherHive.java @@ -28,6 +28,7 @@ public class BiomeGenNetherHive extends BiomeGenBase spawnableCreatureList.clear(); spawnableWaterCreatureList.clear(); spawnableCaveCreatureList.clear(); + customBiomeDecorator.generateHive = true; spawnableMonsterList.add(new SpawnListEntry(EntityGhast.class, 50, 4, 4)); spawnableMonsterList.add(new SpawnListEntry(EntityPigZombie.class, 100, 4, 4)); spawnableMonsterList.add(new SpawnListEntry(EntityMagmaCube.class, 1, 4, 4)); @@ -38,12 +39,13 @@ public class BiomeGenNetherHive extends BiomeGenBase { super.decorate(par1World, par2Random, par3, par4); - if (par2Random.nextInt(10) == 0) + if (par2Random.nextInt(2) == 0) { int var5 = par3 + par2Random.nextInt(16) + 8; + int var99 = par2Random.nextInt(128); int var6 = par4 + par2Random.nextInt(16) + 8; WorldGenHive var7 = new WorldGenHive(); - var7.generate(par1World, par2Random, var5, par1World.getHeightValue(var5, var6) - 1, var6); + var7.generate(par1World, par2Random, var5, var99, var6); } } } diff --git a/common/biomesoplenty/configuration/BOPBiomes.java b/common/biomesoplenty/configuration/BOPBiomes.java index 7254b5ad4..c19044421 100644 --- a/common/biomesoplenty/configuration/BOPBiomes.java +++ b/common/biomesoplenty/configuration/BOPBiomes.java @@ -242,7 +242,7 @@ public class BOPBiomes { Biomes.netherLava = Optional.of((new BiomeGenNetherLava(BOPConfigurationIDs.netherLavaID)).setColor(16711680).setBiomeName("Phantasmagoric Inferno").setDisableRain().setTemperatureRainfall(2.0F, 0.0F)); Biomes.netherBone = Optional.of((new BiomeGenNetherBone(BOPConfigurationIDs.netherBoneID)).setColor(16711680).setBiomeName("Boneyard").setDisableRain().setTemperatureRainfall(2.0F, 0.0F)); Biomes.netherBlood = Optional.of((new BiomeGenNetherBlood(BOPConfigurationIDs.netherBloodID)).setColor(16711680).setBiomeName("Bloody Heap").setDisableRain().setTemperatureRainfall(2.0F, 0.0F)); - Biomes.netherHive = Optional.of((new BiomeGenNetherHive(BOPConfigurationIDs.netherHiveID)).setColor(16711680).setBiomeName("The Hive").setDisableRain().setTemperatureRainfall(2.0F, 0.0F)); + Biomes.netherHive = Optional.of((new BiomeGenNetherHive(BOPConfigurationIDs.netherHiveID)).setColor(16711680).setBiomeName("Hellish Hive").setDisableRain().setTemperatureRainfall(2.0F, 0.0F)); Biomes.oasis = Optional.of((new BiomeGenOasis(BOPConfigurationIDs.oasisID)).setColor(16421912).setBiomeName("Oasis").setTemperatureRainfall(0.9F, 0.7F).setMinMaxHeight(0.3F, 0.4F)); diff --git a/common/biomesoplenty/configuration/configfile/BOPConfigurationBiomeGen.java b/common/biomesoplenty/configuration/configfile/BOPConfigurationBiomeGen.java index 360cab424..7e327bc34 100644 --- a/common/biomesoplenty/configuration/configfile/BOPConfigurationBiomeGen.java +++ b/common/biomesoplenty/configuration/configfile/BOPConfigurationBiomeGen.java @@ -107,7 +107,7 @@ public class BOPConfigurationBiomeGen public static boolean phantasmagoricInfernoGen; public static boolean boneyardGen; public static boolean bloodyHeapGen; - public static boolean theHiveGen; + public static boolean hellishHiveGen; // Beach variations public static boolean gravelBeachGen; @@ -223,7 +223,7 @@ public class BOPConfigurationBiomeGen phantasmagoricInfernoGen = config.get("Nether Biomes To Generate", "PhantasmagoricInferno", true).getBoolean(true); boneyardGen = config.get("Nether Biomes To Generate", "Boneyard", true).getBoolean(true); bloodyHeapGen = config.get("Nether Biomes To Generate", "BloodyHeap", true).getBoolean(true); - theHiveGen = config.get("Nether Biomes To Generate", "TheHive", true).getBoolean(true); + hellishHiveGen = config.get("Nether Biomes To Generate", "HellishHive", true).getBoolean(true); // Beach variations gravelBeachGen = config.get("Beach Variations To Generate", "Gravel Beach", true).getBoolean(true); diff --git a/common/biomesoplenty/configuration/configfile/BOPConfigurationIDs.java b/common/biomesoplenty/configuration/configfile/BOPConfigurationIDs.java index a98a16ccd..3c785e019 100644 --- a/common/biomesoplenty/configuration/configfile/BOPConfigurationIDs.java +++ b/common/biomesoplenty/configuration/configfile/BOPConfigurationIDs.java @@ -481,7 +481,7 @@ public class BOPConfigurationIDs //23-79 ExtraBiomesXL - netherHiveID = config.get("Biome IDs", "The Hive (Nether) ID", 29).getInt(); + netherHiveID = config.get("Biome IDs", "Hellish Hive (Nether) ID", 29).getInt(); netherBloodID = config.get("Biome IDs", "Bloody Heap (Nether) ID", 30).getInt(); lavenderFieldsID = config.get("Biome IDs", "Lavender Fields ID", 31).getInt(); diff --git a/common/biomesoplenty/world/layer/BiomeLayerBiomes.java b/common/biomesoplenty/world/layer/BiomeLayerBiomes.java index 3c4017f3c..f4a66efbf 100644 --- a/common/biomesoplenty/world/layer/BiomeLayerBiomes.java +++ b/common/biomesoplenty/world/layer/BiomeLayerBiomes.java @@ -92,7 +92,7 @@ public class BiomeLayerBiomes extends BiomeLayer } if (Biomes.netherHive.isPresent()) { - if (BOPConfigurationBiomeGen.theHiveGen) + if (BOPConfigurationBiomeGen.hellishHiveGen) { netherBiomes.add(Biomes.netherHive.get()); } diff --git a/common/biomesoplenty/worldgen/WorldGenHive.java b/common/biomesoplenty/worldgen/WorldGenHive.java index c53fd4329..2da35f36a 100644 --- a/common/biomesoplenty/worldgen/WorldGenHive.java +++ b/common/biomesoplenty/worldgen/WorldGenHive.java @@ -15,20 +15,20 @@ public class WorldGenHive extends WorldGenerator @Override public boolean generate(World var1, Random var2, int var3, int var4, int var5) { - if (var1.getBlockId(var3, var4 + 1, var5) != Block.netherrack.blockID) + if (var1.getBlockId(var3, var4, var5) != Block.netherrack.blockID) { - if (var1.getBlockMetadata(var3, var4, var5) != 0) + if (!var1.isAirBlock(var3, var4 - 1, var5)) { return false; } } int x = var3; - int y = var4; + int y = var4 + 6; int z = var5; - int baseWidth = 2 + var1.rand.nextInt(2); - int baseHeight = 7 + var1.rand.nextInt(2); + int baseWidth = 3 + var1.rand.nextInt(2); + int baseHeight = 8 + var1.rand.nextInt(2); for (int cubeno = 0; cubeno < 3; cubeno++) { @@ -37,7 +37,7 @@ public class WorldGenHive extends WorldGenerator switch (cubeno) { case 0: - chance = 0.25F; + chance = 0.5F; break; case 1: @@ -45,7 +45,7 @@ public class WorldGenHive extends WorldGenerator break; case 2: - chance = 0.25F; + chance = 0.5F; break; } diff --git a/common/biomesoplenty/worldgen/WorldGenNetherHive.java b/common/biomesoplenty/worldgen/WorldGenNetherHive.java new file mode 100644 index 000000000..0affc8721 --- /dev/null +++ b/common/biomesoplenty/worldgen/WorldGenNetherHive.java @@ -0,0 +1,79 @@ +package biomesoplenty.worldgen; + +import java.util.Random; + +import net.minecraft.block.Block; +import net.minecraft.util.MathHelper; +import net.minecraft.world.World; +import net.minecraft.world.gen.feature.WorldGenerator; + +public class WorldGenNetherHive extends WorldGenerator +{ + /** The block ID of the ore to be placed using this generator. */ + private int minableBlockId; + + /** The number of blocks to generate. */ + private int numberOfBlocks; + + public WorldGenNetherHive(int par1, int par2) + { + minableBlockId = par1; + numberOfBlocks = par2; + } + + @Override + public boolean generate(World par1World, Random par2Random, int par3, int par4, int par5) + { + float var6 = par2Random.nextFloat() * (float)Math.PI; + double var7 = par3 + 8 + MathHelper.sin(var6) * numberOfBlocks / 8.0F; + double var9 = par3 + 8 - MathHelper.sin(var6) * numberOfBlocks / 8.0F; + double var11 = par5 + 8 + MathHelper.cos(var6) * numberOfBlocks / 8.0F; + double var13 = par5 + 8 - MathHelper.cos(var6) * numberOfBlocks / 8.0F; + double var15 = par4 + par2Random.nextInt(3) - 2; + double var17 = par4 + par2Random.nextInt(3) - 2; + + for (int var19 = 0; var19 <= numberOfBlocks; ++var19) + { + double var20 = var7 + (var9 - var7) * var19 / numberOfBlocks; + double var22 = var15 + (var17 - var15) * var19 / numberOfBlocks; + double var24 = var11 + (var13 - var11) * var19 / numberOfBlocks; + double var26 = par2Random.nextDouble() * numberOfBlocks / 16.0D; + double var28 = (MathHelper.sin(var19 * (float)Math.PI / numberOfBlocks) + 1.0F) * var26 + 1.0D; + double var30 = (MathHelper.sin(var19 * (float)Math.PI / numberOfBlocks) + 1.0F) * var26 + 1.0D; + int var32 = MathHelper.floor_double(var20 - var28 / 2.0D); + int var33 = MathHelper.floor_double(var22 - var30 / 2.0D); + int var34 = MathHelper.floor_double(var24 - var28 / 2.0D); + int var35 = MathHelper.floor_double(var20 + var28 / 2.0D); + int var36 = MathHelper.floor_double(var22 + var30 / 2.0D); + int var37 = MathHelper.floor_double(var24 + var28 / 2.0D); + + for (int var38 = var32; var38 <= var35; ++var38) + { + double var39 = (var38 + 0.5D - var20) / (var28 / 2.0D); + + if (var39 * var39 < 1.0D) + { + for (int var41 = var33; var41 <= var36; ++var41) + { + double var42 = (var41 + 0.5D - var22) / (var30 / 2.0D); + + if (var39 * var39 + var42 * var42 < 1.0D) + { + for (int var44 = var34; var44 <= var37; ++var44) + { + double var45 = (var44 + 0.5D - var24) / (var28 / 2.0D); + + if (var39 * var39 + var42 * var42 + var45 * var45 < 1.0D && par1World.getBlockId(var38, var41, var44) == Block.netherrack.blockID) + { + par1World.setBlock(var38, var41, var44, minableBlockId); + } + } + } + } + } + } + } + + return true; + } +}