From 325ac1eb0c034257f68f399efd451ef8c7f01f97 Mon Sep 17 00:00:00 2001 From: Amnet Date: Sun, 28 Apr 2013 13:54:04 +0200 Subject: [PATCH] Added Witch Huts, Jungle and Desert Temples to some of the biomes in BOP World Type. --- .../biomes/BiomeGenDesertNew.java | 2 +- .../configuration/BOPConfiguration.java | 2 +- .../structure/BOPMapGenScatteredFeature.java | 116 ++++++++++++++++++ .../worldgen/structure/BOPMapGenVillage.java | 26 ++-- .../BOPStructureScatteredFeatureStart.java | 43 +++++++ .../worldtype/ChunkProviderBOP.java | 7 +- 6 files changed, 177 insertions(+), 19 deletions(-) create mode 100644 src/minecraft/biomesoplenty/worldgen/structure/BOPMapGenScatteredFeature.java create mode 100644 src/minecraft/biomesoplenty/worldgen/structure/BOPStructureScatteredFeatureStart.java diff --git a/src/minecraft/biomesoplenty/biomes/BiomeGenDesertNew.java b/src/minecraft/biomesoplenty/biomes/BiomeGenDesertNew.java index 0e388a002..b6d38f5b9 100644 --- a/src/minecraft/biomesoplenty/biomes/BiomeGenDesertNew.java +++ b/src/minecraft/biomesoplenty/biomes/BiomeGenDesertNew.java @@ -25,7 +25,7 @@ public class BiomeGenDesertNew extends BiomeGenBase this.customBiomeDecorator.cactiPerChunk = 10; this.customBiomeDecorator.desertSproutsPerChunk = 1; this.customBiomeDecorator.tinyCactiPerChunk = 5; - this.customBiomeDecorator.quicksand2PerChunk = 6; + this.customBiomeDecorator.quicksand2PerChunk = 3; } public void decorate(World par1World, Random par2Random, int par3, int par4) diff --git a/src/minecraft/biomesoplenty/configuration/BOPConfiguration.java b/src/minecraft/biomesoplenty/configuration/BOPConfiguration.java index c2378e136..2d3c11b72 100644 --- a/src/minecraft/biomesoplenty/configuration/BOPConfiguration.java +++ b/src/minecraft/biomesoplenty/configuration/BOPConfiguration.java @@ -316,7 +316,7 @@ public class BOPConfiguration { config.load(); skyColors = true; - biomeSize = config.get("Biomes O\' Plenty World Type Settings", "Biome Size", 5, "Default World Type has 4. Large Biomes Worl Type has 6.").getInt(); + biomeSize = config.get("Biomes O\' Plenty World Type Settings", "Biome Size", 5, "Default World Type has 4. Large Biomes World Type has 6.").getInt(); achievements = config.get("Achievement Settings", "Add Biomes O\' Plenty Achievements", true).getBoolean(false); vanillaEnhanced = config.get("Biome Settings", "Enhanced Vanilla Biomes", true).getBoolean(false); promisedLandDimID = config.get("Dimension Settings", "Promised Land Dimension ID", 20, null).getInt(); diff --git a/src/minecraft/biomesoplenty/worldgen/structure/BOPMapGenScatteredFeature.java b/src/minecraft/biomesoplenty/worldgen/structure/BOPMapGenScatteredFeature.java new file mode 100644 index 000000000..85140fb4b --- /dev/null +++ b/src/minecraft/biomesoplenty/worldgen/structure/BOPMapGenScatteredFeature.java @@ -0,0 +1,116 @@ +package biomesoplenty.worldgen.structure; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Random; + +import biomesoplenty.api.Biomes; + +import net.minecraft.entity.monster.EntityWitch; +import net.minecraft.util.MathHelper; +import net.minecraft.world.biome.BiomeGenBase; +import net.minecraft.world.biome.SpawnListEntry; +import net.minecraft.world.gen.structure.MapGenStructure; +import net.minecraft.world.gen.structure.StructureStart; + +public class BOPMapGenScatteredFeature extends MapGenStructure +{ + private static List biomelist = Arrays.asList(new BiomeGenBase[] { + BiomeGenBase.desert, BiomeGenBase.desertHills, BiomeGenBase.jungle, BiomeGenBase.jungleHills, BiomeGenBase.swampland, + Biomes.badlands.get(), Biomes.dunes.get(), Biomes.oasis.get(), Biomes.desertNew.get(), + Biomes.bayou.get(), Biomes.bog.get(), Biomes.deadSwamp.get(), Biomes.fen.get(), Biomes.swampwoods.get(), Biomes.swamplandNew.get(), + Biomes.rainforest.get(), Biomes.temperateRainforest.get(), Biomes.tropicalRainforest.get(), Biomes.jungleNew.get() + }); + + /** contains possible spawns for scattered features */ + private List scatteredFeatureSpawnList; + + /** the maximum distance between scattered features */ + private int maxDistanceBetweenScatteredFeatures; + + /** the minimum distance between scattered features */ + private int minDistanceBetweenScatteredFeatures; + + public BOPMapGenScatteredFeature() + { + this.scatteredFeatureSpawnList = new ArrayList(); + this.maxDistanceBetweenScatteredFeatures = 32; + this.minDistanceBetweenScatteredFeatures = 8; + this.scatteredFeatureSpawnList.add(new SpawnListEntry(EntityWitch.class, 1, 1, 1)); + } + + public BOPMapGenScatteredFeature(Map par1Map) + { + this(); + Iterator iterator = par1Map.entrySet().iterator(); + + while (iterator.hasNext()) + { + Entry entry = (Entry)iterator.next(); + + if (((String)entry.getKey()).equals("distance")) + { + this.maxDistanceBetweenScatteredFeatures = MathHelper.parseIntWithDefaultAndMax((String)entry.getValue(), this.maxDistanceBetweenScatteredFeatures, this.minDistanceBetweenScatteredFeatures + 1); + } + } + } + + protected boolean canSpawnStructureAtCoords(int par1, int par2) + { + int k = par1; + int l = par2; + + if (par1 < 0) + { + par1 -= this.maxDistanceBetweenScatteredFeatures - 1; + } + + if (par2 < 0) + { + par2 -= this.maxDistanceBetweenScatteredFeatures - 1; + } + + int i1 = par1 / this.maxDistanceBetweenScatteredFeatures; + int j1 = par2 / this.maxDistanceBetweenScatteredFeatures; + Random random = this.worldObj.setRandomSeed(i1, j1, 14357617); + i1 *= this.maxDistanceBetweenScatteredFeatures; + j1 *= this.maxDistanceBetweenScatteredFeatures; + i1 += random.nextInt(this.maxDistanceBetweenScatteredFeatures - this.minDistanceBetweenScatteredFeatures); + j1 += random.nextInt(this.maxDistanceBetweenScatteredFeatures - this.minDistanceBetweenScatteredFeatures); + + if (k == i1 && l == j1) + { + BiomeGenBase biomegenbase = this.worldObj.getWorldChunkManager().getBiomeGenAt(k * 16 + 8, l * 16 + 8); + Iterator iterator = biomelist.iterator(); + + while (iterator.hasNext()) + { + BiomeGenBase biomegenbase1 = (BiomeGenBase)iterator.next(); + + if (biomegenbase == biomegenbase1) + { + return true; + } + } + } + + return false; + } + + protected StructureStart getStructureStart(int par1, int par2) + { + return new BOPStructureScatteredFeatureStart(this.worldObj, this.rand, par1, par2); + } + + /** + * returns possible spawns for scattered features + */ + public List getScatteredFeatureSpawnList() + { + return this.scatteredFeatureSpawnList; + } +} diff --git a/src/minecraft/biomesoplenty/worldgen/structure/BOPMapGenVillage.java b/src/minecraft/biomesoplenty/worldgen/structure/BOPMapGenVillage.java index a70abc4d8..c351596c9 100644 --- a/src/minecraft/biomesoplenty/worldgen/structure/BOPMapGenVillage.java +++ b/src/minecraft/biomesoplenty/worldgen/structure/BOPMapGenVillage.java @@ -21,14 +21,14 @@ public class BOPMapGenVillage extends MapGenStructure /** World terrain type, 0 for normal, 1 for flat map */ private int terrainType; - private int distance; - private int field_82666_h; + private int maxDistance; + private int minDistance; public BOPMapGenVillage() { this.terrainType = 0; - this.distance = BOPConfiguration.villageDistance; - this.field_82666_h = BOPConfiguration.villageDistance / 4; + this.maxDistance = BOPConfiguration.villageDistance; + this.minDistance = BOPConfiguration.villageDistance / 4; villageSpawnBiomes = MapGenVillage.villageSpawnBiomes; } @@ -47,7 +47,7 @@ public class BOPMapGenVillage extends MapGenStructure } else if (((String)entry.getKey()).equals("distance")) { - this.distance = MathHelper.parseIntWithDefaultAndMax((String)entry.getValue(), this.distance, this.field_82666_h + 1); + this.maxDistance = MathHelper.parseIntWithDefaultAndMax((String)entry.getValue(), this.maxDistance, this.minDistance + 1); } } } @@ -59,21 +59,21 @@ public class BOPMapGenVillage extends MapGenStructure if (par1 < 0) { - par1 -= this.distance - 1; + par1 -= this.maxDistance - 1; } if (par2 < 0) { - par2 -= this.distance - 1; + par2 -= this.maxDistance - 1; } - int i1 = par1 / this.distance; - int j1 = par2 / this.distance; + int i1 = par1 / this.maxDistance; + int j1 = par2 / this.maxDistance; Random random = this.worldObj.setRandomSeed(i1, j1, 10387312); - i1 *= this.distance; - j1 *= this.distance; - i1 += random.nextInt(this.distance - this.field_82666_h); - j1 += random.nextInt(this.distance - this.field_82666_h); + i1 *= this.maxDistance; + j1 *= this.maxDistance; + i1 += random.nextInt(this.maxDistance - this.minDistance); + j1 += random.nextInt(this.maxDistance - this.minDistance); if (k == i1 && l == j1) { diff --git a/src/minecraft/biomesoplenty/worldgen/structure/BOPStructureScatteredFeatureStart.java b/src/minecraft/biomesoplenty/worldgen/structure/BOPStructureScatteredFeatureStart.java new file mode 100644 index 000000000..c6b07b4c5 --- /dev/null +++ b/src/minecraft/biomesoplenty/worldgen/structure/BOPStructureScatteredFeatureStart.java @@ -0,0 +1,43 @@ +package biomesoplenty.worldgen.structure; + +import java.util.Random; + +import biomesoplenty.api.Biomes; +import net.minecraft.world.World; +import net.minecraft.world.biome.BiomeGenBase; +import net.minecraft.world.gen.structure.ComponentScatteredFeatureDesertPyramid; +import net.minecraft.world.gen.structure.ComponentScatteredFeatureJunglePyramid; +import net.minecraft.world.gen.structure.ComponentScatteredFeatureSwampHut; +import net.minecraft.world.gen.structure.StructureStart; + +public class BOPStructureScatteredFeatureStart extends StructureStart +{ + public BOPStructureScatteredFeatureStart(World world, Random random, int x, int z) + { + BiomeGenBase biome = world.getBiomeGenForCoords(x * 16 + 8, z * 16 + 8); + + if (biome != BiomeGenBase.jungle && biome != BiomeGenBase.jungleHills && biome != Biomes.rainforest.get() && + biome != Biomes.temperateRainforest.get() && biome != Biomes.tropicalRainforest.get() && biome != Biomes.jungleNew.get()) + { + if (biome == BiomeGenBase.swampland || biome == Biomes.bayou.get() || biome == Biomes.bog.get() + || biome == Biomes.deadSwamp.get() || biome == Biomes.fen.get() || biome == Biomes.swampwoods.get() + || biome == Biomes.swamplandNew.get()) + { + ComponentScatteredFeatureSwampHut componentscatteredfeatureswamphut = new ComponentScatteredFeatureSwampHut(random, x * 16, z * 16); + this.components.add(componentscatteredfeatureswamphut); + } + else + { + ComponentScatteredFeatureDesertPyramid componentscatteredfeaturedesertpyramid = new ComponentScatteredFeatureDesertPyramid(random, x * 16, z * 16); + this.components.add(componentscatteredfeaturedesertpyramid); + } + } + else + { + ComponentScatteredFeatureJunglePyramid componentscatteredfeaturejunglepyramid = new ComponentScatteredFeatureJunglePyramid(random, x * 16, z * 16); + this.components.add(componentscatteredfeaturejunglepyramid); + } + + this.updateBoundingBox(); + } +} diff --git a/src/minecraft/biomesoplenty/worldtype/ChunkProviderBOP.java b/src/minecraft/biomesoplenty/worldtype/ChunkProviderBOP.java index 567f5e181..bc34b045c 100644 --- a/src/minecraft/biomesoplenty/worldtype/ChunkProviderBOP.java +++ b/src/minecraft/biomesoplenty/worldtype/ChunkProviderBOP.java @@ -15,6 +15,7 @@ import java.util.List; import java.util.Random; import biomesoplenty.configuration.BOPConfiguration; +import biomesoplenty.worldgen.structure.BOPMapGenScatteredFeature; import biomesoplenty.worldgen.structure.BOPMapGenVillage; import net.minecraft.block.Block; @@ -32,12 +33,10 @@ import net.minecraft.world.gen.MapGenBase; import net.minecraft.world.gen.MapGenCaves; import net.minecraft.world.gen.MapGenRavine; import net.minecraft.world.gen.NoiseGeneratorOctaves; -import net.minecraft.world.gen.feature.MapGenScatteredFeature; import net.minecraft.world.gen.feature.WorldGenDungeons; import net.minecraft.world.gen.feature.WorldGenLakes; import net.minecraft.world.gen.structure.MapGenMineshaft; import net.minecraft.world.gen.structure.MapGenStronghold; -import net.minecraft.world.gen.structure.MapGenVillage; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.Event.Result; import net.minecraftforge.event.terraingen.ChunkProviderEvent; @@ -62,7 +61,7 @@ public class ChunkProviderBOP implements IChunkProvider private MapGenStronghold strongholdGenerator = new MapGenStronghold(); private BOPMapGenVillage villageGenerator = new BOPMapGenVillage(); private MapGenMineshaft mineshaftGenerator = new MapGenMineshaft(); - private MapGenScatteredFeature scatteredFeatureGenerator = new MapGenScatteredFeature(); + private BOPMapGenScatteredFeature scatteredFeatureGenerator = new BOPMapGenScatteredFeature(); private MapGenBase ravineGenerator = new MapGenRavine(); private BiomeGenBase[] biomesForGeneration; double[] noise3; @@ -83,7 +82,7 @@ public class ChunkProviderBOP implements IChunkProvider strongholdGenerator = (MapGenStronghold) TerrainGen.getModdedMapGen(strongholdGenerator, STRONGHOLD); villageGenerator = (BOPMapGenVillage) TerrainGen.getModdedMapGen(villageGenerator, VILLAGE); mineshaftGenerator = (MapGenMineshaft) TerrainGen.getModdedMapGen(mineshaftGenerator, MINESHAFT); - scatteredFeatureGenerator = (MapGenScatteredFeature) TerrainGen.getModdedMapGen(scatteredFeatureGenerator, SCATTERED_FEATURE); + scatteredFeatureGenerator = (BOPMapGenScatteredFeature) TerrainGen.getModdedMapGen(scatteredFeatureGenerator, SCATTERED_FEATURE); ravineGenerator = TerrainGen.getModdedMapGen(ravineGenerator, RAVINE); }