Setup for climate-based ocean biomes

This commit is contained in:
Adubbz 2019-05-24 14:51:58 +10:00
parent c739135516
commit f7e91937d8
4 changed files with 125 additions and 3 deletions

View file

@ -159,7 +159,9 @@ public class BOPLayerUtil
// Mix rivers into the biomes branch
biomesFactory = GenLayerRiverMix.INSTANCE.apply(contextFactory.apply(100L), biomesFactory, riversInitFactory);
biomesFactory = GenLayerMixOceans.INSTANCE.apply(contextFactory.apply(100L), biomesFactory, oceanBiomeFactory);
climateFactory = LayerUtil.repeat(2001L, GenLayerZoom.NORMAL, oceanBiomeFactory, 6, contextFactory);
biomesFactory = GenLayerMixOceansBOP.INSTANCE.apply(contextFactory.apply(100L), biomesFactory, oceanBiomeFactory, climateFactory);
// Finish biomes with Voroni zoom
IAreaFactory<T> voroniZoomBiomesFactory = GenLayerVoronoiZoom.INSTANCE.apply(contextFactory.apply(10L), biomesFactory);

View file

@ -0,0 +1,84 @@
/*******************************************************************************
* 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 biomesoplenty.common.world.BOPLayerUtil;
import biomesoplenty.common.world.layer.traits.IAreaTransformer3;
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.IDimOffset0Transformer;
public enum GenLayerMixOceansBOP implements IAreaTransformer3, IDimOffset0Transformer
{
INSTANCE;
@Override
public int apply(IContext context, AreaDimension dimension, IArea biomeArea, IArea oceanArea, IArea climateArea, int x, int z)
{
int biomeId = biomeArea.getValue(x, z);
int oceanId = oceanArea.getValue(x, z);
int climateVal = climateArea.getValue(x, z);
BOPClimates climate = BOPClimates.lookup(climateVal);
if (!BOPLayerUtil.isOcean(biomeId))
{
return biomeId;
}
else
{
// When far from land, warm oceans should become lukewarm and frozen oceans should become cold
for (int xOff = -8; xOff <= 8; xOff += 4)
{
for (int zOff = -8; zOff <= 8; zOff += 4)
{
int offsetBiomeId = biomeArea.getValue(x + xOff, z + zOff);
if (!BOPLayerUtil.isOcean(offsetBiomeId))
{
if (oceanId == BOPLayerUtil.WARM_OCEAN)
{
return BOPLayerUtil.LUKEWARM_OCEAN;
}
if (oceanId == BOPLayerUtil.FROZEN_OCEAN)
{
return BOPLayerUtil.COLD_OCEAN;
}
}
}
}
if (biomeId == BOPLayerUtil.DEEP_OCEAN)
{
if (oceanId == BOPLayerUtil.LUKEWARM_OCEAN)
{
return BOPLayerUtil.DEEP_LUKEWARM_OCEAN;
}
if (oceanId == BOPLayerUtil.OCEAN)
{
return BOPLayerUtil.DEEP_OCEAN;
}
if (oceanId == BOPLayerUtil.COLD_OCEAN)
{
return BOPLayerUtil.DEEP_COLD_OCEAN;
}
if (oceanId == BOPLayerUtil.FROZEN_OCEAN)
{
return BOPLayerUtil.DEEP_FROZEN_OCEAN;
}
}
return oceanId;
}
}
}

View file

@ -43,6 +43,7 @@ public enum GenLayerShoreBOP implements ICastleTransformer
private static final int SWAMP = IRegistry.BIOME.getId(Biomes.SWAMP);
private static final int TAIGA = IRegistry.BIOME.getId(Biomes.TAIGA);
@Override
public int apply(IContext context, int northBiomeId, int eastBiomeId, int southBiomeId, int westBiomeId, int biomeId)
{
Biome biome = IRegistry.BIOME.get(biomeId);
@ -92,7 +93,7 @@ public enum GenLayerShoreBOP implements ICastleTransformer
return BEACH;
}
}
else if (!BOPLayerUtil.isOcean(northBiomeId) && !BOPLayerUtil.isOcean(eastBiomeId) && !BOPLayerUtil.isOcean(southBiomeId) && !BOPLayerUtil.isOcean(westBiomeId) && (!this.isMesa(northBiomeId) || !this.isMesa(eastBiomeId) || !this.isMesa(southBiomeId) || !this.isMesa(westBiomeId)))
else if (!BOPLayerUtil.isOcean(northBiomeId) && !BOPLayerUtil.isOcean(eastBiomeId) && !BOPLayerUtil.isOcean(southBiomeId) && !BOPLayerUtil.isOcean(westBiomeId) && (!isMesa(northBiomeId) || !isMesa(eastBiomeId) || !isMesa(southBiomeId) || !isMesa(westBiomeId)))
{
return DESERT;
}
@ -117,7 +118,7 @@ public enum GenLayerShoreBOP implements ICastleTransformer
}
}
private boolean isMesa(int biomeId)
private static boolean isMesa(int biomeId)
{
return biomeId == BADLANDS || biomeId == WOODED_BADLANDS_PLATEAU || biomeId == BADLANDS_PLATEAU || biomeId == ERODED_BADLANDS || biomeId == MODIFIED_WOODED_BADLANDS_PLATEAU || biomeId == MODIFIED_BADLANDS_PLATEAU;
}

View file

@ -0,0 +1,35 @@
/*******************************************************************************
* 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.traits;
import net.minecraft.world.gen.IContext;
import net.minecraft.world.gen.IContextExtended;
import net.minecraft.world.gen.area.AreaDimension;
import net.minecraft.world.gen.area.IArea;
import net.minecraft.world.gen.area.IAreaFactory;
import net.minecraft.world.gen.layer.traits.IDimTransformer;
public interface IAreaTransformer3 extends IDimTransformer
{
default <R extends IArea> IAreaFactory<R> apply(IContextExtended<R> context, IAreaFactory<R> areaFactory1, IAreaFactory<R> areaFactory2, IAreaFactory<R> areaFactory3)
{
return (areaDimension) ->
{
R area1 = areaFactory1.make(this.apply(areaDimension));
R area2 = areaFactory2.make(this.apply(areaDimension));
R area3 = areaFactory3.make(this.apply(areaDimension));
return context.makeArea(areaDimension, (x, z) ->
{
context.setPosition((long)(x + areaDimension.getStartX()), (long)(z + areaDimension.getStartZ()));
return this.apply(context, areaDimension, area1, area2, area3, x, z);
});
};
}
int apply(IContext context, AreaDimension dimension, IArea area1, IArea area2, IArea area3, int x, int z);
}