Genlayerbiome done
This commit is contained in:
parent
518e6ffe47
commit
2d25e3d99b
|
@ -10,6 +10,7 @@ package biomesoplenty.api.enums;
|
|||
import biomesoplenty.common.world.layer.traits.IBOPContextExtended;
|
||||
import net.minecraft.init.Biomes;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
import net.minecraft.world.gen.IContext;
|
||||
import net.minecraftforge.common.BiomeManager.BiomeType;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
@ -55,7 +56,7 @@ public enum BOPClimates
|
|||
return this;
|
||||
}
|
||||
|
||||
public Biome getRandomBiome(IBOPContextExtended context)
|
||||
public Biome getRandomBiome(IContext context)
|
||||
{
|
||||
int weight = context.random(this.totalBiomesWeight);
|
||||
Iterator<WeightedBiomeEntry> iterator = this.landBiomes.iterator();
|
||||
|
@ -69,7 +70,7 @@ public enum BOPClimates
|
|||
return item.biome;
|
||||
}
|
||||
|
||||
public Biome getRandomOceanBiome(IBOPContextExtended context, boolean deep)
|
||||
public Biome getRandomOceanBiome(IContext context, boolean deep)
|
||||
{
|
||||
return (deep ? Biomes.DEEP_OCEAN : Biomes.OCEAN);
|
||||
}
|
||||
|
|
|
@ -171,9 +171,10 @@ public class GenLayerVisualizer
|
|||
};
|
||||
|
||||
IAreaFactory<LazyArea> landAreaFactory = BOPLayerUtil.createInitialLandAndSeaFactory(contextFactory);
|
||||
//IAreaFactory<LazyArea> biomeAreaFactory = BOPLayerUtil.createBiomeFactory(landAreaFactory, WorldType.DEFAULT, settings, new BOPWorldSettings(), contextFactory);
|
||||
IAreaFactory<LazyArea> climateFactory = BOPLayerUtil.createClimateFactory(contextFactory, new BOPWorldSettings());
|
||||
IAreaFactory<LazyArea> biomeAreaFactory = BOPLayerUtil.createBiomeFactory(landAreaFactory, climateFactory, contextFactory);
|
||||
|
||||
IAreaFactory<LazyArea> biomeAreaFactory = BOPLayerUtil.createAreaFactories(WorldType.DEFAULT, settings, contextFactory).get(0);
|
||||
//IAreaFactory<LazyArea> biomeAreaFactory = BOPLayerUtil.createAreaFactories(WorldType.DEFAULT, settings, contextFactory).get(0);
|
||||
|
||||
AreaDimension areaDimension = new AreaDimension(0, 0, CANVAS_WIDTH, CANVAS_HEIGHT);
|
||||
LazyArea area = biomeAreaFactory.make(areaDimension);
|
||||
|
|
|
@ -33,11 +33,11 @@ public class BOPLayerUtil
|
|||
factory = GenLayerAddIsland.INSTANCE.apply(contextFactory.apply(50L), factory);
|
||||
factory = GenLayerAddIsland.INSTANCE.apply(contextFactory.apply(70L), factory);
|
||||
factory = GenLayerRemoveTooMuchOcean.INSTANCE.apply(contextFactory.apply(2L), factory);
|
||||
factory = GenLayerAddSnow.INSTANCE.<T>apply((IContextExtended)contextFactory.apply(2L), factory);
|
||||
//factory = GenLayerAddSnow.INSTANCE.<T>apply((IContextExtended)contextFactory.apply(2L), factory);
|
||||
factory = GenLayerAddIsland.INSTANCE.apply(contextFactory.apply(3L), factory);
|
||||
factory = GenLayerEdge.CoolWarm.INSTANCE.apply(contextFactory.apply(2L), factory);
|
||||
factory = GenLayerEdge.HeatIce.INSTANCE.apply(contextFactory.apply(2L), factory);
|
||||
factory = GenLayerEdge.Special.INSTANCE.apply(contextFactory.apply(3L), factory);
|
||||
//factory = GenLayerEdge.CoolWarm.INSTANCE.apply(contextFactory.apply(2L), factory);
|
||||
//factory = GenLayerEdge.HeatIce.INSTANCE.apply(contextFactory.apply(2L), factory);
|
||||
//factory = GenLayerEdge.Special.INSTANCE.apply(contextFactory.apply(3L), factory);
|
||||
factory = GenLayerZoom.NORMAL.apply(contextFactory.apply(2002L), factory);
|
||||
factory = GenLayerZoom.NORMAL.apply(contextFactory.apply(2003L), factory);
|
||||
factory = GenLayerAddIsland.INSTANCE.apply(contextFactory.apply(4L), factory);
|
||||
|
@ -90,9 +90,9 @@ public class BOPLayerUtil
|
|||
return GenLayerClimate.INSTANCE.apply(contextFactory.apply(103L), temperatureFactory, rainfallFactory);
|
||||
}
|
||||
|
||||
public static <T extends IArea, C extends IContextExtended<T>> IAreaFactory<T> createBiomeFactory(IAreaFactory<T> landSeaAreaFactory, WorldType worldType, OverworldGenSettings settings, BOPWorldSettings bopWorldSettings, LongFunction<C> contextFactory)
|
||||
public static <T extends IArea, C extends IContextExtended<T>> IAreaFactory<T> createBiomeFactory(IAreaFactory<T> landSeaAreaFactory, IAreaFactory<T> climateAreaFactory, LongFunction<C> contextFactory)
|
||||
{
|
||||
IAreaFactory<T> biomeFactory = (new GenLayerBiome(worldType, settings)).apply(contextFactory.apply(200L), landSeaAreaFactory);
|
||||
IAreaFactory<T> biomeFactory = GenLayerBiomeBOP.INSTANCE.apply(contextFactory.apply(200L), landSeaAreaFactory, climateAreaFactory);
|
||||
biomeFactory = LayerUtil.repeat(1000L, GenLayerZoom.NORMAL, biomeFactory, 2, contextFactory);
|
||||
biomeFactory = GenLayerBiomeEdge.INSTANCE.apply(contextFactory.apply(1000L), biomeFactory);
|
||||
return biomeFactory;
|
||||
|
@ -122,7 +122,8 @@ public class BOPLayerUtil
|
|||
riverAndSubBiomesInitFactory = LayerUtil.repeat(1000L, GenLayerZoom.NORMAL, riverAndSubBiomesInitFactory, 2, contextFactory);
|
||||
|
||||
// Allocate the biomes
|
||||
IAreaFactory<T> biomesFactory = createBiomeFactory(landSeaFactory, worldType, settings, new BOPWorldSettings(), contextFactory);
|
||||
IAreaFactory<T> climateFactory = createClimateFactory(contextFactory, new BOPWorldSettings());
|
||||
IAreaFactory<T> biomesFactory = createBiomeFactory(landSeaFactory, climateFactory, contextFactory);
|
||||
biomesFactory = GenLayerHills.INSTANCE.apply(contextFactory.apply(1000L), biomesFactory, riverAndSubBiomesInitFactory);
|
||||
|
||||
// Develop the rivers branch
|
||||
|
|
|
@ -0,0 +1,67 @@
|
|||
/*******************************************************************************
|
||||
* Copyright 2014-2019, 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.world.layer;
|
||||
|
||||
import biomesoplenty.api.enums.BOPClimates;
|
||||
import net.minecraft.init.Biomes;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
import net.minecraft.world.gen.IContext;
|
||||
import net.minecraft.world.gen.area.AreaDimension;
|
||||
import net.minecraft.world.gen.area.IArea;
|
||||
import net.minecraft.world.gen.layer.traits.IAreaTransformer2;
|
||||
import net.minecraft.world.gen.layer.traits.IDimOffset0Transformer;
|
||||
import net.minecraftforge.common.BiomeManager;
|
||||
|
||||
public enum GenLayerBiomeBOP implements IAreaTransformer2, IDimOffset0Transformer
|
||||
{
|
||||
INSTANCE;
|
||||
|
||||
private static final int DEEP_OCEAN = Biome.func_185362_a(Biomes.DEEP_OCEAN);
|
||||
private static final int MUSHROOM_FIELDS = Biome.func_185362_a(Biomes.MUSHROOM_FIELDS);
|
||||
|
||||
@Override
|
||||
public int apply(IContext context, AreaDimension dimension, IArea area1, IArea area2, int x, int z)
|
||||
{
|
||||
int landSeaVal = area1.getValue(x, z);
|
||||
int climateVal = area2.getValue(x, z);
|
||||
|
||||
BOPClimates climate;
|
||||
try
|
||||
{
|
||||
climate = BOPClimates.lookup(climateVal);
|
||||
}
|
||||
catch (ArrayIndexOutOfBoundsException e)
|
||||
{
|
||||
// This shouldn't happen - but apparently it (rarely) does (https://github.com/Glitchfiend/BiomesOPlenty/issues/983)
|
||||
// If it does it means that something weird happened with the climate layer / lookup
|
||||
// Rethrow with hopefully a more useful message
|
||||
String msg = "Climate lookup failed climateOrdinal: " + climateVal;
|
||||
throw new RuntimeException(msg,e);
|
||||
}
|
||||
|
||||
// At this point, oceans and land have been assigned, and so have mushroom islands
|
||||
if (landSeaVal == DEEP_OCEAN)
|
||||
{
|
||||
return Biome.func_185362_a(climate.getRandomOceanBiome(context, true));
|
||||
}
|
||||
else if ((landSeaVal == MUSHROOM_FIELDS /*|| ModBiomes.islandBiomesMap.containsKey(landSeaVal)*/) && climate.biomeType != BiomeManager.BiomeType.ICY) // TODO
|
||||
{
|
||||
// keep islands, unless it's in an icy climate in which case, replace
|
||||
return landSeaVal;
|
||||
}
|
||||
else if (landSeaVal == 0)
|
||||
{
|
||||
return Biome.func_185362_a(climate.getRandomOceanBiome(context, false));
|
||||
}
|
||||
else
|
||||
{
|
||||
return Biome.func_185362_a(climate.getRandomBiome(context));
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue