Make foothills on the edges of the mountains

This commit is contained in:
Cheeserolls 2015-06-10 00:20:38 +01:00
parent 24e668e943
commit bc93ad2bd8
4 changed files with 97 additions and 46 deletions

View file

@ -14,6 +14,7 @@ import net.minecraft.world.biome.BiomeGenBase;
public class BOPBiomes
{
// normal biomes which have weights
public static Optional<BiomeGenBase> alps = Optional.absent();
public static Optional<BiomeGenBase> arctic = Optional.absent();
public static Optional<BiomeGenBase> crag = Optional.absent();
@ -35,7 +36,7 @@ public class BOPBiomes
public static Optional<BiomeGenBase> tundra = Optional.absent();
public static Optional<BiomeGenBase> woodland = Optional.absent();
// sub biomes
// edge-biomes, sub-biomes and mutated-biomes
public static Optional<BiomeGenBase> glacier = Optional.absent();
public static Optional<BiomeGenBase> mountainFoothills = Optional.absent();
}

View file

@ -14,8 +14,11 @@ import net.minecraft.block.BlockDirt;
import net.minecraft.block.BlockTallGrass;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.passive.EntitySheep;
import net.minecraft.entity.passive.EntityWolf;
import net.minecraft.init.Blocks;
import net.minecraft.world.World;
import net.minecraft.world.biome.BiomeGenBase;
import net.minecraft.world.chunk.ChunkPrimer;
import net.minecraftforge.common.BiomeManager.BiomeType;
import biomesoplenty.api.biome.BOPBiome;
@ -41,6 +44,9 @@ import biomesoplenty.common.world.feature.tree.GeneratorPineTree;
public class BiomeGenMountain extends BOPBiome
{
public static enum MountainType {PEAKS, FOOTHILLS}
public MountainType type;
public IBlockState grassBlock;
public IBlockState dirtBlock;
public IBlockState coarseDirtBlock;
@ -48,18 +54,38 @@ public class BiomeGenMountain extends BOPBiome
public IBlockState snowBlock;
public IBlockState packedSnowBlock;
public BiomeGenMountain()
public BiomeGenMountain(MountainType type)
{
this.type = type;
// terrain
this.bopMinHeight = 30;
this.bopMaxHeight = 240;
switch (type)
{
case PEAKS:
this.bopMinHeight = 90;
this.bopMaxHeight = 230;
break;
case FOOTHILLS:
this.bopMinHeight = 30;
this.bopMaxHeight = 160;
break;
}
this.sidewaysNoiseAmount = 0.22F;
this.setOctaveWeights(1, 1, 2, 2, 3, 2);
this.setColor(0x80A355);
this.setTemperatureRainfall(0.25F, 0.1F);
this.addWeight(BiomeType.COOL, 10);
if (type == MountainType.PEAKS)
{
// peaks are created in the biome gen layer, foothills don't have a weight - they only appear later around the peaks (in the biome edge layer)
this.addWeight(BiomeType.COOL, 10);
// only sheep and wolves on the peaks
this.spawnableCreatureList.clear();
this.spawnableCreatureList.add(new BiomeGenBase.SpawnListEntry(EntitySheep.class, 12, 4, 6));
this.spawnableCreatureList.add(new BiomeGenBase.SpawnListEntry(EntityWolf.class, 4, 4, 4));
}
this.topBlock = Blocks.grass.getDefaultState();
this.fillerBlock = Blocks.dirt.getDefaultState();
@ -78,7 +104,7 @@ public class BiomeGenMountain extends BOPBiome
this.addGenerator("lakes", GeneratorStage.SAND, (new GeneratorLakes.Builder()).amountPerChunk(0.8F).waterLakeForBiome(this).create());
// trees
IBlockPosQuery suitableTreePosition = new BlockPosQueryAnd(new BlockPosQueryAltitude(40, 150), new BlockPosQueryOr(new BlockQueryMaterial(Material.ground), new BlockQueryMaterial(Material.grass)));
IBlockPosQuery suitableTreePosition = new BlockPosQueryAnd(new BlockPosQueryAltitude(40, 140), new BlockPosQueryOr(new BlockQueryMaterial(Material.ground), new BlockQueryMaterial(Material.grass)));
GeneratorWeighted treeGenerator = new GeneratorWeighted(6);
this.addGenerator("trees", GeneratorStage.TREE, treeGenerator);
treeGenerator.add("pine", 1, (new GeneratorPineTree.Builder()).minHeight(6).maxHeight(18).placeOn(suitableTreePosition).create());
@ -159,7 +185,7 @@ public class BiomeGenMountain extends BOPBiome
this.topBlock = this.coarseDirtBlock;
this.fillerBlock = this.coarseDirtBlock;
}
else if (noise > 1.7D)
else if (this.type == MountainType.PEAKS && noise > 1.7D)
{
this.topBlock = this.stoneBlock;
this.fillerBlock = this.stoneBlock;

View file

@ -138,6 +138,8 @@ public class ModBiomes
private static void registerBiomes()
{
// normal biomes which have weights
alps = registerBOPBiome(new BiomeGenAlps(), "Alps");
arctic = registerBOPBiome(new BiomeGenArctic(), "Arctic");
crag = registerBOPBiome(new BiomeGenCrag(), "Crag");
@ -150,7 +152,7 @@ public class ModBiomes
lavenderFields = registerBOPBiome(new BiomeGenLavenderFields(), "Lavender Fields");
marsh = registerBOPBiome(new BiomeGenMarsh(), "Marsh");
moor = registerBOPBiome(new BiomeGenMoor(), "Moor");
mountain = registerBOPBiome(new BiomeGenMountain(), "Mountain");
mountain = registerBOPBiome(new BiomeGenMountain(BiomeGenMountain.MountainType.PEAKS), "Mountain");
originValley = registerBOPBiome(new BiomeGenOriginValley(), "Origin Valley");
outback = registerBOPBiome(new BiomeGenOutback(), "Outback");
shrubland = registerBOPBiome(new BiomeGenShrubland(), "Shrubland");
@ -159,8 +161,9 @@ public class ModBiomes
tundra = registerBOPBiome(new BiomeGenTundra(), "Tundra");
woodland = registerBOPBiome(new BiomeGenWoodland(), "Woodland");
// sub biomes
// edge-biomes, sub-biomes and mutated-biomes
mountainFoothills = registerBOPBiome(new BiomeGenMountain(BiomeGenMountain.MountainType.FOOTHILLS), "Mountain Foothills");
glacier = registerBOPBiome(new BiomeGenGlacier(), "Glacier"); // TODO: implement glacier
setSubBiome(Optional.of(BiomeGenBase.frozenOcean), arctic); // add some arctic regions in frozen oceans

View file

@ -8,6 +8,9 @@
package biomesoplenty.common.world.layer;
import com.google.common.base.Optional;
import biomesoplenty.api.biome.BOPBiomes;
import net.minecraft.world.biome.BiomeGenBase;
import net.minecraft.world.gen.layer.GenLayer;
import net.minecraft.world.gen.layer.IntCache;
@ -33,58 +36,71 @@ public class GenLayerBiomeEdgeBOP extends GenLayer
{
this.initChunkSeed((long)(x + areaX), (long)(y + areaY));
int biomeId = parentVals[x + 1 + (y + 1) * (areaWidth + 2)];
// line BOP mountain peaks with BOP mountain foothills
if (this.replaceBiomeEdge(parentVals, out, x, y, areaWidth, biomeId, BOPBiomes.mountain, BOPBiomes.mountainFoothills)) {continue;}
// line extreme hills with extreme hills edge
if (this.replaceBiomeEdgeIfNecessary(parentVals, out, x, y, areaWidth, biomeId, BiomeGenBase.extremeHills.biomeID, BiomeGenBase.extremeHillsEdge.biomeID)) {continue;}
// line mesa plateau with mesa
if (this.replaceBiomeEdge(parentVals, out, x, y, areaWidth, biomeId, BiomeGenBase.mesaPlateau_F.biomeID, BiomeGenBase.mesa.biomeID)) {continue;}
if (this.replaceBiomeEdge(parentVals, out, x, y, areaWidth, biomeId, BiomeGenBase.mesaPlateau.biomeID, BiomeGenBase.mesa.biomeID)) {continue;}
// line mega taiga with ordinary taiga
if (this.replaceBiomeEdge(parentVals, out, x, y, areaWidth, biomeId, BiomeGenBase.megaTaiga.biomeID, BiomeGenBase.taiga.biomeID)) {continue;}
int northBiomeId;
int eastBiomeId;
int westBiomeId;
int southBiomeId;
if (!this.replaceBiomeEdgeIfNecessary(parentVals, out, x, y, areaWidth, biomeId, BiomeGenBase.extremeHills.biomeID, BiomeGenBase.extremeHillsEdge.biomeID) && !this.replaceBiomeEdge(parentVals, out, x, y, areaWidth, biomeId, BiomeGenBase.mesaPlateau_F.biomeID, BiomeGenBase.mesa.biomeID) && !this.replaceBiomeEdge(parentVals, out, x, y, areaWidth, biomeId, BiomeGenBase.mesaPlateau.biomeID, BiomeGenBase.mesa.biomeID) && !this.replaceBiomeEdge(parentVals, out, x, y, areaWidth, biomeId, BiomeGenBase.megaTaiga.biomeID, BiomeGenBase.taiga.biomeID))
if (biomeId == BiomeGenBase.desert.biomeID)
{
int northBiomeId;
int eastBiomeId;
int westBiomeId;
int southBiomeId;
// if desert is next to ice plains turn it into extremeGillsPlus (separate the ice and desert with a big mountain)
northBiomeId = parentVals[x + 1 + (y + 1 - 1) * (areaWidth + 2)];
eastBiomeId = parentVals[x + 1 + 1 + (y + 1) * (areaWidth + 2)];
westBiomeId = parentVals[x + 1 - 1 + (y + 1) * (areaWidth + 2)];
southBiomeId = parentVals[x + 1 + (y + 1 + 1) * (areaWidth + 2)];
if (biomeId == BiomeGenBase.desert.biomeID)
if (northBiomeId != BiomeGenBase.icePlains.biomeID && eastBiomeId != BiomeGenBase.icePlains.biomeID && westBiomeId != BiomeGenBase.icePlains.biomeID && southBiomeId != BiomeGenBase.icePlains.biomeID)
{
northBiomeId = parentVals[x + 1 + (y + 1 - 1) * (areaWidth + 2)];
eastBiomeId = parentVals[x + 1 + 1 + (y + 1) * (areaWidth + 2)];
westBiomeId = parentVals[x + 1 - 1 + (y + 1) * (areaWidth + 2)];
southBiomeId = parentVals[x + 1 + (y + 1 + 1) * (areaWidth + 2)];
out[x + y * areaWidth] = biomeId;
}
else
{
out[x + y * areaWidth] = BiomeGenBase.extremeHillsPlus.biomeID;
}
}
else if (biomeId == BiomeGenBase.swampland.biomeID)
{
// if swamp is next to desert, cold taiga or ice planes, turn it into plains
// if swamp is next to jungle, turn it into jungle edge
northBiomeId = parentVals[x + 1 + (y + 1 - 1) * (areaWidth + 2)];
eastBiomeId = parentVals[x + 1 + 1 + (y + 1) * (areaWidth + 2)];
westBiomeId = parentVals[x + 1 - 1 + (y + 1) * (areaWidth + 2)];
southBiomeId = parentVals[x + 1 + (y + 1 + 1) * (areaWidth + 2)];
if (northBiomeId != BiomeGenBase.icePlains.biomeID && eastBiomeId != BiomeGenBase.icePlains.biomeID && westBiomeId != BiomeGenBase.icePlains.biomeID && southBiomeId != BiomeGenBase.icePlains.biomeID)
if (northBiomeId != BiomeGenBase.desert.biomeID && eastBiomeId != BiomeGenBase.desert.biomeID && westBiomeId != BiomeGenBase.desert.biomeID && southBiomeId != BiomeGenBase.desert.biomeID && northBiomeId != BiomeGenBase.coldTaiga.biomeID && eastBiomeId != BiomeGenBase.coldTaiga.biomeID && westBiomeId != BiomeGenBase.coldTaiga.biomeID && southBiomeId != BiomeGenBase.coldTaiga.biomeID && northBiomeId != BiomeGenBase.icePlains.biomeID && eastBiomeId != BiomeGenBase.icePlains.biomeID && westBiomeId != BiomeGenBase.icePlains.biomeID && southBiomeId != BiomeGenBase.icePlains.biomeID)
{
if (northBiomeId != BiomeGenBase.jungle.biomeID && southBiomeId != BiomeGenBase.jungle.biomeID && eastBiomeId != BiomeGenBase.jungle.biomeID && westBiomeId != BiomeGenBase.jungle.biomeID)
{
out[x + y * areaWidth] = biomeId;
}
else
{
out[x + y * areaWidth] = BiomeGenBase.extremeHillsPlus.biomeID;
}
}
else if (biomeId == BiomeGenBase.swampland.biomeID)
{
northBiomeId = parentVals[x + 1 + (y + 1 - 1) * (areaWidth + 2)];
eastBiomeId = parentVals[x + 1 + 1 + (y + 1) * (areaWidth + 2)];
westBiomeId = parentVals[x + 1 - 1 + (y + 1) * (areaWidth + 2)];
southBiomeId = parentVals[x + 1 + (y + 1 + 1) * (areaWidth + 2)];
if (northBiomeId != BiomeGenBase.desert.biomeID && eastBiomeId != BiomeGenBase.desert.biomeID && westBiomeId != BiomeGenBase.desert.biomeID && southBiomeId != BiomeGenBase.desert.biomeID && northBiomeId != BiomeGenBase.coldTaiga.biomeID && eastBiomeId != BiomeGenBase.coldTaiga.biomeID && westBiomeId != BiomeGenBase.coldTaiga.biomeID && southBiomeId != BiomeGenBase.coldTaiga.biomeID && northBiomeId != BiomeGenBase.icePlains.biomeID && eastBiomeId != BiomeGenBase.icePlains.biomeID && westBiomeId != BiomeGenBase.icePlains.biomeID && southBiomeId != BiomeGenBase.icePlains.biomeID)
{
if (northBiomeId != BiomeGenBase.jungle.biomeID && southBiomeId != BiomeGenBase.jungle.biomeID && eastBiomeId != BiomeGenBase.jungle.biomeID && westBiomeId != BiomeGenBase.jungle.biomeID)
{
out[x + y * areaWidth] = biomeId;
}
else
{
out[x + y * areaWidth] = BiomeGenBase.jungleEdge.biomeID;
}
}
else
{
out[x + y * areaWidth] = BiomeGenBase.plains.biomeID;
out[x + y * areaWidth] = BiomeGenBase.jungleEdge.biomeID;
}
}
else
{
out[x + y * areaWidth] = biomeId;
out[x + y * areaWidth] = BiomeGenBase.plains.biomeID;
}
}
else
{
out[x + y * areaWidth] = biomeId;
}
}
}
@ -117,6 +133,11 @@ public class GenLayerBiomeEdgeBOP extends GenLayer
}
}
private boolean replaceBiomeEdge(int[] parentVals, int[] out, int x, int y, int areaWidth, int biomeId, Optional<BiomeGenBase> fromBiome, Optional<BiomeGenBase> toBiome)
{
return fromBiome.isPresent() && toBiome.isPresent() && this.replaceBiomeEdge(parentVals, out, x, y, areaWidth, biomeId, fromBiome.get().biomeID, toBiome.get().biomeID);
}
private boolean replaceBiomeEdge(int[] parentVals, int[] out, int x, int y, int areaWidth, int biomeId, int fromBiomeId, int toBiomeId)
{
if (biomeId != fromBiomeId)