Non default Terrain Heights for EndBiomeSource
This commit is contained in:
parent
35b968eb93
commit
73cd08fa69
6 changed files with 63 additions and 33 deletions
|
@ -73,7 +73,7 @@ public class BCLChunkGenerator extends NoiseBasedChunkGenerator {
|
||||||
if (BCLib.RUNS_TERRABLENDER) {
|
if (BCLib.RUNS_TERRABLENDER) {
|
||||||
BCLib.LOGGER.info("Make sure features are loaded from terrablender for " + biomeSource);
|
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
|
//we redo it at this point, otherwise we will get blank biomes
|
||||||
rebuildFeaturesPerStep(biomeSource);
|
rebuildFeaturesPerStep(biomeSource);
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,7 +34,7 @@ import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.function.Function;
|
import java.util.function.BiFunction;
|
||||||
|
|
||||||
public class BCLibEndBiomeSource extends BCLBiomeSource {
|
public class BCLibEndBiomeSource extends BCLBiomeSource {
|
||||||
private static final OpenSimplexNoise SMALL_NOISE = new OpenSimplexNoise(8324);
|
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> centerBiome;
|
||||||
private final Holder<Biome> barrens;
|
private final Holder<Biome> barrens;
|
||||||
private final Point pos;
|
private final Point pos;
|
||||||
private final Function<Point, Boolean> endLandFunction;
|
private final BiFunction<Point, Integer, Boolean> endLandFunction;
|
||||||
private SimplexNoise noise;
|
private SimplexNoise noise;
|
||||||
private BiomeMap mapLand;
|
private BiomeMap mapLand;
|
||||||
private BiomeMap mapVoid;
|
private BiomeMap mapVoid;
|
||||||
|
|
||||||
|
private static int worldHeight;
|
||||||
|
|
||||||
private final BiomePicker endLandBiomePicker;
|
private final BiomePicker endLandBiomePicker;
|
||||||
private final BiomePicker endVoidBiomePicker;
|
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) {
|
private static List<Holder<Biome>> getBclBiomes(Registry<Biome> biomeRegistry) {
|
||||||
List<String> include = Configs.BIOMES_CONFIG.getEntry(
|
List<String> include = Configs.BIOMES_CONFIG.getEntry(
|
||||||
"force_include",
|
"force_include",
|
||||||
|
@ -320,7 +331,7 @@ public class BCLibEndBiomeSource extends BCLBiomeSource {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
pos.setLocation(biomeX, biomeZ);
|
pos.setLocation(biomeX, biomeZ);
|
||||||
if (endLandFunction.apply(pos)) {
|
if (endLandFunction.apply(pos, worldHeight)) {
|
||||||
return dist <= farEndBiomes ? centerBiome : mapLand.getBiome(posX, biomeY << 2, posZ).biome;
|
return dist <= farEndBiomes ? centerBiome : mapLand.getBiome(posX, biomeY << 2, posZ).biome;
|
||||||
} else {
|
} else {
|
||||||
return dist <= farEndBiomes ? barrens : mapVoid.getBiome(posX, biomeY << 2, posZ).biome;
|
return dist <= farEndBiomes ? barrens : mapVoid.getBiome(posX, biomeY << 2, posZ).biome;
|
||||||
|
|
|
@ -5,14 +5,14 @@ import org.betterx.bclib.config.Configs;
|
||||||
import net.minecraft.util.Mth;
|
import net.minecraft.util.Mth;
|
||||||
|
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.util.function.Function;
|
import java.util.function.BiFunction;
|
||||||
|
|
||||||
public class GeneratorOptions {
|
public class GeneratorOptions {
|
||||||
private static int biomeSizeNether;
|
private static int biomeSizeNether;
|
||||||
private static int biomeVSizeNether;
|
private static int biomeVSizeNether;
|
||||||
private static int biomeSizeEndLand;
|
private static int biomeSizeEndLand;
|
||||||
private static int biomeSizeEndVoid;
|
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 customNetherBiomeSource = true;
|
||||||
private static boolean customEndBiomeSource = true;
|
private static boolean customEndBiomeSource = true;
|
||||||
private static boolean verticalBiomes = true;
|
private static boolean verticalBiomes = true;
|
||||||
|
@ -52,11 +52,11 @@ public class GeneratorOptions {
|
||||||
return Mth.clamp(biomeSizeEndVoid, 1, 8192);
|
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;
|
GeneratorOptions.endLandFunction = endLandFunction;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Function<Point, Boolean> getEndLandFunction() {
|
public static BiFunction<Point, Integer, Boolean> getEndLandFunction() {
|
||||||
return endLandFunction;
|
return endLandFunction;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -348,7 +348,11 @@ public class LevelGenUtil {
|
||||||
}
|
}
|
||||||
|
|
||||||
BCLib.LOGGER.info("Set world to BiomeSource Version " + biomeSourceVersion);
|
BCLib.LOGGER.info("Set world to BiomeSource Version " + biomeSourceVersion);
|
||||||
BCLWorldPreset.writeWorldPresetSettings(new BCLWorldPresetSettings(biomeSourceVersion, biomeSourceVersion));
|
BCLWorldPreset.writeWorldPresetSettings(new BCLWorldPresetSettings(
|
||||||
|
biomeSourceVersion,
|
||||||
|
biomeSourceVersion,
|
||||||
|
true
|
||||||
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,7 @@ package org.betterx.bclib.mixin.common;
|
||||||
|
|
||||||
import org.betterx.bclib.api.v2.LifeCycleAPI;
|
import org.betterx.bclib.api.v2.LifeCycleAPI;
|
||||||
import org.betterx.bclib.api.v2.generator.BCLBiomeSource;
|
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 org.betterx.bclib.api.v2.generator.BCLibNetherBiomeSource;
|
||||||
|
|
||||||
import net.minecraft.core.Holder;
|
import net.minecraft.core.Holder;
|
||||||
|
@ -76,7 +77,10 @@ public abstract class ServerLevelMixin extends Level {
|
||||||
|
|
||||||
if (level.dimension() == Level.NETHER) {
|
if (level.dimension() == Level.NETHER) {
|
||||||
BCLibNetherBiomeSource.setWorldHeight(level.getChunkSource().getGenerator().getGenDepth());
|
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) {
|
if (levelStem.generator().getBiomeSource() instanceof BCLBiomeSource source) {
|
||||||
source.setSeed(level.getSeed());
|
source.setSeed(level.getSeed());
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,7 @@ package org.betterx.bclib.presets.worldgen;
|
||||||
import org.betterx.bclib.BCLib;
|
import org.betterx.bclib.BCLib;
|
||||||
import org.betterx.bclib.api.v2.generator.BCLBiomeSource;
|
import org.betterx.bclib.api.v2.generator.BCLBiomeSource;
|
||||||
import org.betterx.bclib.api.v2.generator.BCLChunkGenerator;
|
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.LevelGenUtil;
|
||||||
import org.betterx.bclib.api.v2.levelgen.biomes.InternalBiomeAPI;
|
import org.betterx.bclib.api.v2.levelgen.biomes.InternalBiomeAPI;
|
||||||
import org.betterx.bclib.api.v2.levelgen.surface.SurfaceRuleUtil;
|
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
|
public static final Codec<BCLWorldPresetSettings> CODEC = RecordCodecBuilder
|
||||||
.create((RecordCodecBuilder.Instance<BCLWorldPresetSettings> builderInstance) -> {
|
.create((RecordCodecBuilder.Instance<BCLWorldPresetSettings> builderInstance) -> {
|
||||||
RecordCodecBuilder<BCLWorldPresetSettings, Integer> netherVersion = Codec.INT
|
return builderInstance.group(
|
||||||
.fieldOf(LevelStem.NETHER.location().toString())
|
Codec.INT
|
||||||
.forGetter((BCLWorldPresetSettings settings) -> settings.netherVersion);
|
.fieldOf(LevelStem.NETHER.location().toString())
|
||||||
|
.forGetter(o -> o.netherVersion),
|
||||||
RecordCodecBuilder<BCLWorldPresetSettings, Integer> endVersion = Codec.INT
|
Codec.INT
|
||||||
.fieldOf(LevelStem.END.location().toString())
|
.fieldOf(LevelStem.END.location().toString())
|
||||||
.forGetter((BCLWorldPresetSettings settings) -> settings.endVersion);
|
.forGetter(o -> o.endVersion),
|
||||||
|
Codec.BOOL
|
||||||
|
.fieldOf("custom_end_terrain")
|
||||||
return builderInstance.group(netherVersion, endVersion)
|
.orElse(true)
|
||||||
|
.forGetter(o -> o.useEndTerrainGenerator)
|
||||||
|
)
|
||||||
.apply(builderInstance, builderInstance.stable(BCLWorldPresetSettings::new));
|
.apply(builderInstance, builderInstance.stable(BCLWorldPresetSettings::new));
|
||||||
});
|
});
|
||||||
public final int netherVersion;
|
public final int netherVersion;
|
||||||
public final int endVersion;
|
public final int endVersion;
|
||||||
|
public final boolean useEndTerrainGenerator;
|
||||||
|
|
||||||
public BCLWorldPresetSettings(int version) {
|
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.netherVersion = netherVersion;
|
||||||
this.endVersion = endVersion;
|
this.endVersion = endVersion;
|
||||||
|
this.useEndTerrainGenerator = endVersion != BCLibEndBiomeSource.BIOME_SOURCE_VERSION_VANILLA && useEndTerrainGenerator;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -114,7 +118,8 @@ public class BCLWorldPresetSettings extends WorldPresetSettings {
|
||||||
return biomeSource;
|
return biomeSource;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Holder<NoiseGeneratorSettings> fixNoiseSettings(
|
private Holder<NoiseGeneratorSettings> fixNoiseSettings(
|
||||||
|
Holder<NoiseGeneratorSettings> reference,
|
||||||
Holder<NoiseGeneratorSettings> settings,
|
Holder<NoiseGeneratorSettings> settings,
|
||||||
BiomeSource biomeSource
|
BiomeSource biomeSource
|
||||||
) {
|
) {
|
||||||
|
@ -147,7 +152,7 @@ public class BCLWorldPresetSettings extends WorldPresetSettings {
|
||||||
* @param settings
|
* @param settings
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public WorldGenSettings fixSettingsInCurrentWorld(
|
private WorldGenSettings fixSettingsInCurrentWorld(
|
||||||
RegistryAccess access, ResourceKey<LevelStem> dimensionKey,
|
RegistryAccess access, ResourceKey<LevelStem> dimensionKey,
|
||||||
ResourceKey<DimensionType> dimensionTypeKey,
|
ResourceKey<DimensionType> dimensionTypeKey,
|
||||||
WorldGenSettings settings
|
WorldGenSettings settings
|
||||||
|
@ -179,15 +184,21 @@ public class BCLWorldPresetSettings extends WorldPresetSettings {
|
||||||
|
|
||||||
if (loadedChunkGenerator instanceof ChunkGeneratorAccessor generator) {
|
if (loadedChunkGenerator instanceof ChunkGeneratorAccessor generator) {
|
||||||
if (loadedChunkGenerator instanceof NoiseGeneratorSettingsProvider noiseProvider) {
|
if (loadedChunkGenerator instanceof NoiseGeneratorSettingsProvider noiseProvider) {
|
||||||
final Set<Holder<Biome>> biomes = loadedChunkGenerator.getBiomeSource().possibleBiomes();
|
if (referenceGenerator instanceof NoiseGeneratorSettingsProvider referenceProvider) {
|
||||||
final BiomeSource bs = fixBiomeSource(referenceGenerator.getBiomeSource(), biomes);
|
final Set<Holder<Biome>> biomes = loadedChunkGenerator.getBiomeSource().possibleBiomes();
|
||||||
InternalBiomeAPI.applyModifications(bs, dimensionKey);
|
final BiomeSource bs = fixBiomeSource(referenceGenerator.getBiomeSource(), biomes);
|
||||||
referenceGenerator = new BCLChunkGenerator(
|
InternalBiomeAPI.applyModifications(bs, dimensionKey);
|
||||||
generator.bclib_getStructureSetsRegistry(),
|
referenceGenerator = new BCLChunkGenerator(
|
||||||
noiseProvider.bclib_getNoises(),
|
generator.bclib_getStructureSetsRegistry(),
|
||||||
bs,
|
noiseProvider.bclib_getNoises(),
|
||||||
fixNoiseSettings(noiseProvider.bclib_getNoiseGeneratorSettingHolders(), bs)
|
bs,
|
||||||
);
|
fixNoiseSettings(
|
||||||
|
referenceProvider.bclib_getNoiseGeneratorSettingHolders(),
|
||||||
|
noiseProvider.bclib_getNoiseGeneratorSettingHolders(),
|
||||||
|
bs
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue