Added configurable spawn distance between villages in BOP World Type

Added more biomes to spawn villages in
This commit is contained in:
Amnet 2013-04-25 12:38:55 +02:00
parent 5e6c5f4d06
commit fb1c0b362a
8 changed files with 225 additions and 7 deletions

View file

@ -114,7 +114,7 @@ public class BiomesOPlenty
public void load(FMLInitializationEvent event) public void load(FMLInitializationEvent event)
{ {
LanguageRegistry.instance().addStringLocalization("itemGroup.tabBiomesOPlenty", "en_US", "Biomes O\' Plenty"); 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 // Add helpers for compatibility
MinecraftForge.TERRAIN_GEN_BUS.register(new WorldTypeSize()); MinecraftForge.TERRAIN_GEN_BUS.register(new WorldTypeSize());

View file

@ -32,7 +32,7 @@ public class BOPBiomes {
initializeBiomes(); initializeBiomes();
//Initialize new world type //Initialize new world type
//WTBiomesOP = new WTBiomesOP(); WTBiomesOP = new WTBiomesOP();
//Biome Dictionary //Biome Dictionary
addToBiomeDictionary(); addToBiomeDictionary();
@ -317,7 +317,39 @@ public class BOPBiomes {
addVillageBiome(Biomes.forestNew); addVillageBiome(Biomes.forestNew);
addVillageBiome(Biomes.taigaNew); addVillageBiome(Biomes.taigaNew);
addVillageBiome(Biomes.swamplandNew); 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() private static void addStrongholdBiomes()
{ {
@ -622,65 +654,79 @@ public class BOPBiomes {
// Vanilla biomes generation // Vanilla biomes generation
if (BOPConfiguration.plainsGen) if (BOPConfiguration.plainsGen)
{
if (BOPConfiguration.vanillaEnhanced) if (BOPConfiguration.vanillaEnhanced)
{ {
registerBiome(Biomes.plainsNew); registerBiome(Biomes.plainsNew);
GameRegistry.removeBiome(BiomeGenBase.plains); GameRegistry.removeBiome(BiomeGenBase.plains);
} }
}
else else
GameRegistry.removeBiome(BiomeGenBase.plains); GameRegistry.removeBiome(BiomeGenBase.plains);
if (BOPConfiguration.desertGen) if (BOPConfiguration.desertGen)
{
if (BOPConfiguration.vanillaEnhanced) if (BOPConfiguration.vanillaEnhanced)
{ {
registerBiome(Biomes.desertNew); registerBiome(Biomes.desertNew);
GameRegistry.removeBiome(BiomeGenBase.desert); GameRegistry.removeBiome(BiomeGenBase.desert);
} }
}
else else
GameRegistry.removeBiome(BiomeGenBase.desert); GameRegistry.removeBiome(BiomeGenBase.desert);
if (BOPConfiguration.extremeHillsGen) if (BOPConfiguration.extremeHillsGen)
{
if (BOPConfiguration.vanillaEnhanced) if (BOPConfiguration.vanillaEnhanced)
{ {
registerBiome(Biomes.extremeHillsNew); registerBiome(Biomes.extremeHillsNew);
GameRegistry.removeBiome(BiomeGenBase.extremeHills); GameRegistry.removeBiome(BiomeGenBase.extremeHills);
} }
}
else else
GameRegistry.removeBiome(BiomeGenBase.extremeHills); GameRegistry.removeBiome(BiomeGenBase.extremeHills);
if (BOPConfiguration.forestGen) if (BOPConfiguration.forestGen)
{
if (BOPConfiguration.vanillaEnhanced) if (BOPConfiguration.vanillaEnhanced)
{ {
registerBiome(Biomes.forestNew); registerBiome(Biomes.forestNew);
GameRegistry.removeBiome(BiomeGenBase.forest); GameRegistry.removeBiome(BiomeGenBase.forest);
} }
}
else else
GameRegistry.removeBiome(BiomeGenBase.forest); GameRegistry.removeBiome(BiomeGenBase.forest);
if (BOPConfiguration.taigaGen) if (BOPConfiguration.taigaGen)
{
if (BOPConfiguration.vanillaEnhanced) if (BOPConfiguration.vanillaEnhanced)
{ {
registerBiome(Biomes.taigaNew); registerBiome(Biomes.taigaNew);
GameRegistry.removeBiome(BiomeGenBase.taiga); GameRegistry.removeBiome(BiomeGenBase.taiga);
} }
}
else else
GameRegistry.removeBiome(BiomeGenBase.taiga); GameRegistry.removeBiome(BiomeGenBase.taiga);
if (BOPConfiguration.swamplandGen) if (BOPConfiguration.swamplandGen)
{
if (BOPConfiguration.vanillaEnhanced) if (BOPConfiguration.vanillaEnhanced)
{ {
registerBiome(Biomes.swamplandNew); registerBiome(Biomes.swamplandNew);
GameRegistry.removeBiome(BiomeGenBase.swampland); GameRegistry.removeBiome(BiomeGenBase.swampland);
} }
}
else else
GameRegistry.removeBiome(BiomeGenBase.swampland); GameRegistry.removeBiome(BiomeGenBase.swampland);
if (BOPConfiguration.jungleGen) if (BOPConfiguration.jungleGen)
{
if (BOPConfiguration.vanillaEnhanced) if (BOPConfiguration.vanillaEnhanced)
{ {
registerBiome(Biomes.jungleNew); registerBiome(Biomes.jungleNew);
GameRegistry.removeBiome(BiomeGenBase.jungle); GameRegistry.removeBiome(BiomeGenBase.jungle);
} }
}
else else
GameRegistry.removeBiome(BiomeGenBase.jungle); GameRegistry.removeBiome(BiomeGenBase.jungle);
} }

View file

@ -17,6 +17,8 @@ public class BOPConfiguration {
public static boolean achievements; public static boolean achievements;
public static boolean vanillaEnhanced; public static boolean vanillaEnhanced;
public static int villageDistance;
public static int promisedLandDimID; public static int promisedLandDimID;
public static boolean alpsGen; public static boolean alpsGen;
@ -321,6 +323,10 @@ public class BOPConfiguration {
addToDefault = config.get("Biome Settings", "Add Biomes To Default World", true).getBoolean(true); 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); alpsGen = config.get("Biomes To Generate", "Alps", true).getBoolean(false);
arcticGen = config.get("Biomes To Generate", "Arctic", true).getBoolean(false); arcticGen = config.get("Biomes To Generate", "Arctic", true).getBoolean(false);
badlandsGen = config.get("Biomes To Generate", "Badlands", true).getBoolean(false); badlandsGen = config.get("Biomes To Generate", "Badlands", true).getBoolean(false);

View file

@ -14,7 +14,7 @@ public class ThaumcraftIntegration {
protected static void init() protected static void init()
{ {
addAspects(); 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() private static void addAspects()

View file

@ -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);
}
}

View file

@ -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;
}
}

View file

@ -15,6 +15,7 @@ import java.util.List;
import java.util.Random; import java.util.Random;
import biomesoplenty.configuration.BOPConfiguration; import biomesoplenty.configuration.BOPConfiguration;
import biomesoplenty.worldgen.structure.BOPMapGenVillage;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.BlockSand; import net.minecraft.block.BlockSand;
@ -59,7 +60,7 @@ public class ChunkProviderBOP implements IChunkProvider
private double[] stoneNoise = new double[256]; private double[] stoneNoise = new double[256];
private MapGenBase caveGenerator = new MapGenCaves(); private MapGenBase caveGenerator = new MapGenCaves();
private MapGenStronghold strongholdGenerator = new MapGenStronghold(); private MapGenStronghold strongholdGenerator = new MapGenStronghold();
private MapGenVillage villageGenerator = new MapGenVillage(); private BOPMapGenVillage villageGenerator = new BOPMapGenVillage();
private MapGenMineshaft mineshaftGenerator = new MapGenMineshaft(); private MapGenMineshaft mineshaftGenerator = new MapGenMineshaft();
private MapGenScatteredFeature scatteredFeatureGenerator = new MapGenScatteredFeature(); private MapGenScatteredFeature scatteredFeatureGenerator = new MapGenScatteredFeature();
private MapGenBase ravineGenerator = new MapGenRavine(); private MapGenBase ravineGenerator = new MapGenRavine();
@ -80,7 +81,7 @@ public class ChunkProviderBOP implements IChunkProvider
{ {
caveGenerator = TerrainGen.getModdedMapGen(caveGenerator, CAVE); caveGenerator = TerrainGen.getModdedMapGen(caveGenerator, CAVE);
strongholdGenerator = (MapGenStronghold) TerrainGen.getModdedMapGen(strongholdGenerator, STRONGHOLD); strongholdGenerator = (MapGenStronghold) TerrainGen.getModdedMapGen(strongholdGenerator, STRONGHOLD);
villageGenerator = (MapGenVillage) TerrainGen.getModdedMapGen(villageGenerator, VILLAGE); villageGenerator = (BOPMapGenVillage) TerrainGen.getModdedMapGen(villageGenerator, VILLAGE);
mineshaftGenerator = (MapGenMineshaft) TerrainGen.getModdedMapGen(mineshaftGenerator, MINESHAFT); mineshaftGenerator = (MapGenMineshaft) TerrainGen.getModdedMapGen(mineshaftGenerator, MINESHAFT);
scatteredFeatureGenerator = (MapGenScatteredFeature) TerrainGen.getModdedMapGen(scatteredFeatureGenerator, SCATTERED_FEATURE); scatteredFeatureGenerator = (MapGenScatteredFeature) TerrainGen.getModdedMapGen(scatteredFeatureGenerator, SCATTERED_FEATURE);
ravineGenerator = TerrainGen.getModdedMapGen(ravineGenerator, RAVINE); ravineGenerator = TerrainGen.getModdedMapGen(ravineGenerator, RAVINE);

View file

@ -11,7 +11,7 @@ public class WTBiomesOP extends WorldTypeBase
{ {
public WTBiomesOP() { public WTBiomesOP() {
super(4, "BIOMESOP"); super(4, "BIOMESOP");
this.removeAllBiomes(); //this.removeAllBiomes();
this.removeBiome(BiomeGenBase.plains); this.removeBiome(BiomeGenBase.plains);
this.removeBiome(BiomeGenBase.desert); this.removeBiome(BiomeGenBase.desert);
this.removeBiome(BiomeGenBase.forest); this.removeBiome(BiomeGenBase.forest);