Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import java.util.List;

import net.minecraft.util.ResourceLocation;
import net.minecraft.world.biome.Biome.BiomeProperties;
import net.minecraftforge.common.BiomeDictionary;
import net.minecraftforge.common.BiomeDictionary.Type;
import thebetweenlands.api.entity.spawning.ICustomSpawnEntry;
Expand Down Expand Up @@ -50,7 +51,7 @@ public BiomeCoarseIslands() {
.setTemperature(0.8F)
.setRainfall(0.9F));
this.setWeight(16);
this.getBiomeGenerator().setDecorator(new BiomeDecoratorCoarseIslands(this))
this.getBiomeGenerator().setDecoratorFactory(BiomeDecoratorCoarseIslands::new)
.addFeature(new CoarseIslandsFeature())
.addFeature(new AlgaeFeature());
this.setFoliageColors(-1, 0xA8A800);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import java.util.List;

import net.minecraft.util.ResourceLocation;
import net.minecraft.world.biome.Biome.BiomeProperties;
import net.minecraftforge.common.BiomeDictionary;
import net.minecraftforge.common.BiomeDictionary.Type;
import thebetweenlands.api.entity.spawning.ICustomSpawnEntry;
Expand Down Expand Up @@ -51,7 +52,7 @@ public BiomeDeepWaters() {
.setRainfall(0.9F));

this.setWeight(12);
this.getBiomeGenerator().setDecorator(new BiomeDecoratorDeepWaters(this))
this.getBiomeGenerator().setDecoratorFactory(BiomeDecoratorDeepWaters::new)
.addFeature(new DeepWatersFeature())
.addFeature(new AlgaeFeature())
.addFeature(new CragSpiresFeature());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import net.minecraft.client.Minecraft;
import net.minecraft.entity.Entity;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.biome.Biome.BiomeProperties;
import net.minecraftforge.common.BiomeDictionary;
import net.minecraftforge.common.BiomeDictionary.Type;
import net.minecraftforge.fml.relauncher.Side;
Expand Down Expand Up @@ -60,7 +61,7 @@ public BiomeMarsh(int type) {
.addFeature(new PatchFeature(0.03125D * 6.5D, 0.03125D * 6.5D, BlockRegistry.PEAT_SMOULDERING.getDefaultState(), 0.625D, 3.0D))
.addFeature(new PatchFeature(0.03125D * 5.5D, 0.03125D * 5.5D, BlockRegistry.MUD.getDefaultState()))
.addFeature(new PatchFeature(0.03125D * 8.5D, 0.03125D * 8.5D, BlockRegistry.MUD.getDefaultState()))
.setDecorator(new BiomeDecoratorMarsh(this));
.setDecoratorFactory(BiomeDecoratorMarsh::new);
this.setFoliageColors(0x627017, 0x63B581);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import java.util.List;

import net.minecraft.util.ResourceLocation;
import net.minecraft.world.biome.Biome.BiomeProperties;
import net.minecraftforge.common.BiomeDictionary;
import net.minecraftforge.common.BiomeDictionary.Type;
import thebetweenlands.api.entity.spawning.ICustomSpawnEntry;
Expand Down Expand Up @@ -56,7 +57,7 @@ public BiomePatchyIslands() {
.setRainfall(0.9F));

this.setWeight(20);
this.getBiomeGenerator().setDecorator(new BiomeDecoratorPatchyIslands(this))
this.getBiomeGenerator().setDecoratorFactory(BiomeDecoratorPatchyIslands::new)
.addFeature(new SiltBeachFeature())
.addFeature(new AlgaeFeature());
this.setFoliageColors(0x1FC66D, 0x00AD7C);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import java.util.List;

import net.minecraft.util.ResourceLocation;
import net.minecraft.world.biome.Biome.BiomeProperties;
import net.minecraftforge.common.BiomeDictionary;
import net.minecraftforge.common.BiomeDictionary.Type;
import thebetweenlands.api.entity.spawning.ICustomSpawnEntry;
Expand Down Expand Up @@ -50,7 +51,7 @@ public BiomeRaisedIsles() {
.setTemperature(0.8F)
.setRainfall(0.9F));
this.setWeight(16);
this.getBiomeGenerator().setDecorator(new BiomeDecoratorRaisedIsles(this))
this.getBiomeGenerator().setDecoratorFactory(BiomeDecoratorRaisedIsles::new)
.addFeature(new CoarseIslandsFeature())
.addFeature(new AlgaeFeature());
this.setFoliageColors(-1, 0xA8A800);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import java.util.List;

import net.minecraft.util.ResourceLocation;
import net.minecraft.world.biome.Biome.BiomeProperties;
import net.minecraftforge.common.BiomeDictionary;
import net.minecraftforge.common.BiomeDictionary.Type;
import thebetweenlands.api.entity.spawning.ICustomSpawnEntry;
Expand Down Expand Up @@ -48,7 +49,7 @@ public BiomeSludgePlains() {
.setRainfall(0.9F));

this.setWeight(5);
this.getBiomeGenerator().setTopBlockState(BlockRegistry.MUD.getDefaultState()).setFillerBlockHeight(1).setDecorator(new BiomeDecoratorSludgePlains(this))
this.getBiomeGenerator().setTopBlockState(BlockRegistry.MUD.getDefaultState()).setFillerBlockHeight(1).setDecoratorFactory(BiomeDecoratorSludgePlains::new)
.addFeature(new FlatLandFeature(WorldProviderBetweenlands.LAYER_HEIGHT, 5))
.addFeature(new PatchFeature(0.03125D * 5.75D, 0.03125D * 5.75D, BlockRegistry.SLUDGY_DIRT.getDefaultState()))
.addFeature(new PatchFeature(0.74D, 0.74D, BlockRegistry.SWAMP_DIRT.getDefaultState()))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import java.util.List;

import net.minecraft.util.ResourceLocation;
import net.minecraft.world.biome.Biome.BiomeProperties;
import net.minecraftforge.common.BiomeDictionary;
import net.minecraftforge.common.BiomeDictionary.Type;
import thebetweenlands.api.entity.spawning.ICustomSpawnEntry;
Expand Down Expand Up @@ -45,7 +46,8 @@ public BiomeSludgePlainsClearing() {
.setRainfall(0.9F));

this.setWeight(0);
this.getBiomeGenerator().setTopBlockState(BlockRegistry.COMPACTED_MUD.getDefaultState()).setFillerBlockHeight(1).setDecorator(new BiomeDecoratorSludgePlainsClearing(this))
this.getBiomeGenerator().setTopBlockState(BlockRegistry.COMPACTED_MUD.getDefaultState()).setFillerBlockHeight(1)
.setDecoratorFactory(BiomeDecoratorSludgePlainsClearing::new)
.addFeature(new PatchFeature(0.03125D * 5.75D, 0.03125D * 5.75D, BlockRegistry.SLUDGY_DIRT.getDefaultState()))
.addFeature(new PatchFeature(0.74D, 0.74D, BlockRegistry.SWAMP_DIRT.getDefaultState()))
.addFeature(new PatchFeature(0.65D, 0.65D, BlockRegistry.MUD.getDefaultState(), 1.0D / 1.35D, 1.72D));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import java.util.List;

import net.minecraft.util.ResourceLocation;
import net.minecraft.world.biome.Biome.BiomeProperties;
import net.minecraftforge.common.BiomeDictionary;
import net.minecraftforge.common.BiomeDictionary.Type;
import thebetweenlands.api.entity.spawning.ICustomSpawnEntry;
Expand Down Expand Up @@ -66,7 +67,7 @@ public BiomeSwamplands() {
.addFeature(new PatchFeature(0.65D, 0.65D, BlockRegistry.MUD.getDefaultState(), 1.0D / 1.35D, 1.72D))
.addFeature(new AlgaeFeature())
.addFeature(new SiltBeachFeature(0.98F))
.setDecorator(new BiomeDecoratorSwamplands(this));
.setDecoratorFactory(BiomeDecoratorSwamplands::new);
this.setFoliageColors(0x2AFF00, 0x52AF5A);
this.setSecondaryFoliageColors(0x50a040, 0x85af51);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package thebetweenlands.common.world.biome;

import net.minecraft.util.ResourceLocation;
import net.minecraft.world.biome.Biome.BiomeProperties;
import net.minecraftforge.common.BiomeDictionary;
import net.minecraftforge.common.BiomeDictionary.Type;
import thebetweenlands.common.lib.ModInfo;
Expand All @@ -20,7 +21,7 @@ public BiomeSwamplandsClearing() {

this.setWeight(0);
this.getBiomeGenerator().setFillerBlockState(BlockRegistry.SWAMP_DIRT.getDefaultState())
.setTopBlockState(BlockRegistry.SWAMP_GRASS.getDefaultState()).setDecorator(new BiomeDecoratorSwamplandsClearing(this));
.setTopBlockState(BlockRegistry.SWAMP_GRASS.getDefaultState()).setDecoratorFactory(BiomeDecoratorSwamplandsClearing::new);
this.setFoliageColors(-1, 0x52AF5A);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
import thebetweenlands.common.world.gen.feature.OreGens;

public class BiomeDecoratorBetweenlands extends DecoratorPositionProvider {
private static final List<String> profiledGenerators = new ArrayList<String>();
private static boolean decorating;
private final List<String> profiledGenerators = new ArrayList<String>();
private boolean decorating;
private final Biome biome;

public BiomeDecoratorBetweenlands(Biome biome) {
Expand All @@ -31,6 +31,10 @@ public Biome getBiome() {
return this.biome;
}

public final boolean isDecorating() {
return decorating;
}

/**
* Decorates the specified chunk
*
Expand All @@ -40,25 +44,30 @@ public Biome getBiome() {
* @param z
*/
public final void decorate(World world, ChunkGeneratorBetweenlands generator, Random rand, int x, int z) {
if(this.decorating) {
throw new RuntimeException("Already Decorating!");
}

this.init(world, this.biome, generator, rand, x, z);

boolean wasDecorating = decorating;
//TODO re-evaluate the profiling, make sure it's still working and that decorators aren't piling up or anything
// boolean wasDecorating = decorating;
decorating = true;

if (!wasDecorating) {
profiledGenerators.clear();
// if (!wasDecorating) {
this.profiledGenerators.clear();
this.getProfiler().startSection(this.getBiome().getRegistryName().getPath());
}
// }

this.decorate();

if (!wasDecorating) {
// if (!wasDecorating) {
this.getProfiler().endSection();
}
// }

if (!wasDecorating) {
// if (!wasDecorating) {
decorating = false;
}
// }
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,21 @@
import thebetweenlands.common.world.gen.biome.BiomeWeights;
import thebetweenlands.common.world.gen.biome.decorator.BiomeDecoratorBetweenlands;
import thebetweenlands.common.world.gen.biome.feature.BiomeFeature;
import thebetweenlands.common.world.gen.biome.generator.BiomeGenerator.EnumGeneratorPass;

public class BiomeGenerator {
//because writing Function<BiomeDecoratorBetweenlands, Biome> every time is really long
@FunctionalInterface
public static interface DecoratorProvider {
/**
* Called when the main decorator is already in use (or when creating the main decorator).<br/>
* Must create a new instance of the decorator.
* @param biome The biome to create the decorator for.
* @return A new {@code BiomeDecoratorBetweenlands} instance.
*/
public BiomeDecoratorBetweenlands createDecorator(Biome biome);
}

protected final Biome biome;

protected IBlockState bottomBlockState = BlockRegistry.BETWEENLANDS_BEDROCK.getDefaultState();
Expand All @@ -41,11 +54,13 @@ public class BiomeGenerator {
protected boolean noiseGeneratorsInitialized = false;
protected boolean noiseGenerated = false;

protected BiomeDecoratorBetweenlands decorator;
protected BiomeDecoratorBetweenlands mainDecorator;
protected DecoratorProvider decoratorFactory;

public BiomeGenerator(Biome biome) {
this.biome = biome;
this.decorator = new BiomeDecoratorBetweenlands(biome);
this.mainDecorator = new BiomeDecoratorBetweenlands(biome);
this.decoratorFactory = BiomeDecoratorBetweenlands::new;
}

/**
Expand All @@ -57,23 +72,33 @@ public Biome getBiome() {
}

/**
* Sets the biome decorator
* @param decorator
* Sets the biome decorator factory.
* @param decoratorFactory
* @return
*/
public BiomeGenerator setDecorator(BiomeDecoratorBetweenlands decorator) {
public BiomeGenerator setDecoratorFactory(DecoratorProvider decoratorFactory) {
BiomeDecoratorBetweenlands decorator = decoratorFactory.createDecorator(this.getBiome());
if(decorator.getBiome() != this.getBiome())
throw new RuntimeException("Decorator was assigned to a different biome!");
this.decorator = decorator;
this.mainDecorator = decorator;
this.decoratorFactory = decoratorFactory;
return this;
}

/**
* Returns the biome decorator
* Returns a biome decorator.
* Will create a new instance if the current one is in use.
* @return
*/
public BiomeDecoratorBetweenlands getDecorator() {
return this.decorator;
if(!this.mainDecorator.isDecorating()) {
return this.mainDecorator;
}

BiomeDecoratorBetweenlands decorator = decoratorFactory.createDecorator(this.getBiome());
if(decorator.getBiome() != this.getBiome())
throw new RuntimeException("Decorator was assigned to a different biome!");
return decorator;
}

/**
Expand Down