Improve logging

Signed-off-by: solonovamax <solonovamax@12oclockpoint.com>
This commit is contained in:
solonovamax
2021-08-30 22:04:17 -04:00
parent 7b9c88f8a6
commit b6c40302b6
17 changed files with 94 additions and 56 deletions

View File

@@ -10,7 +10,7 @@ import com.dfsek.terra.api.addon.annotations.Version;
@Addon("Terra-Bukkit")
@Version("1.0.0")
@Author("Terra")
final class BukkitAddon extends TerraAddon {
public final class BukkitAddon extends TerraAddon {
private final TerraPlugin main;
public BukkitAddon(TerraPlugin main) {

View File

@@ -58,11 +58,14 @@ public final class FabricAddon extends TerraAddon {
}
if(template.doRegistryInjection()) {
logger.info("Injecting structures into Terra");
BuiltinRegistries.CONFIGURED_FEATURE.getEntries().forEach(entry -> {
if(!template.getExcludedRegistryFeatures().contains(entry.getKey().getValue())) {
try {
event.getPack().getCheckedRegistry(Tree.class).register(entry.getKey().getValue().toString(),
(Tree) entry.getValue());
event.getPack()
.getCheckedRegistry(Tree.class)
.register(entry.getKey().getValue().toString(), (Tree) entry.getValue());
logger.info("Injected ConfiguredFeature {} as Tree.", entry.getKey().getValue());
} catch(DuplicateEntryException ignored) {
}
@@ -82,7 +85,7 @@ public final class FabricAddon extends TerraAddon {
try {
event.loadTemplate(template);
} catch(ConfigException e) {
logger.error("Error loading config templatE", e);
logger.error("Error loading config template", e);
}
templates.get(event.getPack()).setRight(template);
@@ -95,16 +98,17 @@ public final class FabricAddon extends TerraAddon {
.register(this, BiomeRegistrationEvent.class)
.then(event -> {
logger.info("Registering biomes...");
Registry<Biome> biomeRegistry = event.getRegistryManager().get(Registry.BIOME_KEY);
terraFabricPlugin.getConfigRegistry().forEach(pack -> pack.getCheckedRegistry(TerraBiome.class)
.forEach(
(id, biome) -> FabricUtil.registerOrOverwrite(
biomeRegistry, Registry.BIOME_KEY,
new Identifier("terra",
FabricUtil.createBiomeID(
pack, id)),
FabricUtil.createBiome(biome, pack,
event.getRegistryManager())))); // Register all Terra biomes.
terraFabricPlugin.getConfigRegistry().forEach(pack -> { // Register all Terra biomes.
pack.getCheckedRegistry(TerraBiome.class)
.forEach((id, biome) -> {
Identifier identifier = new Identifier("terra", FabricUtil.createBiomeID(pack, id));
Biome fabricBiome = FabricUtil.createBiome(biome, pack, event.getRegistryManager());
FabricUtil.registerOrOverwrite(biomeRegistry, Registry.BIOME_KEY, identifier, fabricBiome);
});
});
logger.info("Biomes registered.");
})
.global();

View File

@@ -10,6 +10,8 @@ import net.minecraft.world.gen.decorator.NopeDecoratorConfig;
import net.minecraft.world.gen.feature.ConfiguredFeature;
import net.minecraft.world.gen.feature.DefaultFeatureConfig;
import net.minecraft.world.gen.feature.FeatureConfig;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.dfsek.terra.fabric.generation.FabricChunkGeneratorWrapper;
import com.dfsek.terra.fabric.generation.PopulatorFeature;
@@ -17,9 +19,12 @@ import com.dfsek.terra.fabric.generation.TerraBiomeSource;
public class FabricEntryPoint implements ModInitializer {
private static final Logger logger = LoggerFactory.getLogger(FabricEntryPoint.class);
public static final PopulatorFeature POPULATOR_FEATURE = new PopulatorFeature(DefaultFeatureConfig.CODEC);
public static final ConfiguredFeature<?, ?> POPULATOR_CONFIGURED_FEATURE = POPULATOR_FEATURE.configure(FeatureConfig.DEFAULT).decorate(
Decorator.NOPE.configure(NopeDecoratorConfig.INSTANCE));
public static final ConfiguredFeature<?, ?> POPULATOR_CONFIGURED_FEATURE = POPULATOR_FEATURE.configure(FeatureConfig.DEFAULT)
.decorate(Decorator.NOPE.configure(
NopeDecoratorConfig.INSTANCE));
private static final TerraPluginImpl TERRA_PLUGIN = new TerraPluginImpl();
public static TerraPluginImpl getTerraPlugin() {
@@ -28,6 +33,7 @@ public class FabricEntryPoint implements ModInitializer {
@Override
public void onInitialize() {
logger.info("Initializing Terra Fabric mod...");
// register the things
Registry.register(Registry.FEATURE, new Identifier("terra", "populator"), POPULATOR_FEATURE);
RegistryKey<ConfiguredFeature<?, ?>> floraKey = RegistryKey.of(Registry.CONFIGURED_FEATURE_KEY,

View File

@@ -61,11 +61,11 @@ public class TerraPluginImpl extends AbstractTerraPlugin {
@Override
public void register(TypeRegistry registry) {
super.register(registry);
registry
.registerLoader(com.dfsek.terra.api.world.biome.Biome.class, (t, o, l) -> parseBiome((String) o))
registry.registerLoader(com.dfsek.terra.api.world.biome.Biome.class, (t, o, l) -> parseBiome((String) o))
.registerLoader(Identifier.class, (t, o, l) -> {
Identifier identifier = Identifier.tryParse((String) o);
if(identifier == null) throw new LoadException("Invalid identifier: " + o);
if(identifier == null)
throw new LoadException("Invalid identifier: " + o);
return identifier;
});
}