refactor biome layers to match vanilla's new 1.15 system (#1571)
This commit is contained in:
parent
21ae14f67b
commit
7bca7e9707
|
@ -39,7 +39,7 @@ public class BOPBiomeProvider extends OverworldBiomeProvider
|
||||||
super(settingsProvider);
|
super(settingsProvider);
|
||||||
this.possibleBiomes = Sets.newHashSet(super.possibleBiomes);
|
this.possibleBiomes = Sets.newHashSet(super.possibleBiomes);
|
||||||
this.possibleBiomes.addAll(BOPClimates.getOverworldBiomes());
|
this.possibleBiomes.addAll(BOPClimates.getOverworldBiomes());
|
||||||
this.noiseBiomeLayer = BOPLayerUtil.createGenLayers(settingsProvider.getSeed(), settingsProvider.getGeneratorType(), (BOPOverworldGenSettings)settingsProvider.getGeneratorSettings())[0];
|
this.noiseBiomeLayer = BOPLayerUtil.createGenLayers(settingsProvider.getSeed(), settingsProvider.getGeneratorType(), (BOPOverworldGenSettings)settingsProvider.getGeneratorSettings());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -9,13 +9,10 @@ package biomesoplenty.common.world;
|
||||||
|
|
||||||
import biomesoplenty.common.world.layer.*;
|
import biomesoplenty.common.world.layer.*;
|
||||||
import biomesoplenty.common.world.layer.traits.LazyAreaLayerContextBOP;
|
import biomesoplenty.common.world.layer.traits.LazyAreaLayerContextBOP;
|
||||||
import biomesoplenty.core.BiomesOPlenty;
|
|
||||||
import com.google.common.collect.ImmutableList;
|
|
||||||
import net.minecraft.util.registry.Registry;
|
import net.minecraft.util.registry.Registry;
|
||||||
import net.minecraft.world.WorldType;
|
import net.minecraft.world.WorldType;
|
||||||
import net.minecraft.world.biome.Biomes;
|
import net.minecraft.world.biome.Biomes;
|
||||||
import net.minecraft.world.gen.IExtendedNoiseRandom;
|
import net.minecraft.world.gen.IExtendedNoiseRandom;
|
||||||
import net.minecraft.world.gen.OverworldGenSettings;
|
|
||||||
import net.minecraft.world.gen.area.IArea;
|
import net.minecraft.world.gen.area.IArea;
|
||||||
import net.minecraft.world.gen.area.IAreaFactory;
|
import net.minecraft.world.gen.area.IAreaFactory;
|
||||||
import net.minecraft.world.gen.area.LazyArea;
|
import net.minecraft.world.gen.area.LazyArea;
|
||||||
|
@ -111,7 +108,7 @@ public class BOPLayerUtil
|
||||||
return biomeFactory;
|
return biomeFactory;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static <T extends IArea, C extends IExtendedNoiseRandom<T>> ImmutableList<IAreaFactory<T>> createAreaFactories(WorldType worldType, BOPOverworldGenSettings settings, LongFunction<C> contextFactory)
|
public static <T extends IArea, C extends IExtendedNoiseRandom<T>> IAreaFactory<T> createAreaFactories(WorldType worldType, BOPOverworldGenSettings settings, LongFunction<C> contextFactory)
|
||||||
{
|
{
|
||||||
// Create the initial land and sea layer. Is also responsible for adding deep oceans
|
// Create the initial land and sea layer. Is also responsible for adding deep oceans
|
||||||
// and mushroom islands
|
// and mushroom islands
|
||||||
|
@ -123,7 +120,8 @@ public class BOPLayerUtil
|
||||||
|
|
||||||
int biomeSize = 4;
|
int biomeSize = 4;
|
||||||
int riverSize = biomeSize;
|
int riverSize = biomeSize;
|
||||||
if (settings != null) {
|
if (settings != null)
|
||||||
|
{
|
||||||
biomeSize = settings.getBiomeSize();
|
biomeSize = settings.getBiomeSize();
|
||||||
riverSize = settings.getRiverSize();
|
riverSize = settings.getRiverSize();
|
||||||
}
|
}
|
||||||
|
@ -169,23 +167,16 @@ public class BOPLayerUtil
|
||||||
|
|
||||||
climateFactory = LayerUtil.zoom(2001L, ZoomLayer.NORMAL, climateFactory, 6, contextFactory);
|
climateFactory = LayerUtil.zoom(2001L, ZoomLayer.NORMAL, climateFactory, 6, contextFactory);
|
||||||
biomesFactory = BOPMixOceansLayer.INSTANCE.run(contextFactory.apply(100L), biomesFactory, oceanBiomeFactory, climateFactory);
|
biomesFactory = BOPMixOceansLayer.INSTANCE.run(contextFactory.apply(100L), biomesFactory, oceanBiomeFactory, climateFactory);
|
||||||
|
return biomesFactory;
|
||||||
// Finish biomes with Voroni zoom
|
|
||||||
IAreaFactory<T> voroniZoomBiomesFactory = VoroniZoomLayer.INSTANCE.run(contextFactory.apply(10L), biomesFactory);
|
|
||||||
|
|
||||||
return ImmutableList.of(biomesFactory, voroniZoomBiomesFactory, biomesFactory);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Layer[] createGenLayers(long seed, WorldType worldType, BOPOverworldGenSettings settings)
|
public static Layer createGenLayers(long seed, WorldType worldType, BOPOverworldGenSettings settings)
|
||||||
{
|
{
|
||||||
ImmutableList<IAreaFactory<LazyArea>> factoryList = createAreaFactories(worldType, settings, (seedModifier) ->
|
IAreaFactory<LazyArea> factory = createAreaFactories(worldType, settings, (seedModifier) ->
|
||||||
{
|
{
|
||||||
return new LazyAreaLayerContextBOP(1, seed, seedModifier);
|
return new LazyAreaLayerContextBOP(1, seed, seedModifier);
|
||||||
});
|
});
|
||||||
Layer biomesLayer = new Layer(factoryList.get(0));
|
return new Layer(factory);
|
||||||
Layer voroniZoomBiomesLayer = new Layer(factoryList.get(1));
|
|
||||||
Layer biomesLayer2 = new Layer(factoryList.get(2));
|
|
||||||
return new Layer[]{biomesLayer, voroniZoomBiomesLayer, biomesLayer2};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isOcean(int biomeIn)
|
public static boolean isOcean(int biomeIn)
|
||||||
|
|
|
@ -10,9 +10,7 @@ package biomesoplenty.common.world;
|
||||||
import biomesoplenty.common.world.layer.LandLayer;
|
import biomesoplenty.common.world.layer.LandLayer;
|
||||||
import biomesoplenty.common.world.layer.NetherBiomeLayer;
|
import biomesoplenty.common.world.layer.NetherBiomeLayer;
|
||||||
import biomesoplenty.common.world.layer.BOPShoreLayer;
|
import biomesoplenty.common.world.layer.BOPShoreLayer;
|
||||||
import biomesoplenty.common.world.layer.VoroniZoomLayer;
|
|
||||||
import biomesoplenty.common.world.layer.traits.LazyAreaLayerContextBOP;
|
import biomesoplenty.common.world.layer.traits.LazyAreaLayerContextBOP;
|
||||||
import com.google.common.collect.ImmutableList;
|
|
||||||
import net.minecraft.world.WorldType;
|
import net.minecraft.world.WorldType;
|
||||||
import net.minecraft.world.gen.IExtendedNoiseRandom;
|
import net.minecraft.world.gen.IExtendedNoiseRandom;
|
||||||
import net.minecraft.world.gen.OverworldGenSettings;
|
import net.minecraft.world.gen.OverworldGenSettings;
|
||||||
|
@ -33,7 +31,7 @@ public class BOPNetherLayerUtil
|
||||||
return biomeFactory;
|
return biomeFactory;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static <T extends IArea, C extends IExtendedNoiseRandom<T>> ImmutableList<IAreaFactory<T>> createAreaFactories(WorldType worldType, OverworldGenSettings settings, LongFunction<C> contextFactory)
|
public static <T extends IArea, C extends IExtendedNoiseRandom<T>> IAreaFactory<T> createAreaFactories(WorldType worldType, OverworldGenSettings settings, LongFunction<C> contextFactory)
|
||||||
{
|
{
|
||||||
int biomeSize = 3;
|
int biomeSize = 3;
|
||||||
|
|
||||||
|
@ -52,21 +50,16 @@ public class BOPNetherLayerUtil
|
||||||
}
|
}
|
||||||
|
|
||||||
biomesFactory = SmoothLayer.INSTANCE.run(contextFactory.apply(1000L), biomesFactory);
|
biomesFactory = SmoothLayer.INSTANCE.run(contextFactory.apply(1000L), biomesFactory);
|
||||||
|
return biomesFactory;
|
||||||
// Finish biomes with Voroni zoom
|
|
||||||
IAreaFactory<T> voroniZoomBiomesFactory = VoroniZoomLayer.INSTANCE.run(contextFactory.apply(10L), biomesFactory);
|
|
||||||
return ImmutableList.of(biomesFactory, voroniZoomBiomesFactory, biomesFactory);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Layer[] createGenLayers(long seed, WorldType worldType, OverworldGenSettings settings)
|
public static Layer createGenLayers(long seed, WorldType worldType, OverworldGenSettings settings)
|
||||||
{
|
{
|
||||||
ImmutableList<IAreaFactory<LazyArea>> factoryList = createAreaFactories(worldType, settings, (seedModifier) ->
|
IAreaFactory<LazyArea> factory = createAreaFactories(worldType, settings, (seedModifier) ->
|
||||||
{
|
{
|
||||||
return new LazyAreaLayerContextBOP(1, seed, seedModifier);
|
return new LazyAreaLayerContextBOP(1, seed, seedModifier);
|
||||||
});
|
});
|
||||||
Layer biomesLayer = new Layer(factoryList.get(0));
|
|
||||||
Layer voroniZoomBiomesLayer = new Layer(factoryList.get(1));
|
return new Layer(factory);
|
||||||
Layer biomesLayer2 = new Layer(factoryList.get(2));
|
|
||||||
return new Layer[]{biomesLayer, voroniZoomBiomesLayer, biomesLayer2};
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,7 +38,7 @@ public class NetherBiomeProvider extends BiomeProvider
|
||||||
public NetherBiomeProvider(OverworldBiomeProviderSettings settingsProvider)
|
public NetherBiomeProvider(OverworldBiomeProviderSettings settingsProvider)
|
||||||
{
|
{
|
||||||
super(BOPClimates.NETHER.getLandBiomes().stream().map(weightedBiomeEntry -> weightedBiomeEntry.biome).collect(Collectors.toSet()));
|
super(BOPClimates.NETHER.getLandBiomes().stream().map(weightedBiomeEntry -> weightedBiomeEntry.biome).collect(Collectors.toSet()));
|
||||||
this.noiseBiomeLayer = BOPNetherLayerUtil.createGenLayers(settingsProvider.getSeed(), settingsProvider.getGeneratorType(), settingsProvider.getGeneratorSettings())[0];
|
this.noiseBiomeLayer = BOPNetherLayerUtil.createGenLayers(settingsProvider.getSeed(), settingsProvider.getGeneratorType(), settingsProvider.getGeneratorSettings());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -1,65 +0,0 @@
|
||||||
/*******************************************************************************
|
|
||||||
* 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 net.minecraft.world.gen.IExtendedNoiseRandom;
|
|
||||||
import net.minecraft.world.gen.area.IArea;
|
|
||||||
import net.minecraft.world.gen.layer.traits.IAreaTransformer1;
|
|
||||||
|
|
||||||
public enum VoroniZoomLayer implements IAreaTransformer1
|
|
||||||
{
|
|
||||||
INSTANCE;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int applyPixel(IExtendedNoiseRandom<?> context, IArea area, int x, int y)
|
|
||||||
{
|
|
||||||
int i = x - 2;
|
|
||||||
int j = y - 2;
|
|
||||||
int k = i >> 2;
|
|
||||||
int l = j >> 2;
|
|
||||||
int i1 = k << 2;
|
|
||||||
int j1 = l << 2;
|
|
||||||
context.initRandom((long)i1, (long)j1);
|
|
||||||
double d0 = ((double)context.nextRandom(1024) / 1024.0D - 0.5D) * 3.6D;
|
|
||||||
double d1 = ((double)context.nextRandom(1024) / 1024.0D - 0.5D) * 3.6D;
|
|
||||||
context.initRandom((long)(i1 + 4), (long)j1);
|
|
||||||
double d2 = ((double)context.nextRandom(1024) / 1024.0D - 0.5D) * 3.6D + 4.0D;
|
|
||||||
double d3 = ((double)context.nextRandom(1024) / 1024.0D - 0.5D) * 3.6D;
|
|
||||||
context.initRandom((long)i1, (long)(j1 + 4));
|
|
||||||
double d4 = ((double)context.nextRandom(1024) / 1024.0D - 0.5D) * 3.6D;
|
|
||||||
double d5 = ((double)context.nextRandom(1024) / 1024.0D - 0.5D) * 3.6D + 4.0D;
|
|
||||||
context.initRandom((long)(i1 + 4), (long)(j1 + 4));
|
|
||||||
double d6 = ((double)context.nextRandom(1024) / 1024.0D - 0.5D) * 3.6D + 4.0D;
|
|
||||||
double d7 = ((double)context.nextRandom(1024) / 1024.0D - 0.5D) * 3.6D + 4.0D;
|
|
||||||
int k1 = i & 3;
|
|
||||||
int l1 = j & 3;
|
|
||||||
double d8 = ((double)l1 - d1) * ((double)l1 - d1) + ((double)k1 - d0) * ((double)k1 - d0);
|
|
||||||
double d9 = ((double)l1 - d3) * ((double)l1 - d3) + ((double)k1 - d2) * ((double)k1 - d2);
|
|
||||||
double d10 = ((double)l1 - d5) * ((double)l1 - d5) + ((double)k1 - d4) * ((double)k1 - d4);
|
|
||||||
double d11 = ((double)l1 - d7) * ((double)l1 - d7) + ((double)k1 - d6) * ((double)k1 - d6);
|
|
||||||
if (d8 < d9 && d8 < d10 && d8 < d11) {
|
|
||||||
return area.get(this.getParentX(i1), this.getParentY(j1));
|
|
||||||
} else if (d9 < d8 && d9 < d10 && d9 < d11) {
|
|
||||||
return area.get(this.getParentX(i1 + 4), this.getParentY(j1)) & 255;
|
|
||||||
} else {
|
|
||||||
return d10 < d8 && d10 < d9 && d10 < d11 ? area.get(this.getParentX(i1), this.getParentY(j1 + 4)) : area.get(this.getParentX(i1 + 4), this.getParentY(j1 + 4)) & 255;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getParentX(int x)
|
|
||||||
{
|
|
||||||
return x >> 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getParentY(int y)
|
|
||||||
{
|
|
||||||
return y >> 2;
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue