Added the Steppe biome

This commit is contained in:
Adubbz 2015-04-10 10:19:40 +10:00
parent 9dca60f94c
commit 62a336a25c
10 changed files with 110 additions and 12 deletions

View file

@ -18,4 +18,5 @@ public class BOPBiomes
public static Optional<BiomeGenBase> arctic = Optional.absent();
public static Optional<BiomeGenBase> crag = Optional.absent();
public static Optional<BiomeGenBase> originValley = Optional.absent();
public static Optional<BiomeGenBase> steppe = Optional.absent();
}

View file

@ -8,13 +8,13 @@
package biomesoplenty.api.biome.generation;
public abstract class CustomizableGenerator implements IGenerator
public abstract class GeneratorCustomizable implements IGenerator
{
private final String identifier;
private String name;
private GeneratorStage stage;
protected CustomizableGenerator()
protected GeneratorCustomizable()
{
this.identifier = GeneratorRegistry.getIdentifier((Class<? extends IGenerator>)this.getClass());

View file

@ -21,7 +21,7 @@ import com.google.gson.JsonObject;
import com.google.gson.JsonSerializationContext;
import com.google.gson.reflect.TypeToken;
public class GeneratorWeighted extends CustomizableGenerator
public class GeneratorWeighted extends GeneratorCustomizable
{
private List<GeneratorWeightedEntry> weightedEntries = new ArrayList<GeneratorWeightedEntry>();

View file

@ -0,0 +1,57 @@
/*******************************************************************************
* Copyright 2015, 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 net.minecraft.entity.passive.EntityHorse;
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.block.BOPBlocks;
import biomesoplenty.common.block.BlockFoliage;
import biomesoplenty.common.block.BlockFoliage.FoliageType;
import biomesoplenty.common.block.BlockGem;
import biomesoplenty.common.block.BlockGem.GemType;
import biomesoplenty.common.world.feature.GeneratorGrass;
import biomesoplenty.common.world.feature.GeneratorOreSingle;
public class BiomeGenSteppe extends BOPBiome
{
private static final Height biomeHeight = new Height(0.1F, 0.4F);
public BiomeGenSteppe()
{
this.setHeight(biomeHeight);
this.setColor(13413215);
this.setTemperatureRainfall(0.7F, 0.05F);
this.addWeight(BiomeType.DESERT, 5);
this.spawnableCreatureList.add(new SpawnListEntry(EntityHorse.class, 5, 2, 6));
this.addGenerator("dead_bushes", GeneratorStage.DEAD_BUSH, new GeneratorGrass(3, Blocks.deadbush.getDefaultState(), 4));
this.addGenerator("grass", GeneratorStage.GRASS, new GeneratorGrass(15, BOPBlocks.foliage.getDefaultState().withProperty(BlockFoliage.VARIANT, FoliageType.SHORTGRASS)));
this.addGenerator("ruby", GeneratorStage.SAND, new GeneratorOreSingle(BOPBlocks.gem_ore.getDefaultState().withProperty(BlockGem.VARIANT, GemType.RUBY), 12, 4, 32));
}
@Override
public int getGrassColorAtPos(BlockPos pos)
{
double noise = field_180281_af.func_151601_a((double)pos.getX() * 0.0225D, (double)pos.getZ() * 0.0225D);
return noise < -0.1D ? 13214328 : 12885629;
}
@Override
public int getFoliageColorAtPos(BlockPos pos)
{
double noise = field_180281_af.func_151601_a((double)pos.getX() * 0.0225D, (double)pos.getZ() * 0.0225D);
return noise < -0.1D ? 13214328 : 12885629;
}
}

View file

@ -21,6 +21,7 @@ import biomesoplenty.common.biome.overworld.BiomeGenAlps;
import biomesoplenty.common.biome.overworld.BiomeGenArctic;
import biomesoplenty.common.biome.overworld.BiomeGenCrag;
import biomesoplenty.common.biome.overworld.BiomeGenOriginValley;
import biomesoplenty.common.biome.overworld.BiomeGenSteppe;
import biomesoplenty.common.command.BOPCommand;
import biomesoplenty.common.util.config.JsonBiome;
import biomesoplenty.common.world.WorldTypeBOP;
@ -49,6 +50,7 @@ public class ModBiomes
arctic = registerBiome(new BiomeGenArctic().setBiomeName("Arctic"), "arctic");
crag = registerBiome(new BiomeGenCrag().setBiomeName("Crag"), "crag");
originValley = registerBiome(new BiomeGenOriginValley().setBiomeName("Origin Valley"), "origin_valley");
steppe = registerBiome(new BiomeGenSteppe().setBiomeName("Steppe"), "steppe");
}
private static void registerExternalBiomes()

View file

@ -19,12 +19,12 @@ import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.util.BlockPos;
import net.minecraft.world.World;
import biomesoplenty.api.biome.generation.CustomizableGenerator;
import biomesoplenty.api.biome.generation.GeneratorCustomizable;
import biomesoplenty.api.biome.generation.GeneratorWeightedEntry;
import biomesoplenty.common.block.BlockDecoration;
import biomesoplenty.common.util.biome.GeneratorUtils;
public class GeneratorFlora extends CustomizableGenerator
public class GeneratorFlora extends GeneratorCustomizable
{
protected int amountPerChunk;
protected IBlockState state;

View file

@ -10,7 +10,12 @@ package biomesoplenty.common.world.feature;
import java.util.Random;
import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonObject;
import com.google.gson.JsonSerializationContext;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.util.BlockPos;
import net.minecraft.world.World;
import biomesoplenty.common.block.BlockDecoration;
@ -18,6 +23,22 @@ import biomesoplenty.common.util.biome.GeneratorUtils;
public class GeneratorGrass extends GeneratorFlora
{
private int generationAttempts;
public GeneratorGrass() {}
public GeneratorGrass(int amountPerChunk, IBlockState state, int generationAttempts)
{
super(amountPerChunk, state);
this.generationAttempts = generationAttempts;
}
public GeneratorGrass(int amountPerChunk, IBlockState state)
{
this(amountPerChunk, state, 128);
}
@Override
public void scatter(World world, Random random, BlockPos pos)
{
@ -37,6 +58,7 @@ public class GeneratorGrass extends GeneratorFlora
public boolean generate(World world, Random random, BlockPos pos)
{
Block block;
Block stateBlock = this.state.getBlock();
do
{
@ -46,10 +68,10 @@ public class GeneratorGrass extends GeneratorFlora
}
while (pos.getY() > 0);
for (int i = 0; i < 128; i++)
for (int i = 0; i < this.generationAttempts; i++)
{
BlockPos genPos = pos.add(random.nextInt(8) - random.nextInt(8), random.nextInt(4) - random.nextInt(4), random.nextInt(8) - random.nextInt(8));
boolean canStay = block instanceof BlockDecoration ? ((BlockDecoration)block).canBlockStay(world, genPos, this.state) : block.canPlaceBlockAt(world, genPos);
boolean canStay = stateBlock instanceof BlockDecoration ? ((BlockDecoration)stateBlock).canBlockStay(world, genPos, this.state) : stateBlock.canPlaceBlockAt(world, genPos);
if (world.isAirBlock(genPos) && canStay)
{
@ -59,4 +81,20 @@ public class GeneratorGrass extends GeneratorFlora
return true;
}
@Override
public void writeToJson(JsonObject json, JsonSerializationContext context)
{
super.writeToJson(json, context);
json.addProperty("generation_attempts", this.generationAttempts);
}
@Override
public void readFromJson(JsonObject json, JsonDeserializationContext context)
{
super.readFromJson(json, context);
this.generationAttempts = json.get("generation_attempts").getAsInt();
}
}

View file

@ -15,14 +15,14 @@ import net.minecraft.world.World;
import org.apache.commons.lang3.tuple.Pair;
import biomesoplenty.api.biome.generation.CustomizableGenerator;
import biomesoplenty.api.biome.generation.GeneratorCustomizable;
import biomesoplenty.common.util.biome.GeneratorUtils;
import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonObject;
import com.google.gson.JsonSerializationContext;
public abstract class GeneratorOreBase extends CustomizableGenerator
public abstract class GeneratorOreBase extends GeneratorCustomizable
{
protected int amountPerChunk;
protected int minHeight;

View file

@ -16,7 +16,7 @@ import net.minecraft.init.Blocks;
import net.minecraft.util.BlockPos;
import net.minecraft.world.World;
import net.minecraft.world.gen.feature.WorldGenMinable;
import biomesoplenty.api.biome.generation.CustomizableGenerator;
import biomesoplenty.api.biome.generation.GeneratorCustomizable;
import com.google.common.base.Predicate;
import com.google.gson.JsonDeserializationContext;

View file

@ -22,7 +22,7 @@ import net.minecraft.world.World;
import org.apache.commons.lang3.tuple.Pair;
import biomesoplenty.api.biome.generation.CustomizableGenerator;
import biomesoplenty.api.biome.generation.GeneratorCustomizable;
import biomesoplenty.api.biome.generation.GeneratorWeightedEntry;
import biomesoplenty.common.util.biome.GeneratorUtils;
@ -30,7 +30,7 @@ import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonObject;
import com.google.gson.JsonSerializationContext;
public class GeneratorBasicTree extends CustomizableGenerator
public class GeneratorBasicTree extends GeneratorCustomizable
{
private int amountPerChunk;
private boolean updateNeighbours;