From 398cfdc310b4043363f3550696162aa23485147c Mon Sep 17 00:00:00 2001 From: Matt Caughey Date: Sun, 27 Oct 2013 14:21:13 -0400 Subject: [PATCH] Added "The Hive" biome to the Nether --- common/biomesoplenty/api/Biomes.java | 1 + .../biomes/nether/BiomeGenNetherHive.java | 49 ++++++++++++ .../configuration/BOPBiomes.java | 7 +- .../configfile/BOPConfigurationBiomeGen.java | 2 + .../configfile/BOPConfigurationIDs.java | 2 + common/biomesoplenty/items/ItemDart.java | 55 -------------- .../world/WorldProviderBOPhell.java | 2 +- .../world/layer/BiomeLayerBiomes.java | 7 ++ .../biomesoplenty/worldgen/WorldGenHive.java | 74 +++++++++++++++++++ 9 files changed, 141 insertions(+), 58 deletions(-) create mode 100644 common/biomesoplenty/biomes/nether/BiomeGenNetherHive.java create mode 100644 common/biomesoplenty/worldgen/WorldGenHive.java diff --git a/common/biomesoplenty/api/Biomes.java b/common/biomesoplenty/api/Biomes.java index 90dcf5a29..aa6f4bdfb 100644 --- a/common/biomesoplenty/api/Biomes.java +++ b/common/biomesoplenty/api/Biomes.java @@ -70,6 +70,7 @@ public class Biomes public static Optional netherLava = Optional.absent(); public static Optional netherBone = Optional.absent(); public static Optional netherBlood = Optional.absent(); + public static Optional netherHive = Optional.absent(); public static Optional oasis = Optional.absent(); diff --git a/common/biomesoplenty/biomes/nether/BiomeGenNetherHive.java b/common/biomesoplenty/biomes/nether/BiomeGenNetherHive.java new file mode 100644 index 000000000..f72217a01 --- /dev/null +++ b/common/biomesoplenty/biomes/nether/BiomeGenNetherHive.java @@ -0,0 +1,49 @@ +package biomesoplenty.biomes.nether; + +import java.util.Random; + +import net.minecraft.block.Block; +import net.minecraft.entity.monster.EntityGhast; +import net.minecraft.entity.monster.EntityMagmaCube; +import net.minecraft.entity.monster.EntityPigZombie; +import net.minecraft.world.World; +import net.minecraft.world.biome.BiomeGenBase; +import net.minecraft.world.biome.SpawnListEntry; +import biomesoplenty.api.Blocks; +import biomesoplenty.biomes.BiomeDecoratorBOP; +import biomesoplenty.worldgen.WorldGenHive; + +public class BiomeGenNetherHive extends BiomeGenBase +{ + private BiomeDecoratorBOP customBiomeDecorator; + + public BiomeGenNetherHive(int par1) + { + super(par1); + theBiomeDecorator = new BiomeDecoratorBOP(this); + customBiomeDecorator = (BiomeDecoratorBOP)theBiomeDecorator; + topBlock = (byte)Block.netherrack.blockID; + fillerBlock = (byte)Block.netherrack.blockID; + spawnableMonsterList.clear(); + spawnableCreatureList.clear(); + spawnableWaterCreatureList.clear(); + spawnableCaveCreatureList.clear(); + 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)); + } + + @Override + public void decorate(World par1World, Random par2Random, int par3, int par4) + { + super.decorate(par1World, par2Random, par3, par4); + + if (par2Random.nextInt(10) == 0) + { + int var5 = par3 + par2Random.nextInt(16) + 8; + int var6 = par4 + par2Random.nextInt(16) + 8; + WorldGenHive var7 = new WorldGenHive(); + var7.generate(par1World, par2Random, var5, par1World.getHeightValue(var5, var6) - 1, var6); + } + } +} diff --git a/common/biomesoplenty/configuration/BOPBiomes.java b/common/biomesoplenty/configuration/BOPBiomes.java index bfc067663..7254b5ad4 100644 --- a/common/biomesoplenty/configuration/BOPBiomes.java +++ b/common/biomesoplenty/configuration/BOPBiomes.java @@ -108,6 +108,7 @@ import biomesoplenty.biomes.nether.BiomeGenNetherBlood; import biomesoplenty.biomes.nether.BiomeGenNetherBone; import biomesoplenty.biomes.nether.BiomeGenNetherDesert; import biomesoplenty.biomes.nether.BiomeGenNetherGarden; +import biomesoplenty.biomes.nether.BiomeGenNetherHive; import biomesoplenty.biomes.nether.BiomeGenNetherLava; import biomesoplenty.biomes.ocean.BiomeGenOceanAbyss; import biomesoplenty.biomes.ocean.BiomeGenOceanCoral; @@ -241,6 +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.oasis = Optional.of((new BiomeGenOasis(BOPConfigurationIDs.oasisID)).setColor(16421912).setBiomeName("Oasis").setTemperatureRainfall(0.9F, 0.7F).setMinMaxHeight(0.3F, 0.4F)); @@ -378,11 +380,12 @@ public class BOPBiomes { BiomeDictionary.registerBiomeType(Biomes.mysticGrove.get(), Type.MAGICAL, Type.FOREST); BiomeDictionary.registerBiomeType(Biomes.netherBase.get(), Type.NETHER); - BiomeDictionary.registerBiomeType(Biomes.netherGarden.get(), Type.NETHER, Type.FOREST); + BiomeDictionary.registerBiomeType(Biomes.netherGarden.get(), Type.NETHER, Type.JUNGLE); BiomeDictionary.registerBiomeType(Biomes.netherDesert.get(), Type.NETHER, Type.DESERT); BiomeDictionary.registerBiomeType(Biomes.netherLava.get(), Type.NETHER); BiomeDictionary.registerBiomeType(Biomes.netherBone.get(), Type.NETHER, Type.WASTELAND); - BiomeDictionary.registerBiomeType(Biomes.netherBone.get(), Type.NETHER); + BiomeDictionary.registerBiomeType(Biomes.netherBlood.get(), Type.NETHER); + BiomeDictionary.registerBiomeType(Biomes.netherHive.get(), Type.NETHER); BiomeDictionary.registerBiomeType(Biomes.oasis.get(), Type.DESERT, Type.JUNGLE); diff --git a/common/biomesoplenty/configuration/configfile/BOPConfigurationBiomeGen.java b/common/biomesoplenty/configuration/configfile/BOPConfigurationBiomeGen.java index dc51b41df..360cab424 100644 --- a/common/biomesoplenty/configuration/configfile/BOPConfigurationBiomeGen.java +++ b/common/biomesoplenty/configuration/configfile/BOPConfigurationBiomeGen.java @@ -107,6 +107,7 @@ public class BOPConfigurationBiomeGen public static boolean phantasmagoricInfernoGen; public static boolean boneyardGen; public static boolean bloodyHeapGen; + public static boolean theHiveGen; // Beach variations public static boolean gravelBeachGen; @@ -222,6 +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); // 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 2410f8b64..a98a16ccd 100644 --- a/common/biomesoplenty/configuration/configfile/BOPConfigurationIDs.java +++ b/common/biomesoplenty/configuration/configfile/BOPConfigurationIDs.java @@ -219,6 +219,7 @@ public class BOPConfigurationIDs public static int netherLavaID; public static int netherBoneID; public static int netherBloodID; + public static int netherHiveID; public static int oasisID; @@ -480,6 +481,7 @@ public class BOPConfigurationIDs //23-79 ExtraBiomesXL + netherHiveID = config.get("Biome IDs", "The 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/items/ItemDart.java b/common/biomesoplenty/items/ItemDart.java index 7d746a37f..63d1ab3a6 100644 --- a/common/biomesoplenty/items/ItemDart.java +++ b/common/biomesoplenty/items/ItemDart.java @@ -28,61 +28,6 @@ public class ItemDart extends Item setHasSubtypes(true); setCreativeTab(BiomesOPlenty.tabBiomesOPlenty); } - - @Override - public ItemStack onItemRightClick(ItemStack itemstack, World world, EntityPlayer player) - { - MovingObjectPosition pos = this.getMovingObjectPositionFromPlayer(world, player, true); - if (pos == null) return itemstack; - - int x = pos.blockX; - int y = pos.blockY; - int z = pos.blockZ; - - int baseWidth = 2 + world.rand.nextInt(2); - int baseHeight = 7 + world.rand.nextInt(2); - - for (int cubeno = 0; cubeno < 3; cubeno++) - { - float chance = 0.0F; - - switch (cubeno) - { - case 0: - chance = 0.25F; - break; - - case 1: - chance = 1.0F; - break; - - case 2: - chance = 0.25F; - break; - } - - generateHiveCube(world, x, y + cubeno, z, baseHeight + (cubeno * 2), baseWidth + cubeno, cubeno, chance); - } - - return itemstack; - } - - public void generateHiveCube(World world, int origx, int origy, int origz, int height, int width, int cubeno, float chance) - { - for (int hLayer = 0; hLayer < height; hLayer++) - { - for (int i = -width; i < width; i++) - { - for (int j = -width; j < width; j++) - { - 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); - } - } - } - } @SuppressWarnings({ "rawtypes", "unchecked" }) @Override diff --git a/common/biomesoplenty/world/WorldProviderBOPhell.java b/common/biomesoplenty/world/WorldProviderBOPhell.java index fbea88e6f..49716ac7a 100644 --- a/common/biomesoplenty/world/WorldProviderBOPhell.java +++ b/common/biomesoplenty/world/WorldProviderBOPhell.java @@ -10,7 +10,7 @@ public class WorldProviderBOPhell extends WorldProviderHell @Override public void registerWorldChunkManager() { - if (Biomes.netherGarden.isPresent() || Biomes.netherDesert.isPresent() || Biomes.netherLava.isPresent() || Biomes.netherBone.isPresent() || Biomes.netherBlood.isPresent()) + if (Biomes.netherGarden.isPresent() || Biomes.netherDesert.isPresent() || Biomes.netherLava.isPresent() || Biomes.netherBone.isPresent() || Biomes.netherBlood.isPresent() || Biomes.netherHive.isPresent()) { this.worldChunkMgr = new WorldChunkManagerBOPhell(worldObj); } diff --git a/common/biomesoplenty/world/layer/BiomeLayerBiomes.java b/common/biomesoplenty/world/layer/BiomeLayerBiomes.java index efac359fd..3c4017f3c 100644 --- a/common/biomesoplenty/world/layer/BiomeLayerBiomes.java +++ b/common/biomesoplenty/world/layer/BiomeLayerBiomes.java @@ -90,6 +90,13 @@ public class BiomeLayerBiomes extends BiomeLayer netherBiomes.add(Biomes.netherBlood.get()); } } + if (Biomes.netherHive.isPresent()) + { + if (BOPConfigurationBiomeGen.theHiveGen) + { + netherBiomes.add(Biomes.netherHive.get()); + } + } if (Biomes.netherBiomes.size() > 0) { netherBiomes.addAll(Biomes.netherBiomes); diff --git a/common/biomesoplenty/worldgen/WorldGenHive.java b/common/biomesoplenty/worldgen/WorldGenHive.java new file mode 100644 index 000000000..c53fd4329 --- /dev/null +++ b/common/biomesoplenty/worldgen/WorldGenHive.java @@ -0,0 +1,74 @@ +package biomesoplenty.worldgen; + +import java.util.Random; + +import net.minecraft.block.Block; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.util.MovingObjectPosition; +import net.minecraft.world.World; +import net.minecraft.world.gen.feature.WorldGenerator; +import biomesoplenty.api.Blocks; + +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.getBlockMetadata(var3, var4, var5) != 0) + { + return false; + } + } + + int x = var3; + int y = var4; + int z = var5; + + int baseWidth = 2 + var1.rand.nextInt(2); + int baseHeight = 7 + var1.rand.nextInt(2); + + for (int cubeno = 0; cubeno < 3; cubeno++) + { + float chance = 0.0F; + + switch (cubeno) + { + case 0: + chance = 0.25F; + break; + + case 1: + chance = 1.0F; + break; + + case 2: + chance = 0.25F; + break; + } + + generateHiveCube(var1, x, y + cubeno, z, baseHeight + (cubeno * 2), baseWidth + cubeno, cubeno, chance); + } + + return true; + } + + public void generateHiveCube(World world, int origx, int origy, int origz, int height, int width, int cubeno, float chance) + { + for (int hLayer = 0; hLayer < height; hLayer++) + { + for (int i = -width; i < width; i++) + { + for (int j = -width; j < width; j++) + { + 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); + } + } + } + } +}