Skip to content

Commit

Permalink
Switch logInvalidToolStack to a three value enum
Browse files Browse the repository at this point in the history
Allows disabling the warning entirely, as its mainly there for mod devs. A player cannot do much about the warning if they are getting it beyond reporting the issue on Github.
See also RCXcrafter/Materialis#25
  • Loading branch information
KnightMiner committed Feb 11, 2023
1 parent 5127098 commit a98fb9c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
10 changes: 6 additions & 4 deletions src/main/java/slimeknights/tconstruct/common/config/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import net.minecraftforge.common.ForgeConfigSpec.BooleanValue;
import net.minecraftforge.common.ForgeConfigSpec.ConfigValue;
import net.minecraftforge.common.ForgeConfigSpec.DoubleValue;
import net.minecraftforge.common.ForgeConfigSpec.EnumValue;
import net.minecraftforge.common.ForgeConfigSpec.IntValue;
import net.minecraftforge.eventbus.api.IEventBus;
import net.minecraftforge.fml.ModLoadingContext;
Expand Down Expand Up @@ -68,7 +69,8 @@ public static class Common {

// debug
public final BooleanValue forceIntegrationMaterials;
public final BooleanValue logInvalidToolStackTrace;
public final EnumValue<LogInvalidToolStack> logInvalidToolStack;
public enum LogInvalidToolStack { STACKTRACE, WARNING, IGNORED };

Common(ForgeConfigSpec.Builder builder) {
builder.comment("Everything to do with gameplay").push("gameplay");
Expand Down Expand Up @@ -261,9 +263,9 @@ public static class Common {
"Does not provide recipes for any of them, they will only be available to cheat in creative.")
.worldRestart()
.define("forceIntegrationMaterials", false);
this.logInvalidToolStackTrace = builder
.comment("If true, logs the stacktrace whenever a tool stack is created from a non-modifiable item. The stacktrace helps debug which mod is causing it, but is rather expensive on the chance they are doing it a lot.")
.define("logInvalidToolStackTrace", false);
this.logInvalidToolStack = builder
.comment("If STACKTRACE, logs the stacktrace whenever a tool stack is created from a non-modifiable item. If WARNING (default), logs a shorter but more efficient error. If IGNORE, disables logging (useful for modpacks/players *after* they reported the issue). The stacktrace helps debug which mod is causing it, but is rather expensive on the chance they are doing it a lot.")
.defineEnum("logInvalidToolStack", LogInvalidToolStack.WARNING);
builder.pop();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,10 +141,11 @@ private static ToolStack from(ItemStack stack, boolean copyNbt) {
// both are things we will do later, doing so now causes us to recursively call this method (though not infinite)
stack.tag = nbt;
} else {
if (Config.COMMON.logInvalidToolStackTrace.get()) {
TConstruct.LOG.warn("Tool stack constructed using non-modifiable tool, this may cause issues as it has no NBT. Stacktrace can be disabled in config.", new Exception("Stack trace"));
} else {
TConstruct.LOG.warn("Tool stack constructed using non-modifiable tool, this may cause issues as it has no NBT. To debug this issue, enable logInvalidToolStackTrace in the config.");
switch (Config.COMMON.logInvalidToolStack.get()) {
case STACKTRACE ->
TConstruct.LOG.warn("Tool stack constructed using non-modifiable tool, this may cause issues as it has no NBT. Stacktrace can be disabled in config.", new Exception("Stack trace"));
case WARNING ->
TConstruct.LOG.warn("Tool stack constructed using non-modifiable tool, this may cause issues as it has no NBT. To debug this issue or disable the warning, use logInvalidToolStack in the config.");
}
}
}
Expand Down

0 comments on commit a98fb9c

Please sign in to comment.