BiomesOPlenty/src/main/java/biomesoplenty/common/biome/overworld/BiomeGenMountain.java

134 lines
7.2 KiB
Java

/*******************************************************************************
* Copyright 2015-2016, the Biomes O' Plenty Team
*
* This work is licensed under a Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International Public License.
*
* To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-nd/4.0/.
******************************************************************************/
package biomesoplenty.common.biome.overworld;
import com.google.common.base.CaseFormat;
import biomesoplenty.api.block.BlockQueries;
import biomesoplenty.api.block.IBlockPosQuery;
import biomesoplenty.api.enums.BOPClimates;
import biomesoplenty.api.enums.BOPPlants;
import biomesoplenty.api.enums.BOPTrees;
import biomesoplenty.api.enums.BOPWoods;
import biomesoplenty.api.generation.GeneratorStage;
import biomesoplenty.common.block.BlockBOPDoublePlant;
import biomesoplenty.common.util.block.BlockQuery;
import biomesoplenty.common.world.generator.GeneratorDoubleFlora;
import biomesoplenty.common.world.generator.GeneratorFlora;
import biomesoplenty.common.world.generator.GeneratorGrass;
import biomesoplenty.common.world.generator.GeneratorLakes;
import biomesoplenty.common.world.generator.GeneratorOreSingle;
import biomesoplenty.common.world.generator.GeneratorWaterside;
import biomesoplenty.common.world.generator.GeneratorWeighted;
import biomesoplenty.common.world.generator.tree.GeneratorBasicTree;
import biomesoplenty.common.world.generator.tree.GeneratorPineTree;
import net.minecraft.block.BlockTallGrass;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.passive.EntityLlama;
import net.minecraft.entity.passive.EntitySheep;
import net.minecraft.entity.passive.EntityWolf;
import net.minecraft.init.Blocks;
import net.minecraft.world.biome.Biome;
import java.util.Locale;
public class BiomeGenMountain extends BOPOverworldBiome
{
public enum MountainType {MOUNTAIN, MOUNTAIN_FOOTHILLS}
public MountainType type;
public IBlockState grassBlock;
public IBlockState dirtBlock;
public IBlockState coarseDirtBlock;
public IBlockState stoneBlock;
public BiomeGenMountain(MountainType type)
{
super(type.name().toLowerCase(Locale.ENGLISH), new PropsBuilder(CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL, type.toString())).withGuiColour(0x80A355).withTemperature(0.5F).withRainfall(0.1F));
this.type = type;
this.canSpawnInBiome = false;
// terrain
switch (type)
{
case MOUNTAIN:
this.terrainSettings.avgHeight(140).heightVariation(30, 60).octaves(1, 1, 2, 2, 3, 3).sidewaysNoise(0.1D);
break;
case MOUNTAIN_FOOTHILLS:
this.terrainSettings.avgHeight(100).heightVariation(15, 30).octaves(0, 1, 1, 3, 1, 0).sidewaysNoise(0.1D);
this.hasBiomeEssence = false;
break;
}
this.canGenerateRivers = false;
this.canSpawnInBiome = false;
this.canGenerateVillages = false;
this.beachBiomeLocation = null;
if (type == MountainType.MOUNTAIN)
{
this.canGenerateVillages = false;
// 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(BOPClimates.DRY_TEMPERATE, 3);
// only sheep and wolves on the peaks
this.spawnableCreatureList.clear();
this.spawnableCreatureList.add(new SpawnListEntry(EntitySheep.class, 12, 4, 6));
this.spawnableCreatureList.add(new SpawnListEntry(EntityWolf.class, 4, 4, 4));
this.spawnableCreatureList.add(new SpawnListEntry(EntityLlama.class, 5, 4, 6));
}
this.topBlock = Blocks.GRASS.getDefaultState();
this.fillerBlock = Blocks.DIRT.getDefaultState();
// gravel
this.addGenerator("gravel", GeneratorStage.SAND_PASS2, (new GeneratorWaterside.Builder()).amountPerChunk(6).maxRadius(7).with(Blocks.GRAVEL.getDefaultState()).create());
// lakes
this.addGenerator("lakes", GeneratorStage.SAND, (new GeneratorLakes.Builder()).amountPerChunk(1.8F).waterLakeForBiome(this).create());
// trees & logs
IBlockPosQuery suitableTreePosition = BlockQuery.buildAnd().withAltitudeBetween(64, 140).materials(Material.GROUND, Material.GRASS).create();
GeneratorWeighted treeGenerator = new GeneratorWeighted(3);
this.addGenerator("trees", GeneratorStage.TREE, treeGenerator);
treeGenerator.add("pine", 2, (new GeneratorPineTree.Builder()).minHeight(6).maxHeight(18).log(BOPWoods.PINE).leaves(BOPTrees.PINE).placeOn(suitableTreePosition).create());
treeGenerator.add("oak", 1, (new GeneratorBasicTree.Builder()).create());
// grasses
GeneratorWeighted grassGenerator = new GeneratorWeighted(1.5F);
this.addGenerator("grass", GeneratorStage.GRASS, grassGenerator);
grassGenerator.add("tallgrass", 2, (new GeneratorGrass.Builder()).with(BlockTallGrass.EnumType.GRASS).generationAttempts(128).create());
grassGenerator.add("mediumgrass", 1, (new GeneratorGrass.Builder()).with(BOPPlants.MEDIUMGRASS).generationAttempts(128).create());
grassGenerator.add("shortgrass", 1, (new GeneratorGrass.Builder()).with(BOPPlants.SHORTGRASS).generationAttempts(128).create());
//grassGenerator.add("wheatgrass", 1, (new GeneratorGrass.Builder()).with(BOPPlants.WHEATGRASS).generationAttempts(128).create());
//grassGenerator.add("dampgrass", 1, (new GeneratorGrass.Builder()).with(BOPPlants.DAMPGRASS).generationAttempts(128).create());
// other plants
//this.addGenerator("shrubs", GeneratorStage.FLOWERS,(new GeneratorFlora.Builder()).amountPerChunk(0.1F).with(BOPPlants.SHRUB).generationAttempts(type == MountainType.MOUNTAIN_FOOTHILLS ? 64 : 32).create());
this.addGenerator("leaf_piles", GeneratorStage.FLOWERS,(new GeneratorFlora.Builder()).amountPerChunk(0.8F).placeOn(BlockQueries.fertile).with(BOPPlants.LEAFPILE).create());
this.addGenerator("dead_leaf_piles", GeneratorStage.FLOWERS,(new GeneratorFlora.Builder()).amountPerChunk(1.2F).placeOn(BlockQueries.fertile).with(BOPPlants.DEADLEAFPILE).create());
if (type == MountainType.MOUNTAIN_FOOTHILLS)
{
this.addGenerator("flax", GeneratorStage.FLOWERS, (new GeneratorDoubleFlora.Builder()).amountPerChunk(0.1F).with(BlockBOPDoublePlant.DoublePlantType.FLAX).create());
this.addGenerator("berry_bushes", GeneratorStage.FLOWERS,(new GeneratorFlora.Builder()).amountPerChunk(0.2F).with(BOPPlants.BERRYBUSH).create());
this.addGenerator("water_reeds", GeneratorStage.LILYPAD, (new GeneratorFlora.Builder()).amountPerChunk(0.4F).with(BOPPlants.REED).generationAttempts(32).create());
}
// gem
this.addGenerator("emeralds", GeneratorStage.SAND, (new GeneratorOreSingle.Builder()).amountPerChunk(12).with(Blocks.EMERALD_ORE.getDefaultState()).create());
}
}