Non default Terrain Heights for EndBiomeSource

This commit is contained in:
Frank 2022-06-19 22:06:25 +02:00
parent 35b968eb93
commit 73cd08fa69
6 changed files with 63 additions and 33 deletions

View file

@ -73,7 +73,7 @@ public class BCLChunkGenerator extends NoiseBasedChunkGenerator {
if (BCLib.RUNS_TERRABLENDER) {
BCLib.LOGGER.info("Make sure features are loaded from terrablender for " + biomeSource);
//terrablender is completley invalidating the feature imitialization
//terrablender is invalidating the feature initialization
//we redo it at this point, otherwise we will get blank biomes
rebuildFeaturesPerStep(biomeSource);
}

View file

@ -34,7 +34,7 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import java.util.Set;
import java.util.function.Function;
import java.util.function.BiFunction;
public class BCLibEndBiomeSource extends BCLBiomeSource {
private static final OpenSimplexNoise SMALL_NOISE = new OpenSimplexNoise(8324);
@ -62,11 +62,13 @@ public class BCLibEndBiomeSource extends BCLBiomeSource {
private final Holder<Biome> centerBiome;
private final Holder<Biome> barrens;
private final Point pos;
private final Function<Point, Boolean> endLandFunction;
private final BiFunction<Point, Integer, Boolean> endLandFunction;
private SimplexNoise noise;
private BiomeMap mapLand;
private BiomeMap mapVoid;
private static int worldHeight;
private final BiomePicker endLandBiomePicker;
private final BiomePicker endVoidBiomePicker;
@ -158,6 +160,15 @@ public class BCLibEndBiomeSource extends BCLBiomeSource {
);
}
/**
* Set world height, used when Nether is larger than vanilla 128 blocks tall.
*
* @param worldHeight height of the Nether ceiling.
*/
public static void setWorldHeight(int worldHeight) {
BCLibEndBiomeSource.worldHeight = worldHeight;
}
private static List<Holder<Biome>> getBclBiomes(Registry<Biome> biomeRegistry) {
List<String> include = Configs.BIOMES_CONFIG.getEntry(
"force_include",
@ -320,7 +331,7 @@ public class BCLibEndBiomeSource extends BCLBiomeSource {
}
} else {
pos.setLocation(biomeX, biomeZ);
if (endLandFunction.apply(pos)) {
if (endLandFunction.apply(pos, worldHeight)) {
return dist <= farEndBiomes ? centerBiome : mapLand.getBiome(posX, biomeY << 2, posZ).biome;
} else {
return dist <= farEndBiomes ? barrens : mapVoid.getBiome(posX, biomeY << 2, posZ).biome;

View file

@ -5,14 +5,14 @@ import org.betterx.bclib.config.Configs;
import net.minecraft.util.Mth;
import java.awt.*;
import java.util.function.Function;
import java.util.function.BiFunction;
public class GeneratorOptions {
private static int biomeSizeNether;
private static int biomeVSizeNether;
private static int biomeSizeEndLand;
private static int biomeSizeEndVoid;
private static Function<Point, Boolean> endLandFunction;
private static BiFunction<Point, Integer, Boolean> endLandFunction;
private static boolean customNetherBiomeSource = true;
private static boolean customEndBiomeSource = true;
private static boolean verticalBiomes = true;
@ -52,11 +52,11 @@ public class GeneratorOptions {
return Mth.clamp(biomeSizeEndVoid, 1, 8192);
}
public static void setEndLandFunction(Function<Point, Boolean> endLandFunction) {
public static void setEndLandFunction(BiFunction<Point, Integer, Boolean> endLandFunction) {
GeneratorOptions.endLandFunction = endLandFunction;
}
public static Function<Point, Boolean> getEndLandFunction() {
public static BiFunction<Point, Integer, Boolean> getEndLandFunction() {
return endLandFunction;
}

View file

@ -348,7 +348,11 @@ public class LevelGenUtil {
}
BCLib.LOGGER.info("Set world to BiomeSource Version " + biomeSourceVersion);
BCLWorldPreset.writeWorldPresetSettings(new BCLWorldPresetSettings(biomeSourceVersion, biomeSourceVersion));
BCLWorldPreset.writeWorldPresetSettings(new BCLWorldPresetSettings(
biomeSourceVersion,
biomeSourceVersion,
true
));
}
}

View file

@ -2,6 +2,7 @@ package org.betterx.bclib.mixin.common;
import org.betterx.bclib.api.v2.LifeCycleAPI;
import org.betterx.bclib.api.v2.generator.BCLBiomeSource;
import org.betterx.bclib.api.v2.generator.BCLibEndBiomeSource;
import org.betterx.bclib.api.v2.generator.BCLibNetherBiomeSource;
import net.minecraft.core.Holder;
@ -76,7 +77,10 @@ public abstract class ServerLevelMixin extends Level {
if (level.dimension() == Level.NETHER) {
BCLibNetherBiomeSource.setWorldHeight(level.getChunkSource().getGenerator().getGenDepth());
} else if (level.dimension() == Level.END) {
BCLibEndBiomeSource.setWorldHeight(level.getChunkSource().getGenerator().getGenDepth());
}
if (levelStem.generator().getBiomeSource() instanceof BCLBiomeSource source) {
source.setSeed(level.getSeed());
}

View file

@ -3,7 +3,7 @@ package org.betterx.bclib.presets.worldgen;
import org.betterx.bclib.BCLib;
import org.betterx.bclib.api.v2.generator.BCLBiomeSource;
import org.betterx.bclib.api.v2.generator.BCLChunkGenerator;
import org.betterx.bclib.api.v2.generator.BCLibNetherBiomeSource;
import org.betterx.bclib.api.v2.generator.BCLibEndBiomeSource;
import org.betterx.bclib.api.v2.levelgen.LevelGenUtil;
import org.betterx.bclib.api.v2.levelgen.biomes.InternalBiomeAPI;
import org.betterx.bclib.api.v2.levelgen.surface.SurfaceRuleUtil;
@ -33,28 +33,32 @@ public class BCLWorldPresetSettings extends WorldPresetSettings {
public static final Codec<BCLWorldPresetSettings> CODEC = RecordCodecBuilder
.create((RecordCodecBuilder.Instance<BCLWorldPresetSettings> builderInstance) -> {
RecordCodecBuilder<BCLWorldPresetSettings, Integer> netherVersion = Codec.INT
.fieldOf(LevelStem.NETHER.location().toString())
.forGetter((BCLWorldPresetSettings settings) -> settings.netherVersion);
RecordCodecBuilder<BCLWorldPresetSettings, Integer> endVersion = Codec.INT
.fieldOf(LevelStem.END.location().toString())
.forGetter((BCLWorldPresetSettings settings) -> settings.endVersion);
return builderInstance.group(netherVersion, endVersion)
return builderInstance.group(
Codec.INT
.fieldOf(LevelStem.NETHER.location().toString())
.forGetter(o -> o.netherVersion),
Codec.INT
.fieldOf(LevelStem.END.location().toString())
.forGetter(o -> o.endVersion),
Codec.BOOL
.fieldOf("custom_end_terrain")
.orElse(true)
.forGetter(o -> o.useEndTerrainGenerator)
)
.apply(builderInstance, builderInstance.stable(BCLWorldPresetSettings::new));
});
public final int netherVersion;
public final int endVersion;
public final boolean useEndTerrainGenerator;
public BCLWorldPresetSettings(int version) {
this(version, version);
this(version, version, true);
}
public BCLWorldPresetSettings(int netherVersion, int endVersion) {
public BCLWorldPresetSettings(int netherVersion, int endVersion, boolean useEndTerrainGenerator) {
this.netherVersion = netherVersion;
this.endVersion = endVersion;
this.useEndTerrainGenerator = endVersion != BCLibEndBiomeSource.BIOME_SOURCE_VERSION_VANILLA && useEndTerrainGenerator;
}
@ -114,7 +118,8 @@ public class BCLWorldPresetSettings extends WorldPresetSettings {
return biomeSource;
}
public Holder<NoiseGeneratorSettings> fixNoiseSettings(
private Holder<NoiseGeneratorSettings> fixNoiseSettings(
Holder<NoiseGeneratorSettings> reference,
Holder<NoiseGeneratorSettings> settings,
BiomeSource biomeSource
) {
@ -147,7 +152,7 @@ public class BCLWorldPresetSettings extends WorldPresetSettings {
* @param settings
* @return
*/
public WorldGenSettings fixSettingsInCurrentWorld(
private WorldGenSettings fixSettingsInCurrentWorld(
RegistryAccess access, ResourceKey<LevelStem> dimensionKey,
ResourceKey<DimensionType> dimensionTypeKey,
WorldGenSettings settings
@ -179,15 +184,21 @@ public class BCLWorldPresetSettings extends WorldPresetSettings {
if (loadedChunkGenerator instanceof ChunkGeneratorAccessor generator) {
if (loadedChunkGenerator instanceof NoiseGeneratorSettingsProvider noiseProvider) {
final Set<Holder<Biome>> biomes = loadedChunkGenerator.getBiomeSource().possibleBiomes();
final BiomeSource bs = fixBiomeSource(referenceGenerator.getBiomeSource(), biomes);
InternalBiomeAPI.applyModifications(bs, dimensionKey);
referenceGenerator = new BCLChunkGenerator(
generator.bclib_getStructureSetsRegistry(),
noiseProvider.bclib_getNoises(),
bs,
fixNoiseSettings(noiseProvider.bclib_getNoiseGeneratorSettingHolders(), bs)
);
if (referenceGenerator instanceof NoiseGeneratorSettingsProvider referenceProvider) {
final Set<Holder<Biome>> biomes = loadedChunkGenerator.getBiomeSource().possibleBiomes();
final BiomeSource bs = fixBiomeSource(referenceGenerator.getBiomeSource(), biomes);
InternalBiomeAPI.applyModifications(bs, dimensionKey);
referenceGenerator = new BCLChunkGenerator(
generator.bclib_getStructureSetsRegistry(),
noiseProvider.bclib_getNoises(),
bs,
fixNoiseSettings(
referenceProvider.bclib_getNoiseGeneratorSettingHolders(),
noiseProvider.bclib_getNoiseGeneratorSettingHolders(),
bs
)
);
}
}
}