[Feature] More flexible/extensible End-Biome Placement

This commit is contained in:
Frank 2022-07-08 00:12:39 +02:00
parent 0a75eb0c5d
commit 8861c0645f
9 changed files with 394 additions and 61 deletions

View file

@ -67,6 +67,7 @@ public class BCLibEndBiomeSource extends BCLBiomeSource implements BiomeSourceWi
private BiomePicker endVoidBiomePicker; private BiomePicker endVoidBiomePicker;
private BiomePicker endCenterBiomePicker; private BiomePicker endCenterBiomePicker;
private BiomePicker endBarrensBiomePicker; private BiomePicker endBarrensBiomePicker;
private List<BiomeDecider> deciders;
private BCLEndBiomeSourceConfig config; private BCLEndBiomeSourceConfig config;
@ -111,6 +112,11 @@ public class BCLibEndBiomeSource extends BCLBiomeSource implements BiomeSourceWi
var includeMap = Configs.BIOMES_CONFIG.getBiomeIncludeMap(); var includeMap = Configs.BIOMES_CONFIG.getBiomeIncludeMap();
var excludeList = Configs.BIOMES_CONFIG.getExcludeMatching(BiomeAPI.BiomeType.END); var excludeList = Configs.BIOMES_CONFIG.getExcludeMatching(BiomeAPI.BiomeType.END);
this.deciders = BiomeDecider.DECIDERS.stream()
.filter(d -> d.canProvideFor(this))
.map(d -> d.createInstance(this))
.toList();
this.endLandBiomePicker = new BiomePicker(biomeRegistry); this.endLandBiomePicker = new BiomePicker(biomeRegistry);
this.endVoidBiomePicker = new BiomePicker(biomeRegistry); this.endVoidBiomePicker = new BiomePicker(biomeRegistry);
this.endCenterBiomePicker = new BiomePicker(biomeRegistry); this.endCenterBiomePicker = new BiomePicker(biomeRegistry);
@ -160,24 +166,36 @@ public class BCLibEndBiomeSource extends BCLBiomeSource implements BiomeSourceWi
} }
if (!didForceAdd) { if (!didForceAdd) {
if (BiomeAPI.wasRegisteredAs(biomeID, BiomeAPI.BiomeType.END_IGNORE)) { if (biomeID.equals(BCLBiomeRegistry.EMPTY_BIOME.getID())
|| bclBiome.getIntendedType().is(BiomeAPI.BiomeType.END_IGNORE)) {
//we should not add this biome anywhere, so just ignore it //we should not add this biome anywhere, so just ignore it
} else if (BiomeAPI.wasRegisteredAs(biomeID, BiomeAPI.BiomeType.END_CENTER)
|| TheEndBiomesHelper.canGenerateAsMainIslandBiome(key)) {
endCenterBiomePicker.addBiome(bclBiome);
} else if (BiomeAPI.wasRegisteredAs(biomeID, BiomeAPI.BiomeType.END_LAND)
|| TheEndBiomesHelper.canGenerateAsHighlandsBiome(key)) {
if (!config.withVoidBiomes) endVoidBiomePicker.addBiome(bclBiome);
endLandBiomePicker.addBiome(bclBiome);
} else if (BiomeAPI.wasRegisteredAs(biomeID, BiomeAPI.BiomeType.END_BARRENS)
|| TheEndBiomesHelper.canGenerateAsEndBarrens(key)) {
endBarrensBiomePicker.addBiome(bclBiome);
} else if (BiomeAPI.wasRegisteredAs(biomeID, BiomeAPI.BiomeType.END_VOID)
|| TheEndBiomesHelper.canGenerateAsSmallIslandsBiome(key)) {
endVoidBiomePicker.addBiome(bclBiome);
} else { } else {
BCLib.LOGGER.info("Found End Biome " + biomeStr + " that was not registers with fabric or bclib. Assuming end-land Biome..."); didForceAdd = false;
endLandBiomePicker.addBiome(bclBiome); for (BiomeDecider decider : deciders) {
if (decider.addToPicker(bclBiome)) {
didForceAdd = true;
break;
}
}
if (!didForceAdd) {
if (bclBiome.getIntendedType().is(BiomeAPI.BiomeType.END_CENTER)
|| TheEndBiomesHelper.canGenerateAsMainIslandBiome(key)) {
endCenterBiomePicker.addBiome(bclBiome);
} else if (bclBiome.getIntendedType().is(BiomeAPI.BiomeType.END_LAND)
|| TheEndBiomesHelper.canGenerateAsHighlandsBiome(key)) {
if (!config.withVoidBiomes) endVoidBiomePicker.addBiome(bclBiome);
endLandBiomePicker.addBiome(bclBiome);
} else if (bclBiome.getIntendedType().is(BiomeAPI.BiomeType.END_BARRENS)
|| TheEndBiomesHelper.canGenerateAsEndBarrens(key)) {
endBarrensBiomePicker.addBiome(bclBiome);
} else if (bclBiome.getIntendedType().is(BiomeAPI.BiomeType.END_VOID)
|| TheEndBiomesHelper.canGenerateAsSmallIslandsBiome(key)) {
endVoidBiomePicker.addBiome(bclBiome);
} else {
BCLib.LOGGER.info("Found End Biome " + biomeStr + " that was not registers with fabric or bclib. Assuming end-land Biome...");
endLandBiomePicker.addBiome(bclBiome);
}
}
} }
} }
} }
@ -189,6 +207,10 @@ public class BCLibEndBiomeSource extends BCLBiomeSource implements BiomeSourceWi
endBarrensBiomePicker.rebuild(); endBarrensBiomePicker.rebuild();
endCenterBiomePicker.rebuild(); endCenterBiomePicker.rebuild();
for (BiomeDecider decider : deciders) {
decider.rebuild();
}
if (endVoidBiomePicker.isEmpty()) { if (endVoidBiomePicker.isEmpty()) {
BCLib.LOGGER.info("No Void Biomes found. Disabling by using barrens"); BCLib.LOGGER.info("No Void Biomes found. Disabling by using barrens");
endVoidBiomePicker = endBarrensBiomePicker; endVoidBiomePicker = endBarrensBiomePicker;
@ -266,25 +288,32 @@ public class BCLibEndBiomeSource extends BCLBiomeSource implements BiomeSourceWi
@Override @Override
protected void onInitMap(long seed) { protected void onInitMap(long seed) {
this.mapLand = config.mapVersion.mapBuilder.apply( for (BiomeDecider decider : deciders) {
decider.createMap((picker, size) -> config.mapVersion.mapBuilder.create(
seed,
size <= 0 ? config.landBiomesSize : size,
picker
));
}
this.mapLand = config.mapVersion.mapBuilder.create(
seed, seed,
config.landBiomesSize, config.landBiomesSize,
endLandBiomePicker endLandBiomePicker
); );
this.mapVoid = config.mapVersion.mapBuilder.apply( this.mapVoid = config.mapVersion.mapBuilder.create(
seed, seed,
config.voidBiomesSize, config.voidBiomesSize,
endVoidBiomePicker endVoidBiomePicker
); );
this.mapCenter = config.mapVersion.mapBuilder.apply( this.mapCenter = config.mapVersion.mapBuilder.create(
seed, seed,
config.centerBiomesSize, config.centerBiomesSize,
endCenterBiomePicker endCenterBiomePicker
); );
this.mapBarrens = config.mapVersion.mapBuilder.apply( this.mapBarrens = config.mapVersion.mapBuilder.create(
seed, seed,
config.barrensBiomesSize, config.barrensBiomesSize,
endBarrensBiomePicker endBarrensBiomePicker
@ -315,39 +344,74 @@ public class BCLibEndBiomeSource extends BCLBiomeSource implements BiomeSourceWi
mapVoid.clearCache(); mapVoid.clearCache();
mapCenter.clearCache(); mapCenter.clearCache();
mapVoid.clearCache(); mapVoid.clearCache();
for (BiomeDecider decider : deciders) {
decider.clearMapCache();
}
} }
if (config.generatorVersion == BCLEndBiomeSourceConfig.EndBiomeGeneratorType.VANILLA || endLandFunction == null) { BiomeAPI.BiomeType suggestedType;
if (dist <= (long) config.innerVoidRadiusSquared) {
return mapCenter.getBiome(posX, biomeY << 2, posZ).biome; if (config.generatorVersion == BCLEndBiomeSourceConfig.EndBiomeGeneratorType.VANILLA) {
}
int x = (SectionPos.blockToSectionCoord(posX) * 2 + 1) * 8; int x = (SectionPos.blockToSectionCoord(posX) * 2 + 1) * 8;
int z = (SectionPos.blockToSectionCoord(posZ) * 2 + 1) * 8; int z = (SectionPos.blockToSectionCoord(posZ) * 2 + 1) * 8;
double d = sampler.erosion().compute(new DensityFunction.SinglePointContext(x, posY, z)); double d = sampler.erosion().compute(new DensityFunction.SinglePointContext(x, posY, z));
if (d > 0.25) { if (dist <= (long) config.innerVoidRadiusSquared) {
return mapLand.getBiome(posX, biomeY << 2, posZ).biome; //highlands suggestedType = BiomeAPI.BiomeType.END_CENTER;
} else if (d >= -0.0625) {
return mapLand.getBiome(posX, biomeY << 2, posZ).biome; //midlands
} else { } else {
return d < -0.21875 if (d > 0.25) {
? mapVoid.getBiome(posX, biomeY << 2, posZ).biome //small islands suggestedType = BiomeAPI.BiomeType.END_LAND; //highlands
: (config.withVoidBiomes ? mapBarrens : mapLand).getBiome( } else if (d >= -0.0625) {
suggestedType = BiomeAPI.BiomeType.END_LAND; //midlands
} else {
suggestedType = d < -0.21875
? BiomeAPI.BiomeType.END_VOID //small islands
: (config.withVoidBiomes
? BiomeAPI.BiomeType.END_BARRENS
: BiomeAPI.BiomeType.END_LAND); //barrens
}
}
final BiomeAPI.BiomeType originalType = suggestedType;
for (BiomeDecider decider : deciders) {
suggestedType = decider
.suggestType(
originalType,
suggestedType,
d,
maxHeight,
posX, posX,
biomeY << 2, posY,
posZ posZ,
).biome; //barrens biomeX,
biomeY,
biomeZ
);
} }
} else { } else {
pos.setLocation(biomeX, biomeZ); pos.setLocation(biomeX, biomeZ);
if (endLandFunction.apply(pos, maxHeight)) { final BiomeAPI.BiomeType originalType = (dist <= (long) config.innerVoidRadiusSquared
return (dist <= (long) config.innerVoidRadiusSquared ? mapCenter : mapLand) ? BiomeAPI.BiomeType.END_CENTER
.getBiome(posX, biomeY << 2, posZ).biome; : BiomeAPI.BiomeType.END_LAND);
} else { suggestedType = originalType;
return (dist <= (long) config.innerVoidRadiusSquared ? mapBarrens : mapVoid)
.getBiome(posX, biomeY << 2, posZ).biome; for (BiomeDecider decider : deciders) {
suggestedType = decider
.suggestType(originalType, suggestedType, maxHeight, posX, posY, posZ, biomeX, biomeY, biomeZ);
} }
} }
BiomePicker.ActualBiome result;
for (BiomeDecider decider : deciders) {
if (decider.canProvideBiome(suggestedType)) {
result = decider.provideBiome(suggestedType, posX, posY, posZ);
if (result != null) return result.biome;
}
}
if (suggestedType.is(BiomeAPI.BiomeType.END_CENTER)) return mapCenter.getBiome(posX, posY, posZ).biome;
if (suggestedType.is(BiomeAPI.BiomeType.END_VOID)) return mapVoid.getBiome(posX, posY, posZ).biome;
if (suggestedType.is(BiomeAPI.BiomeType.END_BARRENS)) return mapBarrens.getBiome(posX, posY, posZ).biome;
return mapLand.getBiome(posX, posY, posZ).biome;
} }

View file

@ -2,13 +2,13 @@ package org.betterx.bclib.api.v2.generator;
import org.betterx.bclib.BCLib; import org.betterx.bclib.BCLib;
import org.betterx.bclib.api.v2.generator.config.BCLNetherBiomeSourceConfig; import org.betterx.bclib.api.v2.generator.config.BCLNetherBiomeSourceConfig;
import org.betterx.bclib.api.v2.generator.config.MapBuilderFunction;
import org.betterx.bclib.api.v2.generator.map.MapStack; import org.betterx.bclib.api.v2.generator.map.MapStack;
import org.betterx.bclib.api.v2.levelgen.biomes.BCLBiome; import org.betterx.bclib.api.v2.levelgen.biomes.BCLBiome;
import org.betterx.bclib.api.v2.levelgen.biomes.BCLBiomeRegistry; import org.betterx.bclib.api.v2.levelgen.biomes.BCLBiomeRegistry;
import org.betterx.bclib.api.v2.levelgen.biomes.BiomeAPI; import org.betterx.bclib.api.v2.levelgen.biomes.BiomeAPI;
import org.betterx.bclib.config.Configs; import org.betterx.bclib.config.Configs;
import org.betterx.bclib.interfaces.BiomeMap; import org.betterx.bclib.interfaces.BiomeMap;
import org.betterx.bclib.util.TriFunction;
import org.betterx.worlds.together.biomesource.BiomeSourceWithConfig; import org.betterx.worlds.together.biomesource.BiomeSourceWithConfig;
import org.betterx.worlds.together.biomesource.ReloadableBiomeSource; import org.betterx.worlds.together.biomesource.ReloadableBiomeSource;
@ -181,7 +181,7 @@ public class BCLibNetherBiomeSource extends BCLBiomeSource implements BiomeSourc
@Override @Override
protected void onInitMap(long seed) { protected void onInitMap(long seed) {
TriFunction<Long, Integer, BiomePicker, BiomeMap> mapConstructor = config.mapVersion.mapBuilder; MapBuilderFunction mapConstructor = config.mapVersion.mapBuilder;
if (maxHeight > config.biomeSizeVertical * 1.5 && config.useVerticalBiomes) { if (maxHeight > config.biomeSizeVertical * 1.5 && config.useVerticalBiomes) {
this.biomeMap = new MapStack( this.biomeMap = new MapStack(
seed, seed,
@ -192,7 +192,7 @@ public class BCLibNetherBiomeSource extends BCLBiomeSource implements BiomeSourc
mapConstructor mapConstructor
); );
} else { } else {
this.biomeMap = mapConstructor.apply( this.biomeMap = mapConstructor.create(
seed, seed,
config.biomeSize, config.biomeSize,
biomePicker biomePicker

View file

@ -0,0 +1,264 @@
package org.betterx.bclib.api.v2.generator;
import org.betterx.bclib.api.v2.levelgen.biomes.BCLBiome;
import org.betterx.bclib.api.v2.levelgen.biomes.BiomeAPI;
import org.betterx.bclib.interfaces.BiomeMap;
import net.minecraft.core.Registry;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.level.biome.Biome;
import net.minecraft.world.level.biome.BiomeSource;
import java.util.LinkedList;
import java.util.List;
/**
* Used to extend the BiomePlacement in the {@link BCLBiomeSource}
*/
public abstract class BiomeDecider {
/**
* used to create new {@link BiomeMap} instances
*/
@FunctionalInterface
public interface BiomeMapBuilderFunction {
/**
* Constructs a new {@link BiomeMap}
*
* @param picker The picker the BiomeMap should use
* @param biomeSize The biomeSize the map will use or -1 for the default size
* @return a new {@link BiomeMap} instance
*/
BiomeMap create(BiomePicker picker, int biomeSize);
}
/**
* used to determine wether or not a decider can provide this biome
*/
@FunctionalInterface
public interface BiomePredicate {
boolean test(BCLBiome biome);
}
protected BiomePicker picker;
protected BiomeMap map;
private final BiomePredicate predicate;
static List<BiomeDecider> DECIDERS = new LinkedList<>();
/**
* Register a high priority Decider for the {@link BCLibEndBiomeSource}.
* Normally you should not need to register a high priority decider and instead use
* {@link BiomeDecider#registerDecider(ResourceLocation, BiomeDecider)}.
* BetterEnd (for example) will add
*
* @param location The {@link ResourceLocation} for the decider
* @param decider The initial decider Instance. Each Instance of the {@link BCLibEndBiomeSource}
* will call {@link BiomeDecider#createInstance(BCLBiomeSource)} to build a
* new instance of this decider
*/
public static void registerHighPriorityDecider(ResourceLocation location, BiomeDecider decider) {
if (DECIDERS.size() == 0) DECIDERS.add(decider);
else DECIDERS.add(0, decider);
}
/**
* Register a new Decider for the {@link BCLibEndBiomeSource}
*
* @param location The {@link ResourceLocation} for the decider
* @param decider The initial decider Instance. Each Instance of the {@link BCLibEndBiomeSource}
* will call {@link BiomeDecider#createInstance(BCLBiomeSource)} to build a
* new instance of this decider
*/
public static void registerDecider(ResourceLocation location, BiomeDecider decider) {
DECIDERS.add(decider);
}
protected BiomeDecider(BiomePredicate predicate) {
this(null, predicate);
}
/**
* @param biomeRegistry The biome registry assigned to the creating BiomeSource
* @param predicate A predicate that decides if a given Biome can be provided by this decider
*/
protected BiomeDecider(
Registry<Biome> biomeRegistry, BiomePredicate predicate
) {
this.predicate = predicate;
this.map = null;
if (biomeRegistry == null) {
this.picker = null;
} else {
this.picker = new BiomePicker(biomeRegistry);
}
}
/**
* Called to test, if a decider is suitable for the given BiomeSource.
*
* @param source The BiomeSource that wants to use the decider
* @return true, if this decider is usable by that source
*/
public abstract boolean canProvideFor(BiomeSource source);
/**
* Called from the BiomeSource whenever it needs to create a new instance of this decider.
* <p>
* Inheriting classes should overwrite this method and return Instances of the class. For
* the base {@link BiomeDecider} you would return <em>new BiomeDecider(biomeSource.biomeRegistry, this.predicate);</em>
*
* @param biomeSource The biome source this decider is used from
* @return A new instance
*/
public abstract BiomeDecider createInstance(BCLBiomeSource biomeSource);
/**
* Called when the BiomeSources needs to construct a new {@link BiomeMap} for the picker.
* <p>
* The default implementation creates a new map with the instances picker and a default biome size
*
* @param mapBuilder A function you can use to create a new {@link BiomeMap} that conforms to the settings
* of the current BiomeSource.
*/
public void createMap(BiomeMapBuilderFunction mapBuilder) {
this.map = mapBuilder.create(picker, -1);
}
/**
* called whenever the BiomeSource needs to clear caches
*/
public void clearMapCache() {
map.clearCache();
}
/**
* This method get's called whenever the BiomeSource populates the Biome Pickers. You need to
* determine if the passed Biome is valid for your picker.
* <p>
* If this method returns false, the Biome wil not get added to any other Deciders/Pickers.
* <p>
* The default implementation will use the instances {@link BiomeDecider#predicate} to determine if
* a biome should get added and return true if it was added.
*
* @param biome The biome that should get added if it matches the criteria of the picker
* @return false, if other pickers/deciders are allowed to use the biome as well
*/
public boolean addToPicker(BCLBiome biome) {
if (predicate.test(biome)) {
picker.addBiome(biome);
return true;
}
return false;
}
/**
* Called whenever the picker needs to rebuild it's contents
*/
public void rebuild() {
picker.rebuild();
}
/**
* Called from the BiomeSource to determine the type of Biome it needs to place.
*
* @param originalType The original biome type the source did select
* @param suggestedType The currently suggested type. This will differ from <em>originalType</em> if other
* {@link BiomeDecider} instances already had a new suggestion. You implementation should return the
* <em>suggestedType</em> if it does not want to provide the Biome for this location
* @param maxHeight The maximum terrain height for this world
* @param blockX The block coordinate where we are at
* @param blockY The block coordinate where we are at
* @param blockZ The block coordinate where we are at
* @param quarterX The quarter Block Coordinate (which is blockX/4)
* @param quarterY The quarter Block Coordinate (which is blockY/4)
* @param quarterZ The quarter Block Coordinate (which is blockZ/4)
* @return The <em>suggestedType</em> if this decider does not plan to provide a Biome, or a unique BiomeType.
* The Biome Source will call {@link BiomeDecider#selectBiome(BiomeAPI.BiomeType)} with the finally chosen type
* for all available Deciders.
*/
public BiomeAPI.BiomeType suggestType(
BiomeAPI.BiomeType originalType,
BiomeAPI.BiomeType suggestedType,
int maxHeight,
int blockX,
int blockY,
int blockZ,
int quarterX,
int quarterY,
int quarterZ
) {
return suggestType(
originalType,
suggestedType,
0,
maxHeight,
blockX,
blockY,
blockZ,
quarterX,
quarterY,
quarterZ
);
}
/**
* Called from the BiomeSource to determine the type of Biome it needs to place.
*
* @param originalType The original biome type the source did select
* @param suggestedType The currently suggested type. This will differ from <em>originalType</em> if other
* {@link BiomeDecider} instances already had a new suggestion. You implementation should return the
* <em>suggestedType</em> if it does not want to provide the Biome for this location
* @param density The terrain density at this location. Currently only valid if for {@link BCLibEndBiomeSource}
* that use the {@link org.betterx.bclib.api.v2.generator.config.BCLEndBiomeSourceConfig.EndBiomeGeneratorType#VANILLA}
* @param maxHeight The maximum terrain height for this world
* @param blockX The block coordinate where we are at
* @param blockY The block coordinate where we are at
* @param blockZ The block coordinate where we are at
* @param quarterX The quarter Block Coordinate (which is blockX/4)
* @param quarterY The quarter Block Coordinate (which is blockY/4)
* @param quarterZ The quarter Block Coordinate (which is blockZ/4)
* @param maxHeight
* @return The <em>suggestedType</em> if this decider does not plan to provide a Biome, or a unique BiomeType.
* The Biome Source will call {@link BiomeDecider#selectBiome(BiomeAPI.BiomeType)} with the finally chosen type
* for all available Deciders.
*/
public abstract BiomeAPI.BiomeType suggestType(
BiomeAPI.BiomeType originalType,
BiomeAPI.BiomeType suggestedType,
double density,
int maxHeight,
int blockX,
int blockY,
int blockZ,
int quarterX,
int quarterY,
int quarterZ
);
/**
* Called to check if this decider can place a biome for the specified type
*
* @param suggestedType The type of biome we need to place
* @return true, if this type of biome can be provided by the current picker. If true
* is returned, the BiomeSource will call {@link BiomeDecider#provideBiome(BiomeAPI.BiomeType, int, int, int)}
* next
*/
public abstract boolean canProvideBiome(BiomeAPI.BiomeType suggestedType);
/**
* Called to check if this decider can place a biome for the specified type
* <p>
* The default implementation will return <em>map.getBiome(posX, posY, posZ)</em>
*
* @param suggestedType The type of biome we need to place
* @return The methode should return a Biome from its {@link BiomeMap}. If null is returned, the next
* decider (or the default map) will provide the biome
*/
public BiomePicker.ActualBiome provideBiome(BiomeAPI.BiomeType suggestedType, int posX, int posY, int posZ) {
return map.getBiome(posX, posY, posZ);
}
}

View file

@ -7,7 +7,7 @@ import java.util.function.BiFunction;
import java.util.function.Function; import java.util.function.Function;
public class GeneratorOptions { public class GeneratorOptions {
private static BiFunction<Point, Integer, Boolean> endLandFunction; //private static BiFunction<Point, Integer, Boolean> endLandFunction;
private static boolean fixEndBiomeSource = true; private static boolean fixEndBiomeSource = true;
private static boolean fixNetherBiomeSource = true; private static boolean fixNetherBiomeSource = true;
@ -42,15 +42,17 @@ public class GeneratorOptions {
*/ */
@Deprecated(forRemoval = true) @Deprecated(forRemoval = true)
public static void setEndLandFunction(Function<Point, Boolean> endLandFunction) { public static void setEndLandFunction(Function<Point, Boolean> endLandFunction) {
GeneratorOptions.endLandFunction = (p, h) -> endLandFunction.apply(p); //GeneratorOptions.endLandFunction = (p, h) -> endLandFunction.apply(p);
} }
@Deprecated(forRemoval = true)
public static void setEndLandFunction(BiFunction<Point, Integer, Boolean> endLandFunction) { public static void setEndLandFunction(BiFunction<Point, Integer, Boolean> endLandFunction) {
GeneratorOptions.endLandFunction = endLandFunction; ///GeneratorOptions.endLandFunction = endLandFunction;
} }
@Deprecated(forRemoval = true)
public static BiFunction<Point, Integer, Boolean> getEndLandFunction() { public static BiFunction<Point, Integer, Boolean> getEndLandFunction() {
return endLandFunction; return (a, b) -> true;//endLandFunction;
} }
@Deprecated(forRemoval = true) @Deprecated(forRemoval = true)

View file

@ -2,11 +2,8 @@ package org.betterx.bclib.api.v2.generator.config;
import org.betterx.bclib.BCLib; import org.betterx.bclib.BCLib;
import org.betterx.bclib.api.v2.generator.BCLibEndBiomeSource; import org.betterx.bclib.api.v2.generator.BCLibEndBiomeSource;
import org.betterx.bclib.api.v2.generator.BiomePicker;
import org.betterx.bclib.api.v2.generator.map.hex.HexBiomeMap; import org.betterx.bclib.api.v2.generator.map.hex.HexBiomeMap;
import org.betterx.bclib.api.v2.generator.map.square.SquareBiomeMap; import org.betterx.bclib.api.v2.generator.map.square.SquareBiomeMap;
import org.betterx.bclib.interfaces.BiomeMap;
import org.betterx.bclib.util.TriFunction;
import org.betterx.worlds.together.biomesource.config.BiomeSourceConfig; import org.betterx.worlds.together.biomesource.config.BiomeSourceConfig;
import com.mojang.serialization.Codec; import com.mojang.serialization.Codec;
@ -114,9 +111,9 @@ public class BCLEndBiomeSourceConfig implements BiomeSourceConfig<BCLibEndBiomeS
public static final Codec<EndBiomeMapType> CODEC = StringRepresentable.fromEnum(EndBiomeMapType::values); public static final Codec<EndBiomeMapType> CODEC = StringRepresentable.fromEnum(EndBiomeMapType::values);
public final String name; public final String name;
public final @NotNull TriFunction<Long, Integer, BiomePicker, BiomeMap> mapBuilder; public final @NotNull MapBuilderFunction mapBuilder;
EndBiomeMapType(String name, @NotNull TriFunction<Long, Integer, BiomePicker, BiomeMap> mapBuilder) { EndBiomeMapType(String name, @NotNull MapBuilderFunction mapBuilder) {
this.name = name; this.name = name;
this.mapBuilder = mapBuilder; this.mapBuilder = mapBuilder;
} }

View file

@ -1,11 +1,8 @@
package org.betterx.bclib.api.v2.generator.config; package org.betterx.bclib.api.v2.generator.config;
import org.betterx.bclib.api.v2.generator.BCLibNetherBiomeSource; import org.betterx.bclib.api.v2.generator.BCLibNetherBiomeSource;
import org.betterx.bclib.api.v2.generator.BiomePicker;
import org.betterx.bclib.api.v2.generator.map.hex.HexBiomeMap; import org.betterx.bclib.api.v2.generator.map.hex.HexBiomeMap;
import org.betterx.bclib.api.v2.generator.map.square.SquareBiomeMap; import org.betterx.bclib.api.v2.generator.map.square.SquareBiomeMap;
import org.betterx.bclib.interfaces.BiomeMap;
import org.betterx.bclib.util.TriFunction;
import org.betterx.worlds.together.biomesource.config.BiomeSourceConfig; import org.betterx.worlds.together.biomesource.config.BiomeSourceConfig;
import com.mojang.serialization.Codec; import com.mojang.serialization.Codec;
@ -110,9 +107,9 @@ public class BCLNetherBiomeSourceConfig implements BiomeSourceConfig<BCLibNether
public static final Codec<NetherBiomeMapType> CODEC = StringRepresentable.fromEnum(NetherBiomeMapType::values); public static final Codec<NetherBiomeMapType> CODEC = StringRepresentable.fromEnum(NetherBiomeMapType::values);
public final String name; public final String name;
public final TriFunction<Long, Integer, BiomePicker, BiomeMap> mapBuilder; public final MapBuilderFunction mapBuilder;
NetherBiomeMapType(String name, TriFunction<Long, Integer, BiomePicker, BiomeMap> mapBuilder) { NetherBiomeMapType(String name, MapBuilderFunction mapBuilder) {
this.name = name; this.name = name;
this.mapBuilder = mapBuilder; this.mapBuilder = mapBuilder;
} }

View file

@ -0,0 +1,9 @@
package org.betterx.bclib.api.v2.generator.config;
import org.betterx.bclib.api.v2.generator.BiomePicker;
import org.betterx.bclib.interfaces.BiomeMap;
@FunctionalInterface
public interface MapBuilderFunction {
BiomeMap create(long seed, int biomeSize, BiomePicker picker);
}

View file

@ -1,11 +1,11 @@
package org.betterx.bclib.api.v2.generator.map; package org.betterx.bclib.api.v2.generator.map;
import org.betterx.bclib.api.v2.generator.BiomePicker; import org.betterx.bclib.api.v2.generator.BiomePicker;
import org.betterx.bclib.api.v2.generator.config.MapBuilderFunction;
import org.betterx.bclib.interfaces.BiomeChunk; import org.betterx.bclib.interfaces.BiomeChunk;
import org.betterx.bclib.interfaces.BiomeMap; import org.betterx.bclib.interfaces.BiomeMap;
import org.betterx.bclib.interfaces.TriConsumer; import org.betterx.bclib.interfaces.TriConsumer;
import org.betterx.bclib.noise.OpenSimplexNoise; import org.betterx.bclib.noise.OpenSimplexNoise;
import org.betterx.bclib.util.TriFunction;
import net.minecraft.util.Mth; import net.minecraft.util.Mth;
@ -26,7 +26,7 @@ public class MapStack implements BiomeMap {
BiomePicker picker, BiomePicker picker,
int mapHeight, int mapHeight,
int worldHeight, int worldHeight,
TriFunction<Long, Integer, BiomePicker, BiomeMap> mapConstructor MapBuilderFunction mapConstructor
) { ) {
final int mapCount = Mth.ceil((float) worldHeight / mapHeight); final int mapCount = Mth.ceil((float) worldHeight / mapHeight);
this.maxIndex = mapCount - 1; this.maxIndex = mapCount - 1;
@ -37,7 +37,7 @@ public class MapStack implements BiomeMap {
maps = new BiomeMap[mapCount]; maps = new BiomeMap[mapCount];
Random random = new Random(seed); Random random = new Random(seed);
for (int i = 0; i < mapCount; i++) { for (int i = 0; i < mapCount; i++) {
maps[i] = mapConstructor.apply(random.nextLong(), size, picker); maps[i] = mapConstructor.create(random.nextLong(), size, picker);
maps[i].setChunkProcessor(this::onChunkCreation); maps[i].setChunkProcessor(this::onChunkCreation);
} }
noise = new OpenSimplexNoise(random.nextInt()); noise = new OpenSimplexNoise(random.nextInt());

View file

@ -290,7 +290,7 @@ public class BCLBiome extends BCLBiomeSettings implements BiomeData {
return this; return this;
} }
BiomeAPI.BiomeType getIntendedType() { public BiomeAPI.BiomeType getIntendedType() {
return this.intendedType; return this.intendedType;
} }