diff --git a/src/minecraft/biomesoplenty/BiomesOPlenty.java b/src/minecraft/biomesoplenty/BiomesOPlenty.java index a45d98826..3f3950309 100644 --- a/src/minecraft/biomesoplenty/BiomesOPlenty.java +++ b/src/minecraft/biomesoplenty/BiomesOPlenty.java @@ -114,7 +114,7 @@ public class BiomesOPlenty public void load(FMLInitializationEvent event) { LanguageRegistry.instance().addStringLocalization("itemGroup.tabBiomesOPlenty", "en_US", "Biomes O\' Plenty"); - //LanguageRegistry.instance().addStringLocalization("generator.BIOMESOP", "en_US", "Biomes O\' Plenty"); + LanguageRegistry.instance().addStringLocalization("generator.BIOMESOP", "en_US", "Biomes O\' Plenty"); // Add helpers for compatibility MinecraftForge.TERRAIN_GEN_BUS.register(new WorldTypeSize()); diff --git a/src/minecraft/biomesoplenty/configuration/BOPBiomes.java b/src/minecraft/biomesoplenty/configuration/BOPBiomes.java index a82833bb2..d3bf9496e 100644 --- a/src/minecraft/biomesoplenty/configuration/BOPBiomes.java +++ b/src/minecraft/biomesoplenty/configuration/BOPBiomes.java @@ -32,7 +32,7 @@ public class BOPBiomes { initializeBiomes(); //Initialize new world type - //WTBiomesOP = new WTBiomesOP(); + WTBiomesOP = new WTBiomesOP(); //Biome Dictionary addToBiomeDictionary(); @@ -317,7 +317,39 @@ public class BOPBiomes { addVillageBiome(Biomes.forestNew); addVillageBiome(Biomes.taigaNew); addVillageBiome(Biomes.swamplandNew); - } + + // Additional biomes to spawn villages + addVillageBiome(Biomes.alps); + addVillageBiome(Biomes.badlands); + addVillageBiome(Biomes.bambooForest); + addVillageBiome(Biomes.bog); + addVillageBiome(Biomes.borealForest); + addVillageBiome(Biomes.canyon); + addVillageBiome(Biomes.cherryBlossomGrove); + addVillageBiome(Biomes.deadSwamp); + addVillageBiome(Biomes.deciduousForest); + addVillageBiome(Biomes.drylands); + addVillageBiome(Biomes.dunes); + addVillageBiome(Biomes.fen); + addVillageBiome(Biomes.highland); + addVillageBiome(Biomes.jadeCliffs); + addVillageBiome(Biomes.lushDesert); + addVillageBiome(Biomes.meadow); + addVillageBiome(Biomes.moor); + addVillageBiome(Biomes.mountain); + addVillageBiome(Biomes.oasis); + addVillageBiome(Biomes.outback); + addVillageBiome(Biomes.pasture); + addVillageBiome(Biomes.quagmire); + addVillageBiome(Biomes.rainforest); + addVillageBiome(Biomes.seasonalForest); + addVillageBiome(Biomes.swampwoods); + addVillageBiome(Biomes.temperateRainforest); + addVillageBiome(Biomes.thicket); + addVillageBiome(Biomes.tropics); + addVillageBiome(Biomes.tundra); + addVillageBiome(Biomes.wetland); + } private static void addStrongholdBiomes() { @@ -622,65 +654,79 @@ public class BOPBiomes { // Vanilla biomes generation if (BOPConfiguration.plainsGen) + { if (BOPConfiguration.vanillaEnhanced) { registerBiome(Biomes.plainsNew); GameRegistry.removeBiome(BiomeGenBase.plains); } + } else GameRegistry.removeBiome(BiomeGenBase.plains); if (BOPConfiguration.desertGen) + { if (BOPConfiguration.vanillaEnhanced) { registerBiome(Biomes.desertNew); GameRegistry.removeBiome(BiomeGenBase.desert); } + } else GameRegistry.removeBiome(BiomeGenBase.desert); if (BOPConfiguration.extremeHillsGen) + { if (BOPConfiguration.vanillaEnhanced) { registerBiome(Biomes.extremeHillsNew); GameRegistry.removeBiome(BiomeGenBase.extremeHills); } + } else GameRegistry.removeBiome(BiomeGenBase.extremeHills); if (BOPConfiguration.forestGen) + { if (BOPConfiguration.vanillaEnhanced) { registerBiome(Biomes.forestNew); GameRegistry.removeBiome(BiomeGenBase.forest); } + } else GameRegistry.removeBiome(BiomeGenBase.forest); if (BOPConfiguration.taigaGen) + { if (BOPConfiguration.vanillaEnhanced) { registerBiome(Biomes.taigaNew); GameRegistry.removeBiome(BiomeGenBase.taiga); } + } else GameRegistry.removeBiome(BiomeGenBase.taiga); if (BOPConfiguration.swamplandGen) + { if (BOPConfiguration.vanillaEnhanced) { registerBiome(Biomes.swamplandNew); GameRegistry.removeBiome(BiomeGenBase.swampland); } + } else GameRegistry.removeBiome(BiomeGenBase.swampland); if (BOPConfiguration.jungleGen) + { if (BOPConfiguration.vanillaEnhanced) { registerBiome(Biomes.jungleNew); GameRegistry.removeBiome(BiomeGenBase.jungle); } + } else GameRegistry.removeBiome(BiomeGenBase.jungle); } diff --git a/src/minecraft/biomesoplenty/configuration/BOPConfiguration.java b/src/minecraft/biomesoplenty/configuration/BOPConfiguration.java index 8f5c475a3..3307046bb 100644 --- a/src/minecraft/biomesoplenty/configuration/BOPConfiguration.java +++ b/src/minecraft/biomesoplenty/configuration/BOPConfiguration.java @@ -17,6 +17,8 @@ public class BOPConfiguration { public static boolean achievements; public static boolean vanillaEnhanced; + public static int villageDistance; + public static int promisedLandDimID; public static boolean alpsGen; @@ -320,6 +322,10 @@ public class BOPConfiguration { promisedLandDimID = config.get("Dimension Settings", "Promised Land Dimension ID", 20, null).getInt(); addToDefault = config.get("Biome Settings", "Add Biomes To Default World", true).getBoolean(true); + + villageDistance = config.get("Biomes O\' Plenty World Type Settings", "Distance between villages", 24, "In Vanilla it is set to 32").getInt(); + if (villageDistance < 8) + villageDistance = 8; alpsGen = config.get("Biomes To Generate", "Alps", true).getBoolean(false); arcticGen = config.get("Biomes To Generate", "Arctic", true).getBoolean(false); diff --git a/src/minecraft/biomesoplenty/integration/ThaumcraftIntegration.java b/src/minecraft/biomesoplenty/integration/ThaumcraftIntegration.java index 8005209d0..5a2b20106 100644 --- a/src/minecraft/biomesoplenty/integration/ThaumcraftIntegration.java +++ b/src/minecraft/biomesoplenty/integration/ThaumcraftIntegration.java @@ -14,7 +14,7 @@ public class ThaumcraftIntegration { protected static void init() { addAspects(); - FMLInterModComms.sendMessage("Thaumcraft", "harvestClickableCrop", new ItemStack(Blocks.leavesFruit.get(), 1, 4)); + FMLInterModComms.sendMessage("Thaumcraft", "harvestClickableCrop", new ItemStack(Blocks.leavesFruit.get(), 1, 3)); } private static void addAspects() diff --git a/src/minecraft/biomesoplenty/worldgen/structure/BOPMapGenVillage.java b/src/minecraft/biomesoplenty/worldgen/structure/BOPMapGenVillage.java new file mode 100644 index 000000000..a70abc4d8 --- /dev/null +++ b/src/minecraft/biomesoplenty/worldgen/structure/BOPMapGenVillage.java @@ -0,0 +1,95 @@ +package biomesoplenty.worldgen.structure; + +import java.util.Arrays; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Random; +import java.util.Map.Entry; + +import biomesoplenty.configuration.BOPConfiguration; +import net.minecraft.util.MathHelper; +import net.minecraft.world.biome.BiomeGenBase; +import net.minecraft.world.gen.structure.MapGenStructure; +import net.minecraft.world.gen.structure.MapGenVillage; +import net.minecraft.world.gen.structure.StructureStart; + +public class BOPMapGenVillage extends MapGenStructure +{ + /** A list of all the biomes villages can spawn in. */ + public static List villageSpawnBiomes = Arrays.asList(new BiomeGenBase[] {BiomeGenBase.plains, BiomeGenBase.desert}); + + /** World terrain type, 0 for normal, 1 for flat map */ + private int terrainType; + private int distance; + private int field_82666_h; + + public BOPMapGenVillage() + { + this.terrainType = 0; + this.distance = BOPConfiguration.villageDistance; + this.field_82666_h = BOPConfiguration.villageDistance / 4; + villageSpawnBiomes = MapGenVillage.villageSpawnBiomes; + } + + public BOPMapGenVillage(Map par1Map) + { + this(); + Iterator iterator = par1Map.entrySet().iterator(); + + while (iterator.hasNext()) + { + Entry entry = (Entry)iterator.next(); + + if (((String)entry.getKey()).equals("size")) + { + this.terrainType = MathHelper.parseIntWithDefaultAndMax((String)entry.getValue(), this.terrainType, 0); + } + else if (((String)entry.getKey()).equals("distance")) + { + this.distance = MathHelper.parseIntWithDefaultAndMax((String)entry.getValue(), this.distance, this.field_82666_h + 1); + } + } + } + + protected boolean canSpawnStructureAtCoords(int par1, int par2) + { + int k = par1; + int l = par2; + + if (par1 < 0) + { + par1 -= this.distance - 1; + } + + if (par2 < 0) + { + par2 -= this.distance - 1; + } + + int i1 = par1 / this.distance; + int j1 = par2 / this.distance; + 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); + + if (k == i1 && l == j1) + { + boolean flag = this.worldObj.getWorldChunkManager().areBiomesViable(k * 16 + 8, l * 16 + 8, 0, villageSpawnBiomes); + + if (flag) + { + return true; + } + } + + return false; + } + + protected StructureStart getStructureStart(int par1, int par2) + { + return new BOPStructureVillageStart(this.worldObj, this.rand, par1, par2, this.terrainType); + } +} diff --git a/src/minecraft/biomesoplenty/worldgen/structure/BOPStructureVillageStart.java b/src/minecraft/biomesoplenty/worldgen/structure/BOPStructureVillageStart.java new file mode 100644 index 000000000..bffad5719 --- /dev/null +++ b/src/minecraft/biomesoplenty/worldgen/structure/BOPStructureVillageStart.java @@ -0,0 +1,70 @@ +package biomesoplenty.worldgen.structure; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.Random; +import net.minecraft.world.World; +import net.minecraft.world.gen.structure.ComponentVillageRoadPiece; +import net.minecraft.world.gen.structure.ComponentVillageStartPiece; +import net.minecraft.world.gen.structure.StructureComponent; +import net.minecraft.world.gen.structure.StructureStart; +import net.minecraft.world.gen.structure.StructureVillagePieces; + +class BOPStructureVillageStart extends StructureStart +{ + /** well ... thats what it does */ + private boolean hasMoreThanTwoComponents = false; + + public BOPStructureVillageStart(World par1World, Random par2Random, int par3, int par4, int par5) + { + ArrayList arraylist = StructureVillagePieces.getStructureVillageWeightedPieceList(par2Random, par5); + ComponentVillageStartPiece componentvillagestartpiece = new ComponentVillageStartPiece(par1World.getWorldChunkManager(), 0, par2Random, (par3 << 4) + 2, (par4 << 4) + 2, arraylist, par5); + this.components.add(componentvillagestartpiece); + componentvillagestartpiece.buildComponent(componentvillagestartpiece, this.components, par2Random); + ArrayList arraylist1 = componentvillagestartpiece.field_74930_j; + ArrayList arraylist2 = componentvillagestartpiece.field_74932_i; + int l; + + while (!arraylist1.isEmpty() || !arraylist2.isEmpty()) + { + StructureComponent structurecomponent; + + if (arraylist1.isEmpty()) + { + l = par2Random.nextInt(arraylist2.size()); + structurecomponent = (StructureComponent)arraylist2.remove(l); + structurecomponent.buildComponent(componentvillagestartpiece, this.components, par2Random); + } + else + { + l = par2Random.nextInt(arraylist1.size()); + structurecomponent = (StructureComponent)arraylist1.remove(l); + structurecomponent.buildComponent(componentvillagestartpiece, this.components, par2Random); + } + } + + this.updateBoundingBox(); + l = 0; + Iterator iterator = this.components.iterator(); + + while (iterator.hasNext()) + { + StructureComponent structurecomponent1 = (StructureComponent)iterator.next(); + + if (!(structurecomponent1 instanceof ComponentVillageRoadPiece)) + { + ++l; + } + } + + this.hasMoreThanTwoComponents = l > 2; + } + + /** + * currently only defined for Villages, returns true if Village has more than 2 non-road components + */ + public boolean isSizeableStructure() + { + return this.hasMoreThanTwoComponents; + } +} diff --git a/src/minecraft/biomesoplenty/worldtype/ChunkProviderBOP.java b/src/minecraft/biomesoplenty/worldtype/ChunkProviderBOP.java index 9679fb475..567f5e181 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.BOPMapGenVillage; import net.minecraft.block.Block; import net.minecraft.block.BlockSand; @@ -59,7 +60,7 @@ public class ChunkProviderBOP implements IChunkProvider private double[] stoneNoise = new double[256]; private MapGenBase caveGenerator = new MapGenCaves(); private MapGenStronghold strongholdGenerator = new MapGenStronghold(); - private MapGenVillage villageGenerator = new MapGenVillage(); + private BOPMapGenVillage villageGenerator = new BOPMapGenVillage(); private MapGenMineshaft mineshaftGenerator = new MapGenMineshaft(); private MapGenScatteredFeature scatteredFeatureGenerator = new MapGenScatteredFeature(); private MapGenBase ravineGenerator = new MapGenRavine(); @@ -80,7 +81,7 @@ public class ChunkProviderBOP implements IChunkProvider { caveGenerator = TerrainGen.getModdedMapGen(caveGenerator, CAVE); strongholdGenerator = (MapGenStronghold) TerrainGen.getModdedMapGen(strongholdGenerator, STRONGHOLD); - villageGenerator = (MapGenVillage) TerrainGen.getModdedMapGen(villageGenerator, VILLAGE); + villageGenerator = (BOPMapGenVillage) TerrainGen.getModdedMapGen(villageGenerator, VILLAGE); mineshaftGenerator = (MapGenMineshaft) TerrainGen.getModdedMapGen(mineshaftGenerator, MINESHAFT); scatteredFeatureGenerator = (MapGenScatteredFeature) TerrainGen.getModdedMapGen(scatteredFeatureGenerator, SCATTERED_FEATURE); ravineGenerator = TerrainGen.getModdedMapGen(ravineGenerator, RAVINE); diff --git a/src/minecraft/biomesoplenty/worldtype/WTBiomesOP.java b/src/minecraft/biomesoplenty/worldtype/WTBiomesOP.java index 75d16763f..64dae9f81 100644 --- a/src/minecraft/biomesoplenty/worldtype/WTBiomesOP.java +++ b/src/minecraft/biomesoplenty/worldtype/WTBiomesOP.java @@ -11,7 +11,7 @@ public class WTBiomesOP extends WorldTypeBase { public WTBiomesOP() { super(4, "BIOMESOP"); - this.removeAllBiomes(); + //this.removeAllBiomes(); this.removeBiome(BiomeGenBase.plains); this.removeBiome(BiomeGenBase.desert); this.removeBiome(BiomeGenBase.forest);