9
0
mirror of https://github.com/Dreeam-qwq/Gale.git synced 2025-12-20 07:19:31 +00:00

Use timin.gs by default

This commit is contained in:
MartijnMuijsers
2022-12-01 17:27:21 +01:00
parent fd5551f54c
commit a616b367fd
111 changed files with 29 additions and 10 deletions

View File

@@ -0,0 +1,87 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: MartijnMuijsers <martijnmuijsers@live.nl>
Date: Fri, 25 Nov 2022 16:26:04 +0100
Subject: [PATCH] Softly log invalid pool element errors
License: MIT (https://opensource.org/licenses/MIT)
This patch is based on the following patch:
"Change vanilla structure error to info log level"
By: chickeneer <emcchickeneer@gmail.com>
As part of: EmpireCraft (https://github.com/starlis/empirecraft)
Licensed under: MIT (https://opensource.org/licenses/MIT)
diff --git a/src/main/java/net/minecraft/world/level/levelgen/structure/PoolElementStructurePiece.java b/src/main/java/net/minecraft/world/level/levelgen/structure/PoolElementStructurePiece.java
index d2b4654a9095a678bbc9e004af969cf54da0fcab..d797bac97ec1adec7a25a26c8e052e70e8db1c28 100644
--- a/src/main/java/net/minecraft/world/level/levelgen/structure/PoolElementStructurePiece.java
+++ b/src/main/java/net/minecraft/world/level/levelgen/structure/PoolElementStructurePiece.java
@@ -23,10 +23,11 @@ import net.minecraft.world.level.levelgen.structure.pieces.StructurePieceType;
import net.minecraft.world.level.levelgen.structure.pools.JigsawJunction;
import net.minecraft.world.level.levelgen.structure.pools.StructurePoolElement;
import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplateManager;
+import org.galemc.gale.configuration.GaleGlobalConfiguration;
import org.slf4j.Logger;
public class PoolElementStructurePiece extends StructurePiece {
- private static final Logger LOGGER = LogUtils.getLogger();
+ public static final Logger LOGGER = LogUtils.getLogger(); // Gale - EMC - softly log invalid pool element errors - private -> public
protected final StructurePoolElement element;
protected BlockPos position;
private final int groundLevelDelta;
@@ -49,7 +50,7 @@ public class PoolElementStructurePiece extends StructurePiece {
this.position = new BlockPos(nbt.getInt("PosX"), nbt.getInt("PosY"), nbt.getInt("PosZ"));
this.groundLevelDelta = nbt.getInt("ground_level_delta");
DynamicOps<Tag> dynamicOps = RegistryOps.create(NbtOps.INSTANCE, context.registryAccess());
- this.element = StructurePoolElement.CODEC.parse(dynamicOps, nbt.getCompound("pool_element")).resultOrPartial(LOGGER::error).orElseThrow(() -> {
+ this.element = StructurePoolElement.CODEC.parse(dynamicOps, nbt.getCompound("pool_element")).resultOrPartial(GaleGlobalConfiguration.get().logToConsole.invalidPoolElementErrorStringConsumer).orElseThrow(() -> { // Gale - EMC - softly log invalid pool element errors
return new IllegalStateException("Invalid pool element found");
});
this.rotation = Rotation.valueOf(nbt.getString("rotation"));
diff --git a/src/main/java/org/galemc/gale/configuration/GaleGlobalConfiguration.java b/src/main/java/org/galemc/gale/configuration/GaleGlobalConfiguration.java
index cf4a354fd3a68f8a0639ed98c7c2e842c6459389..bc44c8537ea69a7682584db57ec566ecb4e76b3b 100644
--- a/src/main/java/org/galemc/gale/configuration/GaleGlobalConfiguration.java
+++ b/src/main/java/org/galemc/gale/configuration/GaleGlobalConfiguration.java
@@ -4,8 +4,12 @@ package org.galemc.gale.configuration;
import io.papermc.paper.configuration.Configuration;
import io.papermc.paper.configuration.ConfigurationPart;
+import net.minecraft.world.level.levelgen.structure.PoolElementStructurePiece;
import org.spongepowered.configurate.objectmapping.meta.Setting;
+import java.util.Locale;
+import java.util.function.Consumer;
+
@SuppressWarnings({"CanBeFinal", "FieldCanBeLocal", "FieldMayBeFinal", "NotNullFieldNotInitialized", "InnerClassMayBeStatic"})
public class GaleGlobalConfiguration extends ConfigurationPart {
static final int CURRENT_VERSION = 1;
@@ -54,7 +58,7 @@ public class GaleGlobalConfiguration extends ConfigurationPart {
}
public LogToConsole logToConsole;
- public class LogToConsole extends ConfigurationPart {
+ public class LogToConsole extends ConfigurationPart.Post { // Gale - EMC - softly log invalid pool element errors
public boolean invalidStatistics = true; // Gale - EMC - do not log invalid statistics
public boolean ignoredAdvancements = true; // Gale - Purpur - do not log ignored advancements
@@ -71,6 +75,21 @@ public class GaleGlobalConfiguration extends ConfigurationPart {
public boolean notSecureMarker = true; // Gale - do not log Not Secure marker
}
+ // Gale start - EMC - softly log invalid pool element errors
+ public String invalidPoolElementErrorLogLevel = "info";
+ public transient Consumer<String> invalidPoolElementErrorStringConsumer;
+
+ @Override
+ public void postProcess() {
+ this.invalidPoolElementErrorStringConsumer = switch (this.invalidPoolElementErrorLogLevel.toLowerCase(Locale.ROOT)) {
+ case "none" -> $ -> {};
+ case "info", "log" -> PoolElementStructurePiece.LOGGER::info;
+ case "warn", "warning" -> PoolElementStructurePiece.LOGGER::warn;
+ default -> PoolElementStructurePiece.LOGGER::error;
+ };
+ }
+ // Gale end - EMC - softly log invalid pool element errors
+
}
}