Skip to content

Commit

Permalink
Add support for Custom biomes from BiomesOPlenty. (Closes #290)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexbegt committed Oct 7, 2016
1 parent d500d52 commit 4bcf268
Showing 1 changed file with 22 additions and 15 deletions.
37 changes: 22 additions & 15 deletions src/main/java/com/progwml6/natura/world/worldgen/TreeGenerator.java
Expand Up @@ -22,8 +22,11 @@
import net.minecraft.block.state.IBlockState;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraft.world.biome.Biome;
import net.minecraft.world.chunk.IChunkGenerator;
import net.minecraft.world.chunk.IChunkProvider;
import net.minecraftforge.common.BiomeDictionary;
import net.minecraftforge.common.BiomeDictionary.Type;
import net.minecraftforge.fml.common.IWorldGenerator;

public class TreeGenerator implements IWorldGenerator
Expand Down Expand Up @@ -105,7 +108,14 @@ public void generateOverworld(Random random, int chunkX, int chunkZ, World world
return;
}

if (biomeName == "Forest" || biomeName == "AutumnWoods" || biomeName == "BirchForest" || biomeName == "PineForest" || biomeName == "Rainforest" || biomeName == "TemperateRainforest" || biomeName == "Woodlands")
Biome biome = world.getChunkFromBlockCoords(chunkPos).getBiome(chunkPos, world.getBiomeProvider());

if (biome == null)
{
return;
}

if (BiomeDictionary.isBiomeOfType(biome, Type.FOREST))
{
if (Config.generateSakura && random.nextInt(Config.sakuraSpawnRarity * 5) == 0)
{
Expand All @@ -131,7 +141,7 @@ public void generateOverworld(Random random, int chunkX, int chunkZ, World world
}
}

if (biomeName == "Plains" || biomeName == "Meadow")
if (BiomeDictionary.isBiomeOfType(biome, Type.PLAINS))
{
if (Config.generateEucalyptus && random.nextInt((int) (Config.eucalyptusSpawnRarity * 1.5)) == 0)
{
Expand All @@ -144,7 +154,7 @@ public void generateOverworld(Random random, int chunkX, int chunkZ, World world
}
}

if (biomeName == "Extreme Hills" || biomeName == "Extreme Hills Edge" || biomeName == "ForestedHills" || biomeName == "GreenHills")
if (BiomeDictionary.isBiomeOfType(biome, Type.MOUNTAIN) && BiomeDictionary.isBiomeOfType(biome, Type.HILLS))
{
if (Config.generateHopseed && random.nextInt(Config.hopseedSpawnRarity) == 0)
{
Expand All @@ -167,7 +177,7 @@ public void generateOverworld(Random random, int chunkX, int chunkZ, World world
}
}

if (biomeName == "River")
if (BiomeDictionary.isBiomeOfType(biome, Type.RIVER))
{
if (Config.generateSakura && random.nextInt(Config.sakuraSpawnRarity) == 0)
{
Expand All @@ -193,7 +203,7 @@ public void generateOverworld(Random random, int chunkX, int chunkZ, World world
}
}

if (biomeName == "Jungle" || biomeName == "JungleHills" || biomeName == "Extreme Jungle")
if (BiomeDictionary.isBiomeOfType(biome, Type.JUNGLE))
{
if (Config.generateAmaranth)
{
Expand All @@ -206,7 +216,7 @@ public void generateOverworld(Random random, int chunkX, int chunkZ, World world
}
}

if (biomeName == "Forest" || biomeName == "Woodlands" || biomeName == "AutumnWoods")
if (BiomeDictionary.isBiomeOfType(biome, Type.FOREST))
{
if (Config.generateMaple && random.nextInt(Config.mapleRarity) == 0)
{
Expand All @@ -227,10 +237,7 @@ public void generateOverworld(Random random, int chunkX, int chunkZ, World world

this.silverbellTreeGen.generateTree(random, world, position);
}
}

if (biomeName == "Forest" || biomeName == "Rainforest" || biomeName == "TemperateRainforest")
{
if (Config.generateTiger && random.nextInt(Config.tigerRarity) == 0)
{
xSpawn = xPos + random.nextInt(16);
Expand All @@ -242,7 +249,7 @@ public void generateOverworld(Random random, int chunkX, int chunkZ, World world
}
}

if (biomeName == "Swampland" || biomeName == "ForestHills")
if (BiomeDictionary.isBiomeOfType(biome, Type.SWAMP))
{
if (Config.generateWillow && random.nextInt(Config.willowRarity) == 0)
{
Expand Down Expand Up @@ -270,24 +277,24 @@ public void generateNether(Random random, int chunkX, int chunkZ, World world)

BlockPos position;

String biomeName = world.getChunkFromBlockCoords(chunkPos).getBiome(chunkPos, world.getBiomeProvider()).getBiomeName();
Biome biome = world.getChunkFromBlockCoords(chunkPos).getBiome(chunkPos, world.getBiomeProvider());

if (biomeName == null)
if (biome == null)
{
return;
}

if (biomeName.equals("Hell") || biomeName.equals("Boneyard") || biomeName.equals("Phantasmagoric Inferno") || biomeName.equals("Corrupted Sands") || biomeName.equals("Corrupted Sands"))
if (BiomeDictionary.isBiomeOfType(biome, Type.NETHER))
{
/*if (Config.generateBloodwood && random.nextInt(Config.bloodwoodSpawnRarity) == 0)
{
xSpawn = xPos + random.nextInt(16);
ySpawn = 72;
zSpawn = zPos + random.nextInt(16);
position = new BlockPos(xSpawn, ySpawn, zSpawn);
this.bloodwoodTreeGen.generateTree(random, world, position);
this.genBlood.generate(world, random, xSpawn, ySpawn, zSpawn);
}*/

Expand Down

0 comments on commit 4bcf268

Please sign in to comment.