Better logging

This commit is contained in:
Frank 2022-07-10 00:26:07 +02:00
parent a988083417
commit 8f9c33e378
9 changed files with 99 additions and 23 deletions

View file

@ -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;
}
}

View file

@ -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());
}
}

View file

@ -1,5 +1,6 @@
package org.betterx.worlds.together.world.event;
import org.betterx.bclib.BCLib;
import org.betterx.worlds.together.WorldsTogether;
import org.betterx.worlds.together.levelgen.WorldGenUtil;
import org.betterx.worlds.together.mixin.common.RegistryOpsAccessor;
@ -294,13 +295,23 @@ public class WorldBootstrap {
}
public static void finalizeWorldGenSettings(WorldGenSettings worldGenSettings) {
String output = "World Dimensions: ";
for (var entry : worldGenSettings.dimensions().entrySet()) {
WorldEventsImpl.ON_FINALIZE_LEVEL_STEM.emit(e -> e.now(
worldGenSettings,
entry.getKey(),
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);
}