Better logging
This commit is contained in:
parent
a988083417
commit
8f9c33e378
9 changed files with 99 additions and 23 deletions
|
@ -1,8 +1,10 @@
|
||||||
package org.betterx.bclib.api.v2.generator;
|
package org.betterx.bclib.api.v2.generator;
|
||||||
|
|
||||||
|
import org.betterx.bclib.BCLib;
|
||||||
import org.betterx.bclib.api.v2.levelgen.biomes.BiomeAPI;
|
import org.betterx.bclib.api.v2.levelgen.biomes.BiomeAPI;
|
||||||
import org.betterx.bclib.api.v2.levelgen.biomes.InternalBiomeAPI;
|
import org.betterx.bclib.api.v2.levelgen.biomes.InternalBiomeAPI;
|
||||||
import org.betterx.worlds.together.biomesource.BiomeSourceFromRegistry;
|
import org.betterx.worlds.together.biomesource.BiomeSourceFromRegistry;
|
||||||
|
import org.betterx.worlds.together.biomesource.BiomeSourceHelper;
|
||||||
import org.betterx.worlds.together.biomesource.MergeableBiomeSource;
|
import org.betterx.worlds.together.biomesource.MergeableBiomeSource;
|
||||||
import org.betterx.worlds.together.world.BiomeSourceWithNoiseRelatedSettings;
|
import org.betterx.worlds.together.world.BiomeSourceWithNoiseRelatedSettings;
|
||||||
import org.betterx.worlds.together.world.BiomeSourceWithSeed;
|
import org.betterx.worlds.together.world.BiomeSourceWithSeed;
|
||||||
|
@ -19,6 +21,7 @@ import com.google.common.collect.Sets;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
public abstract class BCLBiomeSource extends BiomeSource implements BiomeSourceWithSeed, MergeableBiomeSource<BCLBiomeSource>, BiomeSourceWithNoiseRelatedSettings, BiomeSourceFromRegistry<BCLBiomeSource> {
|
public abstract class BCLBiomeSource extends BiomeSource implements BiomeSourceWithSeed, MergeableBiomeSource<BCLBiomeSource>, BiomeSourceWithNoiseRelatedSettings, BiomeSourceFromRegistry<BCLBiomeSource> {
|
||||||
protected final Registry<Biome> biomeRegistry;
|
protected final Registry<Biome> biomeRegistry;
|
||||||
|
@ -54,7 +57,7 @@ public abstract class BCLBiomeSource extends BiomeSource implements BiomeSourceW
|
||||||
|
|
||||||
final public void setSeed(long seed) {
|
final public void setSeed(long seed) {
|
||||||
if (seed != currentSeed) {
|
if (seed != currentSeed) {
|
||||||
System.out.println(this + " set Seed: " + seed);
|
BCLib.LOGGER.debug(this + "\n --> new seed = " + seed);
|
||||||
this.currentSeed = seed;
|
this.currentSeed = seed;
|
||||||
initMap(seed);
|
initMap(seed);
|
||||||
}
|
}
|
||||||
|
@ -67,14 +70,14 @@ public abstract class BCLBiomeSource extends BiomeSource implements BiomeSourceW
|
||||||
*/
|
*/
|
||||||
final public void setMaxHeight(int maxHeight) {
|
final public void setMaxHeight(int maxHeight) {
|
||||||
if (this.maxHeight != maxHeight) {
|
if (this.maxHeight != maxHeight) {
|
||||||
System.out.println(this + " set Max Height: " + maxHeight);
|
BCLib.LOGGER.debug(this + "\n --> new height = " + maxHeight);
|
||||||
this.maxHeight = maxHeight;
|
this.maxHeight = maxHeight;
|
||||||
onHeightChange(maxHeight);
|
onHeightChange(maxHeight);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected final void initMap(long seed) {
|
protected final void initMap(long seed) {
|
||||||
System.out.println(this + " updates Map");
|
BCLib.LOGGER.debug(this + "\n --> Map Update");
|
||||||
onInitMap(seed);
|
onInitMap(seed);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -89,6 +92,11 @@ public abstract class BCLBiomeSource extends BiomeSource implements BiomeSourceW
|
||||||
|
|
||||||
protected abstract BCLBiomeSource cloneForDatapack(Set<Holder<Biome>> datapackBiomes);
|
protected abstract BCLBiomeSource cloneForDatapack(Set<Holder<Biome>> datapackBiomes);
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
protected String getNamespaces() {
|
||||||
|
return BiomeSourceHelper.getNamespaces(possibleBiomes());
|
||||||
|
}
|
||||||
|
|
||||||
public interface ValidBiomePredicate {
|
public interface ValidBiomePredicate {
|
||||||
boolean isValid(Holder<Biome> biome, ResourceLocation location);
|
boolean isValid(Holder<Biome> biome, ResourceLocation location);
|
||||||
}
|
}
|
||||||
|
|
|
@ -78,13 +78,12 @@ public class BCLChunkGenerator extends NoiseBasedChunkGenerator implements Resto
|
||||||
}
|
}
|
||||||
|
|
||||||
if (WorldsTogether.RUNS_TERRABLENDER) {
|
if (WorldsTogether.RUNS_TERRABLENDER) {
|
||||||
BCLib.LOGGER.info("Make sure features are loaded from terrablender for " + biomeSource);
|
BCLib.LOGGER.info("Make sure features are loaded from terrablender" + biomeSource);
|
||||||
|
|
||||||
//terrablender is invalidating the feature initialization
|
//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);
|
||||||
}
|
}
|
||||||
System.out.println("Chunk Generator: " + this + " (biomeSource: " + biomeSource + ")");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void rebuildFeaturesPerStep(BiomeSource biomeSource) {
|
private void rebuildFeaturesPerStep(BiomeSource biomeSource) {
|
||||||
|
|
|
@ -31,7 +31,6 @@ import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.function.BiFunction;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
public class BCLibEndBiomeSource extends BCLBiomeSource implements BiomeSourceWithConfig<BCLibEndBiomeSource, BCLEndBiomeSourceConfig>, ReloadableBiomeSource {
|
public class BCLibEndBiomeSource extends BCLBiomeSource implements BiomeSourceWithConfig<BCLibEndBiomeSource, BCLEndBiomeSourceConfig>, ReloadableBiomeSource {
|
||||||
|
@ -57,7 +56,6 @@ public class BCLibEndBiomeSource extends BCLBiomeSource implements BiomeSourceWi
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
private final Point pos;
|
private final Point pos;
|
||||||
private final BiFunction<Point, Integer, Boolean> endLandFunction;
|
|
||||||
private BiomeMap mapLand;
|
private BiomeMap mapLand;
|
||||||
private BiomeMap mapVoid;
|
private BiomeMap mapVoid;
|
||||||
private BiomeMap mapCenter;
|
private BiomeMap mapCenter;
|
||||||
|
@ -99,7 +97,6 @@ public class BCLibEndBiomeSource extends BCLBiomeSource implements BiomeSourceWi
|
||||||
this.config = config;
|
this.config = config;
|
||||||
rebuildBiomePickers();
|
rebuildBiomePickers();
|
||||||
|
|
||||||
this.endLandFunction = GeneratorOptions.getEndLandFunction();
|
|
||||||
this.pos = new Point();
|
this.pos = new Point();
|
||||||
|
|
||||||
if (initMaps) {
|
if (initMaps) {
|
||||||
|
@ -434,7 +431,13 @@ public class BCLibEndBiomeSource extends BCLBiomeSource implements BiomeSourceWi
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "BCLib - The End BiomeSource (" + Integer.toHexString(hashCode()) + ", config=" + config + ", seed=" + currentSeed + ", height=" + maxHeight + ", customLand=" + (endLandFunction != null) + ", biomes=" + possibleBiomes().size() + ")";
|
return "\nBCLib - The End BiomeSource (" + Integer.toHexString(hashCode()) + ")" +
|
||||||
|
"\n biomes = " + possibleBiomes().size() +
|
||||||
|
"\n namespaces = " + getNamespaces() +
|
||||||
|
"\n seed = " + currentSeed +
|
||||||
|
"\n height = " + maxHeight +
|
||||||
|
"\n deciders = " + deciders.size() +
|
||||||
|
"\n config = " + config;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -96,8 +96,8 @@ public class BCLibNetherBiomeSource extends BCLBiomeSource implements BiomeSourc
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!BiomeAPI.hasBiome(biomeID)) {
|
if (!BiomeAPI.hasBiome(biomeID)) {
|
||||||
|
BCLBiome bclBiome = new BCLBiome(biomeID, biome.value(), BiomeAPI.BiomeType.NETHER);
|
||||||
BCLBiome bclBiome = new BCLBiome(biomeID, biome.value());
|
BiomeAPI.registerBiome(bclBiome);
|
||||||
biomePicker.addBiome(bclBiome);
|
biomePicker.addBiome(bclBiome);
|
||||||
} else {
|
} else {
|
||||||
BCLBiome bclBiome = BiomeAPI.getBiome(biomeID);
|
BCLBiome bclBiome = BiomeAPI.getBiome(biomeID);
|
||||||
|
@ -114,17 +114,27 @@ public class BCLibNetherBiomeSource extends BCLBiomeSource implements BiomeSourc
|
||||||
}
|
}
|
||||||
|
|
||||||
protected BCLBiomeSource cloneForDatapack(Set<Holder<Biome>> datapackBiomes) {
|
protected BCLBiomeSource cloneForDatapack(Set<Holder<Biome>> datapackBiomes) {
|
||||||
datapackBiomes.addAll(getBclBiomes(this.biomeRegistry));
|
datapackBiomes.addAll(getNonVanillaBiomes(this.biomeRegistry));
|
||||||
|
datapackBiomes.addAll(possibleBiomes().stream()
|
||||||
|
.filter(h -> !h.unwrapKey()
|
||||||
|
.orElseThrow()
|
||||||
|
.location()
|
||||||
|
.getNamespace()
|
||||||
|
.equals("minecraft"))
|
||||||
|
.toList());
|
||||||
return new BCLibNetherBiomeSource(
|
return new BCLibNetherBiomeSource(
|
||||||
this.biomeRegistry,
|
this.biomeRegistry,
|
||||||
datapackBiomes.stream().toList(),
|
datapackBiomes.stream()
|
||||||
|
.filter(b -> b.isValidInRegistry(biomeRegistry) && b.unwrapKey()
|
||||||
|
.orElse(null) != BCLBiomeRegistry.EMPTY_BIOME.getBiomeKey())
|
||||||
|
.toList(),
|
||||||
this.currentSeed,
|
this.currentSeed,
|
||||||
config,
|
config,
|
||||||
true
|
true
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static List<Holder<Biome>> getBclBiomes(Registry<Biome> biomeRegistry) {
|
private static List<Holder<Biome>> getNonVanillaBiomes(Registry<Biome> biomeRegistry) {
|
||||||
List<String> include = Configs.BIOMES_CONFIG.getIncludeMatching(BiomeAPI.BiomeType.NETHER);
|
List<String> include = Configs.BIOMES_CONFIG.getIncludeMatching(BiomeAPI.BiomeType.NETHER);
|
||||||
List<String> exclude = Configs.BIOMES_CONFIG.getExcludeMatching(BiomeAPI.BiomeType.NETHER);
|
List<String> exclude = Configs.BIOMES_CONFIG.getExcludeMatching(BiomeAPI.BiomeType.NETHER);
|
||||||
|
|
||||||
|
@ -147,14 +157,15 @@ public class BCLibNetherBiomeSource extends BCLBiomeSource implements BiomeSourc
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean isValidNonVanillaNetherBiome(Holder<Biome> biome, ResourceLocation location) {
|
private static boolean isValidNonVanillaNetherBiome(Holder<Biome> biome, ResourceLocation location) {
|
||||||
return (
|
if (BiomeAPI.wasRegisteredAs(location, BiomeAPI.BiomeType.END_IGNORE) || biome.unwrapKey()
|
||||||
!"minecraft".equals(location.getNamespace()) &&
|
.orElseThrow()
|
||||||
NetherBiomes.canGenerateInNether(biome.unwrapKey().get())) ||
|
.location()
|
||||||
BiomeAPI.wasRegisteredAs(location, BiomeAPI.BiomeType.BCL_NETHER);
|
.getNamespace()
|
||||||
}
|
.equals("minecraft"))
|
||||||
|
return false;
|
||||||
|
|
||||||
public static <T> void debug(Object el, Registry<T> reg) {
|
return NetherBiomes.canGenerateInNether(biome.unwrapKey().get()) ||
|
||||||
System.out.println("Unknown " + el + " in " + reg);
|
BiomeAPI.wasRegisteredAsNetherBiome(location);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void register() {
|
public static void register() {
|
||||||
|
@ -207,7 +218,12 @@ public class BCLibNetherBiomeSource extends BCLBiomeSource implements BiomeSourc
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "BCLib - Nether BiomeSource (" + Integer.toHexString(hashCode()) + ", config=" + config + ", seed=" + currentSeed + ", height=" + maxHeight + ", biomes=" + possibleBiomes().size() + ")";
|
return "\nBCLib - Nether BiomeSource (" + Integer.toHexString(hashCode()) + ")" +
|
||||||
|
"\n biomes = " + possibleBiomes().size() +
|
||||||
|
"\n namespaces = " + getNamespaces() +
|
||||||
|
"\n seed = " + currentSeed +
|
||||||
|
"\n height = " + maxHeight +
|
||||||
|
"\n config = " + config;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -236,7 +236,8 @@ public class InternalBiomeAPI {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void applyModifications(BiomeSource source, ResourceKey<LevelStem> dimension) {
|
public static void applyModifications(BiomeSource source, ResourceKey<LevelStem> dimension) {
|
||||||
BCLib.LOGGER.info("Apply Modifications for " + dimension.location() + " BiomeSource " + source);
|
BCLib.LOGGER.info("\nApply Modifications for " + dimension.location() + source.toString()
|
||||||
|
.replace("\n", "\n "));
|
||||||
/*if (dimension.location().equals(LevelStem.NETHER)){
|
/*if (dimension.location().equals(LevelStem.NETHER)){
|
||||||
if (source instanceof BCLBiomeSource s) {
|
if (source instanceof BCLBiomeSource s) {
|
||||||
NetherBiomes.useLegacyGeneration = s.biomeSourceVersion==BCLBiomeSource.BIOME_SOURCE_VERSION_SQUARE;
|
NetherBiomes.useLegacyGeneration = s.biomeSourceVersion==BCLBiomeSource.BIOME_SOURCE_VERSION_SQUARE;
|
||||||
|
|
|
@ -0,0 +1,19 @@
|
||||||
|
package org.betterx.worlds.together.biomesource;
|
||||||
|
|
||||||
|
import net.minecraft.core.Holder;
|
||||||
|
import net.minecraft.world.level.biome.Biome;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
public class BiomeSourceHelper {
|
||||||
|
public static String getNamespaces(Collection<Holder<Biome>> biomes) {
|
||||||
|
String namespaces = biomes
|
||||||
|
.stream()
|
||||||
|
.filter(h -> h.unwrapKey().isPresent())
|
||||||
|
.map(h -> h.unwrapKey().get().location().getNamespace())
|
||||||
|
.distinct()
|
||||||
|
.collect(Collectors.joining(", "));
|
||||||
|
return namespaces;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,18 @@
|
||||||
|
package org.betterx.worlds.together.mixin.common;
|
||||||
|
|
||||||
|
import org.betterx.worlds.together.biomesource.BiomeSourceHelper;
|
||||||
|
|
||||||
|
import net.minecraft.world.level.biome.BiomeSource;
|
||||||
|
|
||||||
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
|
||||||
|
@Mixin(BiomeSource.class)
|
||||||
|
public class BiomeSourceMixin {
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
BiomeSource self = (BiomeSource) (Object) this;
|
||||||
|
return "\n" + getClass().getSimpleName() + " (" + Integer.toHexString(hashCode()) + ")" +
|
||||||
|
"\n biomes = " + self.possibleBiomes().size() +
|
||||||
|
"\n namespaces = " + BiomeSourceHelper.getNamespaces(self.possibleBiomes());
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,5 +1,6 @@
|
||||||
package org.betterx.worlds.together.world.event;
|
package org.betterx.worlds.together.world.event;
|
||||||
|
|
||||||
|
import org.betterx.bclib.BCLib;
|
||||||
import org.betterx.worlds.together.WorldsTogether;
|
import org.betterx.worlds.together.WorldsTogether;
|
||||||
import org.betterx.worlds.together.levelgen.WorldGenUtil;
|
import org.betterx.worlds.together.levelgen.WorldGenUtil;
|
||||||
import org.betterx.worlds.together.mixin.common.RegistryOpsAccessor;
|
import org.betterx.worlds.together.mixin.common.RegistryOpsAccessor;
|
||||||
|
@ -294,13 +295,23 @@ public class WorldBootstrap {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void finalizeWorldGenSettings(WorldGenSettings worldGenSettings) {
|
public static void finalizeWorldGenSettings(WorldGenSettings worldGenSettings) {
|
||||||
|
String output = "World Dimensions: ";
|
||||||
for (var entry : worldGenSettings.dimensions().entrySet()) {
|
for (var entry : worldGenSettings.dimensions().entrySet()) {
|
||||||
WorldEventsImpl.ON_FINALIZE_LEVEL_STEM.emit(e -> e.now(
|
WorldEventsImpl.ON_FINALIZE_LEVEL_STEM.emit(e -> e.now(
|
||||||
worldGenSettings,
|
worldGenSettings,
|
||||||
entry.getKey(),
|
entry.getKey(),
|
||||||
entry.getValue()
|
entry.getValue()
|
||||||
));
|
));
|
||||||
|
|
||||||
|
output += "\n - " + entry.getKey().location().toString() + ": " +
|
||||||
|
"\n " + entry.getValue().generator().toString() + " " +
|
||||||
|
entry.getValue()
|
||||||
|
.generator()
|
||||||
|
.getBiomeSource()
|
||||||
|
.toString()
|
||||||
|
.replace("\n", "\n ");
|
||||||
}
|
}
|
||||||
|
BCLib.LOGGER.info(output);
|
||||||
SurfaceRuleUtil.injectSurfaceRulesToAllDimensions(worldGenSettings);
|
SurfaceRuleUtil.injectSurfaceRulesToAllDimensions(worldGenSettings);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
"package": "org.betterx.worlds.together.mixin.common",
|
"package": "org.betterx.worlds.together.mixin.common",
|
||||||
"compatibilityLevel": "JAVA_17",
|
"compatibilityLevel": "JAVA_17",
|
||||||
"mixins": [
|
"mixins": [
|
||||||
|
"BiomeSourceMixin",
|
||||||
"BuiltinRegistriesMixin",
|
"BuiltinRegistriesMixin",
|
||||||
"DedicatedServerPropertiesMixin",
|
"DedicatedServerPropertiesMixin",
|
||||||
"DiggerItemAccessor",
|
"DiggerItemAccessor",
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue