Add Boreal Forest biome
This commit is contained in:
parent
abe80e28e1
commit
d2a5db2bbb
5 changed files with 138 additions and 67 deletions
|
@ -20,6 +20,7 @@ public class BOPBiomes
|
|||
public static Optional<BiomeGenBase> bamboo_forest = Optional.absent();
|
||||
public static Optional<BiomeGenBase> bayou = Optional.absent();
|
||||
public static Optional<BiomeGenBase> bog = Optional.absent();
|
||||
public static Optional<BiomeGenBase> boreal_forest = Optional.absent();
|
||||
public static Optional<BiomeGenBase> crag = Optional.absent();
|
||||
public static Optional<BiomeGenBase> chaparral = Optional.absent();
|
||||
public static Optional<BiomeGenBase> denseForest = Optional.absent();
|
||||
|
|
|
@ -0,0 +1,92 @@
|
|||
package biomesoplenty.common.biome.overworld;
|
||||
|
||||
import net.minecraft.block.BlockDoublePlant;
|
||||
import net.minecraft.block.BlockPlanks;
|
||||
import net.minecraft.block.BlockTallGrass;
|
||||
import net.minecraft.entity.passive.EntityWolf;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraftforge.common.BiomeManager.BiomeType;
|
||||
import biomesoplenty.api.biome.BOPBiome;
|
||||
import biomesoplenty.api.biome.generation.GeneratorStage;
|
||||
import biomesoplenty.api.biome.generation.GeneratorWeighted;
|
||||
import biomesoplenty.common.block.BlockBOPDoublePlant;
|
||||
import biomesoplenty.common.block.BlockBOPLilypad;
|
||||
import biomesoplenty.common.enums.BOPGems;
|
||||
import biomesoplenty.common.enums.BOPPlants;
|
||||
import biomesoplenty.common.enums.BOPTrees;
|
||||
import biomesoplenty.common.world.feature.GeneratorDoubleFlora;
|
||||
import biomesoplenty.common.world.feature.GeneratorFlora;
|
||||
import biomesoplenty.common.world.feature.GeneratorGrass;
|
||||
import biomesoplenty.common.world.feature.GeneratorOreSingle;
|
||||
import biomesoplenty.common.world.feature.GeneratorWaterside;
|
||||
import biomesoplenty.common.world.feature.tree.GeneratorBasicTree;
|
||||
import biomesoplenty.common.world.feature.tree.GeneratorBush;
|
||||
import biomesoplenty.common.world.feature.tree.GeneratorTaigaTree;
|
||||
|
||||
public class BiomeGenBorealForest extends BOPBiome
|
||||
{
|
||||
public BiomeGenBorealForest()
|
||||
{
|
||||
// terrain
|
||||
this.bopMinHeight = 57;
|
||||
this.bopMaxHeight = 100;
|
||||
|
||||
this.setColor(0x9FB771);
|
||||
this.setTemperatureRainfall(0.5F, 0.6F);
|
||||
this.addWeight(BiomeType.COOL, 10);
|
||||
|
||||
|
||||
this.spawnableCreatureList.add(new SpawnListEntry(EntityWolf.class, 5, 4, 4));
|
||||
|
||||
// gravel
|
||||
this.addGenerator("gravel", GeneratorStage.SAND_PASS2, (new GeneratorWaterside.Builder()).amountPerChunk(6).maxRadius(7).with(Blocks.gravel.getDefaultState()).create());
|
||||
|
||||
// trees & logs
|
||||
GeneratorWeighted treeGenerator = new GeneratorWeighted(20);
|
||||
this.addGenerator("trees", GeneratorStage.TREE, treeGenerator);
|
||||
treeGenerator.add("small_oak", 2, (new GeneratorBasicTree.Builder()).create());
|
||||
treeGenerator.add("oak", 3, (new GeneratorBasicTree.Builder()).minHeight(8).maxHeight(12).create());
|
||||
treeGenerator.add("oak_bush", 3, (new GeneratorBush.Builder()).amountPerChunk(3).create());
|
||||
treeGenerator.add("yellow_autumn", 4, (new GeneratorBasicTree.Builder()).log(BlockPlanks.EnumType.BIRCH).leaves(BOPTrees.YELLOW_AUTUMN).minHeight(5).maxHeight(8).create());
|
||||
treeGenerator.add("spruce", 4, (new GeneratorTaigaTree.Builder()).minHeight(10).maxHeight(19).create()); // TODO: implement pine cones
|
||||
|
||||
// grasses
|
||||
GeneratorWeighted grassGenerator = new GeneratorWeighted(10.0F);
|
||||
this.addGenerator("grass", GeneratorStage.GRASS, grassGenerator);
|
||||
grassGenerator.add("wheatgrass", 1, (new GeneratorGrass.Builder()).with(BOPPlants.WHEATGRASS).create());
|
||||
grassGenerator.add("dampgrass", 1, (new GeneratorGrass.Builder()).with(BOPPlants.DAMPGRASS).create());
|
||||
grassGenerator.add("tallgrass", 2, (new GeneratorGrass.Builder()).with(BlockTallGrass.EnumType.GRASS).create());
|
||||
grassGenerator.add("fern", 4, (new GeneratorGrass.Builder()).with(BlockTallGrass.EnumType.FERN).create());
|
||||
|
||||
// flowers
|
||||
GeneratorWeighted flowerGenerator = new GeneratorWeighted(0.5F);
|
||||
this.addGenerator("flowers", GeneratorStage.GRASS, flowerGenerator);
|
||||
flowerGenerator.add("rose", 2, (new GeneratorDoubleFlora.Builder().with(BlockDoublePlant.EnumPlantType.ROSE).create()));
|
||||
|
||||
// other plants
|
||||
this.addGenerator("shrubs", GeneratorStage.FLOWERS,(new GeneratorFlora.Builder()).amountPerChunk(1.0F).with(BOPPlants.SHRUB).create());
|
||||
this.addGenerator("dead_leaf_piles", GeneratorStage.FLOWERS,(new GeneratorFlora.Builder()).amountPerChunk(1.0F).with(BOPPlants.DEADLEAFPILE).create());
|
||||
this.addGenerator("flax", GeneratorStage.FLOWERS, (new GeneratorDoubleFlora.Builder()).amountPerChunk(0.2F).with(BlockBOPDoublePlant.DoublePlantType.FLAX).create());
|
||||
|
||||
// water plants
|
||||
this.addGenerator("duckweed", GeneratorStage.LILYPAD, (new GeneratorFlora.Builder()).amountPerChunk(1.0F).with(BlockBOPLilypad.LilypadType.DUCKWEED).generationAttempts(32).create());
|
||||
this.addGenerator("water_reeds", GeneratorStage.LILYPAD, (new GeneratorFlora.Builder()).amountPerChunk(2.0F).with(BOPPlants.REED).generationAttempts(32).create());
|
||||
|
||||
// gem
|
||||
this.addGenerator("amber", GeneratorStage.SAND, (new GeneratorOreSingle.Builder()).amountPerChunk(12).with(BOPGems.AMBER).create());
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getGrassColorAtPos(BlockPos pos)
|
||||
{
|
||||
return 0x9FB771;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFoliageColorAtPos(BlockPos pos)
|
||||
{
|
||||
return 0xC9CE65;
|
||||
}
|
||||
}
|
|
@ -145,6 +145,7 @@ public class ModBiomes
|
|||
bamboo_forest = registerBOPBiome(new BiomeGenBambooForest(), "Bamboo Forest");
|
||||
bayou = registerBOPBiome(new BiomeGenBayou(), "Bayou");
|
||||
bog = registerBOPBiome(new BiomeGenBog(), "Bog");
|
||||
boreal_forest = registerBOPBiome(new BiomeGenBorealForest(), "Boreal Forest");
|
||||
crag = registerBOPBiome(new BiomeGenCrag(), "Crag");
|
||||
chaparral = registerBOPBiome(new BiomeGenChaparral(), "Chaparral");
|
||||
denseForest = registerBOPBiome(new BiomeGenDenseForest(), "Dense Forest");
|
||||
|
|
|
@ -27,7 +27,7 @@ public class ModGenerators
|
|||
registerGenerator("pine_tree", GeneratorPineTree.class, new GeneratorPineTree.Builder());
|
||||
registerGenerator("bulb_tree", GeneratorBulbTree.class, new GeneratorBulbTree.Builder());
|
||||
registerGenerator("bayou_tree", GeneratorBayouTree.class, new GeneratorBayouTree.Builder());
|
||||
registerGenerator("cypress_tree", GeneratorCypressTree.class, new GeneratorCypressTree.Builder());
|
||||
registerGenerator("taiga_tree", GeneratorTaigaTree.class, new GeneratorTaigaTree.Builder());
|
||||
registerGenerator("flora", GeneratorFlora.class, new GeneratorFlora.Builder());
|
||||
registerGenerator("double_flora", GeneratorDoubleFlora.class, new GeneratorDoubleFlora.Builder());
|
||||
registerGenerator("grass", GeneratorGrass.class, new GeneratorGrass.Builder());
|
||||
|
|
|
@ -13,15 +13,18 @@ import biomesoplenty.api.block.BlockQueries;
|
|||
import biomesoplenty.common.util.biome.GeneratorUtils;
|
||||
import biomesoplenty.common.util.block.BlockQuery.IBlockPosQuery;
|
||||
import biomesoplenty.common.util.config.BOPConfig.IConfigObj;
|
||||
import net.minecraft.block.BlockOldLeaf;
|
||||
import net.minecraft.block.BlockOldLog;
|
||||
import net.minecraft.block.BlockPlanks;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class GeneratorCypressTree extends GeneratorTreeBase
|
||||
public class GeneratorTaigaTree extends GeneratorTreeBase
|
||||
{
|
||||
|
||||
public static class Builder extends GeneratorTreeBase.InnerBuilder<Builder, GeneratorCypressTree> implements IGeneratorBuilder<GeneratorCypressTree>
|
||||
// TODO: fruit
|
||||
public static class Builder extends GeneratorTreeBase.InnerBuilder<Builder, GeneratorTaigaTree> implements IGeneratorBuilder<GeneratorTaigaTree>
|
||||
{
|
||||
public Builder()
|
||||
{
|
||||
|
@ -30,25 +33,23 @@ public class GeneratorCypressTree extends GeneratorTreeBase
|
|||
this.maxHeight = 12;
|
||||
this.placeOn = BlockQueries.fertile;
|
||||
this.replace = BlockQueries.airOrLeaves;
|
||||
this.log = Blocks.log.getDefaultState();
|
||||
this.leaves = Blocks.leaves.getDefaultState();
|
||||
this.log = Blocks.log.getDefaultState().withProperty(BlockOldLog.VARIANT, BlockPlanks.EnumType.SPRUCE);
|
||||
this.leaves = Blocks.leaves.getDefaultState().withProperty(BlockOldLeaf.VARIANT, BlockPlanks.EnumType.SPRUCE);
|
||||
this.vine = Blocks.vine.getDefaultState();
|
||||
}
|
||||
|
||||
@Override
|
||||
public GeneratorCypressTree create() {
|
||||
return new GeneratorCypressTree(this.amountPerChunk, this.placeOn, this.replace, this.log, this.leaves, this.vine, this.minHeight, this.maxHeight);
|
||||
public GeneratorTaigaTree create() {
|
||||
return new GeneratorTaigaTree(this.amountPerChunk, this.placeOn, this.replace, this.log, this.leaves, this.vine, this.minHeight, this.maxHeight);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public GeneratorCypressTree(float amountPerChunk, IBlockPosQuery placeOn, IBlockPosQuery replace, IBlockState log, IBlockState leaves, IBlockState vine, int minHeight, int maxHeight)
|
||||
public GeneratorTaigaTree(float amountPerChunk, IBlockPosQuery placeOn, IBlockPosQuery replace, IBlockState log, IBlockState leaves, IBlockState vine, int minHeight, int maxHeight)
|
||||
{
|
||||
super(amountPerChunk, placeOn, replace, log, leaves, vine, minHeight, maxHeight);
|
||||
}
|
||||
|
||||
|
||||
public boolean checkSpace(World world, BlockPos pos, int baseHeight, int height)
|
||||
{
|
||||
for (int y = 0; y <= height; y++)
|
||||
|
@ -72,40 +73,20 @@ public class GeneratorCypressTree extends GeneratorTreeBase
|
|||
return true;
|
||||
}
|
||||
|
||||
// generates a layer of leafs, starting with radius minRadius and increasing to maxRadius, returns the next blockpos
|
||||
// generates a layer of leafs
|
||||
public void generateLeafLayer(World world, Random rand, BlockPos pos, int radius)
|
||||
{
|
||||
for (int x = -radius; x <= radius; x++)
|
||||
{
|
||||
for (int z = -radius; z <= radius; z++)
|
||||
{
|
||||
this.setLeaves(world, pos.add(x, 0, z));
|
||||
// skip corners
|
||||
if (Math.abs(x) < radius || Math.abs(z) < radius || radius == 0)
|
||||
{
|
||||
this.setLeaves(world, pos.add(x, 0, z));
|
||||
}
|
||||
}
|
||||
}
|
||||
// add the trunk in the middle
|
||||
this.setLog(world, pos.add(0, 0, 0));
|
||||
}
|
||||
|
||||
|
||||
// generate the top of the tree (3 blocks)
|
||||
public void generateTop(World world, BlockPos pos)
|
||||
{
|
||||
for(int x = -1; x <= 1; x++)
|
||||
{
|
||||
for(int z = -1; z <= 1; z++)
|
||||
{
|
||||
this.setLeaves(world, pos.add(x, 0, z));
|
||||
}
|
||||
}
|
||||
this.setLog(world, pos);
|
||||
|
||||
pos = pos.up();
|
||||
this.setLeaves(world, pos);
|
||||
this.setLeaves(world, pos.north());
|
||||
this.setLeaves(world, pos.east());
|
||||
this.setLeaves(world, pos.south());
|
||||
this.setLeaves(world, pos.west());
|
||||
this.setLeaves(world, pos.up());
|
||||
}
|
||||
|
||||
|
||||
|
@ -124,54 +105,50 @@ public class GeneratorCypressTree extends GeneratorTreeBase
|
|||
|
||||
// Choose heights
|
||||
int height = GeneratorUtils.nextIntBetween(random, this.minHeight, this.maxHeight);
|
||||
int topHeight = 3;
|
||||
int baseHeight = 1 + random.nextInt(3);
|
||||
int leavesHeight = height - topHeight - baseHeight;
|
||||
if (leavesHeight < 0) {return false;}
|
||||
int leavesRadius = 1;
|
||||
int baseHeight = GeneratorUtils.nextIntBetween(random, height / 6, height / 3);
|
||||
int leavesHeight = height - baseHeight;
|
||||
if (leavesHeight < 3) {return false;}
|
||||
int leavesMaxRadius = 2 + random.nextInt(2);
|
||||
|
||||
// Start on the space above ground
|
||||
BlockPos pos = startPos.up();
|
||||
|
||||
if (!this.checkSpace(world, pos, baseHeight, height))
|
||||
if (!this.checkSpace(world, startPos.up(), baseHeight, height))
|
||||
{
|
||||
// Abandon if there isn't enough room
|
||||
return false;
|
||||
}
|
||||
|
||||
// Generate bottom of tree (trunk only)
|
||||
for(int i = 0; i < baseHeight; i++)
|
||||
{
|
||||
this.setLog(world, pos);
|
||||
pos = pos.up();
|
||||
}
|
||||
|
||||
// Generate middle of tree
|
||||
int minRadius = 0;
|
||||
// Start at the top of the tree
|
||||
BlockPos pos = startPos.up(height);
|
||||
|
||||
// Add layers of leaves
|
||||
int localMinRadius = 0;
|
||||
int radius = random.nextInt(2);
|
||||
int sectionRadius = 1;
|
||||
for (int y = 0; y < leavesHeight; y++)
|
||||
int localMaxRadius = 1;
|
||||
for (int i = 0; i < leavesHeight; i++)
|
||||
{
|
||||
this.generateLeafLayer(world, random, pos, radius);
|
||||
if (radius >= sectionRadius)
|
||||
if (radius < localMaxRadius)
|
||||
{
|
||||
radius = minRadius;
|
||||
if (minRadius == 0) {minRadius = 1;}
|
||||
if (sectionRadius < leavesRadius) {sectionRadius++;}
|
||||
radius++;
|
||||
} else {
|
||||
radius++;
|
||||
radius = localMinRadius;
|
||||
if (localMinRadius == 0) {localMinRadius = 1;}
|
||||
if (localMaxRadius < leavesMaxRadius) {localMaxRadius++;}
|
||||
}
|
||||
pos = pos.up();
|
||||
pos = pos.down();
|
||||
}
|
||||
|
||||
// Generate top of tree
|
||||
this.generateTop(world, pos);
|
||||
// Go back to the top of the tree and generate the trunk
|
||||
pos = startPos.up(height - 1);
|
||||
for(int i = 0; i < height - 1; i++)
|
||||
{
|
||||
this.setLog(world, pos);
|
||||
pos = pos.down();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void configure(IConfigObj conf)
|
||||
{
|
Loading…
Reference in a new issue