diff options
Diffstat (limited to 'src/main/java/shcm/shsupercm/fabric')
8 files changed, 37 insertions, 10 deletions
diff --git a/src/main/java/shcm/shsupercm/fabric/citresewn/ActiveCITs.java b/src/main/java/shcm/shsupercm/fabric/citresewn/ActiveCITs.java index b0d97ab..3069585 100644 --- a/src/main/java/shcm/shsupercm/fabric/citresewn/ActiveCITs.java +++ b/src/main/java/shcm/shsupercm/fabric/citresewn/ActiveCITs.java @@ -34,7 +34,7 @@ public class ActiveCITs { if (type instanceof ArmorItem armorType) citArmor.computeIfAbsent(armorType, t -> new ArrayList<>()).add(armor); else - CITResewn.LOG.error("Skipping item type: " + Registry.ITEM.getId(type) + " is not armor in " + cit.pack.resourcePack.getName() + " -> " + cit.propertiesIdentifier.getPath()); + CITResewn.logErrorLoading("Skipping item type: " + Registry.ITEM.getId(type) + " is not armor in " + cit.pack.resourcePack.getName() + " -> " + cit.propertiesIdentifier.getPath()); else if (cit instanceof CITElytra) citElytra.add((CITElytra) cit); else if (cit instanceof CITEnchantment) diff --git a/src/main/java/shcm/shsupercm/fabric/citresewn/CITResewn.java b/src/main/java/shcm/shsupercm/fabric/citresewn/CITResewn.java index cf85a2c..0eb4ec5 100644 --- a/src/main/java/shcm/shsupercm/fabric/citresewn/CITResewn.java +++ b/src/main/java/shcm/shsupercm/fabric/citresewn/CITResewn.java @@ -3,6 +3,7 @@ package shcm.shsupercm.fabric.citresewn; import net.fabricmc.api.ClientModInitializer; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; +import org.apache.logging.log4j.Level; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import shcm.shsupercm.fabric.citresewn.config.CITResewnConfig; @@ -22,4 +23,16 @@ public class CITResewn implements ClientModInitializer { config = CITResewnConfig.read(); } + + public static void logErrorLoading(String message) { + if (CITResewnConfig.INSTANCE().mute_errors) + return; + LOG.error(message); + } + + public static void logWarnLoading(String message) { + if (CITResewnConfig.INSTANCE().mute_warns) + return; + LOG.error(message); + } } diff --git a/src/main/java/shcm/shsupercm/fabric/citresewn/config/CITResewnConfig.java b/src/main/java/shcm/shsupercm/fabric/citresewn/config/CITResewnConfig.java index 38995ca..475cd14 100644 --- a/src/main/java/shcm/shsupercm/fabric/citresewn/config/CITResewnConfig.java +++ b/src/main/java/shcm/shsupercm/fabric/citresewn/config/CITResewnConfig.java @@ -9,6 +9,8 @@ import java.io.*; public class CITResewnConfig { public boolean enabled = true; + public boolean mute_errors = false; + public boolean mute_warns = false; private static final File FILE = new File("config/citresewn.json"); public static CITResewnConfig INSTANCE() { diff --git a/src/main/java/shcm/shsupercm/fabric/citresewn/config/CITResewnConfigScreenFactory.java b/src/main/java/shcm/shsupercm/fabric/citresewn/config/CITResewnConfigScreenFactory.java index bc00d2b..a47e6d4 100644 --- a/src/main/java/shcm/shsupercm/fabric/citresewn/config/CITResewnConfigScreenFactory.java +++ b/src/main/java/shcm/shsupercm/fabric/citresewn/config/CITResewnConfigScreenFactory.java @@ -20,8 +20,8 @@ public class CITResewnConfigScreenFactory { ConfigCategory category = builder.getOrCreateCategory(new LiteralText("")); ConfigEntryBuilder entryBuilder = builder.entryBuilder(); - category.addEntry(entryBuilder.startBooleanToggle(new TranslatableText("config.citresewn.citsEnabled.title"), currentConfig.enabled) - .setTooltip(new TranslatableText("config.citresewn.citsEnabled.tooltip")) + category.addEntry(entryBuilder.startBooleanToggle(new TranslatableText("config.citresewn.enabled.title"), currentConfig.enabled) + .setTooltip(new TranslatableText("config.citresewn.enabled.tooltip")) .setSaveConsumer(newConfig -> { if (currentConfig.enabled != newConfig) { currentConfig.enabled = newConfig; @@ -31,6 +31,18 @@ public class CITResewnConfigScreenFactory { .setDefaultValue(defaultConfig.enabled) .build()); + category.addEntry(entryBuilder.startBooleanToggle(new TranslatableText("config.citresewn.mute_errors.title"), currentConfig.mute_errors) + .setTooltip(new TranslatableText("config.citresewn.mute_errors.tooltip")) + .setSaveConsumer(newConfig -> currentConfig.mute_errors = newConfig) + .setDefaultValue(defaultConfig.mute_errors) + .build()); + + category.addEntry(entryBuilder.startBooleanToggle(new TranslatableText("config.citresewn.mute_warns.title"), currentConfig.mute_warns) + .setTooltip(new TranslatableText("config.citresewn.mute_warns.tooltip")) + .setSaveConsumer(newConfig -> currentConfig.mute_warns = newConfig) + .setDefaultValue(defaultConfig.mute_warns) + .build()); + return builder.build(); } } diff --git a/src/main/java/shcm/shsupercm/fabric/citresewn/mixin/ModelLoaderMixin.java b/src/main/java/shcm/shsupercm/fabric/citresewn/mixin/ModelLoaderMixin.java index f0fa82d..a5e6a30 100644 --- a/src/main/java/shcm/shsupercm/fabric/citresewn/mixin/ModelLoaderMixin.java +++ b/src/main/java/shcm/shsupercm/fabric/citresewn/mixin/ModelLoaderMixin.java @@ -59,7 +59,7 @@ public abstract class ModelLoaderMixin { this.modelsToBake.put(id, unbakedModel); } } catch (Exception e) { - CITResewn.LOG.error(e.getMessage()); + CITResewn.logErrorLoading(e.getMessage()); } } @@ -99,7 +99,7 @@ public abstract class ModelLoaderMixin { if (override != null) citItem.subItems.put(override, this.bakedModels.get(new ResewnItemModelIdentifier(citModelEntry.getValue().id))); else { - CITResewn.LOG.error("Skipping sub cit: No such sub item model \"" + citModelEntry.getKey().getPath().substring(5) + "\" in " + citItem.pack.resourcePack.getName() + " -> " + citItem.propertiesIdentifier.getPath()); + CITResewn.logErrorLoading("Skipping sub cit: No such sub item model \"" + citModelEntry.getKey().getPath().substring(5) + "\" in " + citItem.pack.resourcePack.getName() + " -> " + citItem.propertiesIdentifier.getPath()); } } } diff --git a/src/main/java/shcm/shsupercm/fabric/citresewn/pack/CITPack.java b/src/main/java/shcm/shsupercm/fabric/citresewn/pack/CITPack.java index 0431e62..78dc0e3 100644 --- a/src/main/java/shcm/shsupercm/fabric/citresewn/pack/CITPack.java +++ b/src/main/java/shcm/shsupercm/fabric/citresewn/pack/CITPack.java @@ -28,17 +28,17 @@ public class CITPack { try { cap = Integer.parseInt(properties.getProperty("cap", "8")); } catch (NumberFormatException e) { - CITResewn.LOG.error(new CITParseException(resourcePack, new Identifier("cit.properties"), "cap is not a whole number").getMessage()); + CITResewn.logErrorLoading(new CITParseException(resourcePack, new Identifier("cit.properties"), "cap is not a whole number").getMessage()); } try { fade = Float.parseFloat(properties.getProperty("fade", "0.5")); } catch (NumberFormatException e) { - CITResewn.LOG.error(new CITParseException(resourcePack, new Identifier("cit.properties"), "fade is not a number").getMessage()); + CITResewn.logErrorLoading(new CITParseException(resourcePack, new Identifier("cit.properties"), "fade is not a number").getMessage()); } switch (properties.getProperty("useGlint", "true")) { case "true" -> useGlint = true; case "false" -> useGlint = false; - default -> CITResewn.LOG.error(new CITParseException(resourcePack, new Identifier("cit.properties"), "useGlint is not a boolean").getMessage()); + default -> CITResewn.logErrorLoading(new CITParseException(resourcePack, new Identifier("cit.properties"), "useGlint is not a boolean").getMessage()); } } diff --git a/src/main/java/shcm/shsupercm/fabric/citresewn/pack/CITParser.java b/src/main/java/shcm/shsupercm/fabric/citresewn/pack/CITParser.java index cf7fe19..5204c9c 100644 --- a/src/main/java/shcm/shsupercm/fabric/citresewn/pack/CITParser.java +++ b/src/main/java/shcm/shsupercm/fabric/citresewn/pack/CITParser.java @@ -60,7 +60,7 @@ public class CITParser { private CITParser() {} citPack.cits.add(parseCIT(citPack, citIdentifier, citProperties)); } catch (Exception e) { - CITResewn.LOG.error(e.getMessage()); + CITResewn.logErrorLoading(e.getMessage()); } } cits.addAll(citPack.cits); diff --git a/src/main/java/shcm/shsupercm/fabric/citresewn/pack/cits/CITItem.java b/src/main/java/shcm/shsupercm/fabric/citresewn/pack/cits/CITItem.java index bcd719c..a2ef7ea 100644 --- a/src/main/java/shcm/shsupercm/fabric/citresewn/pack/cits/CITItem.java +++ b/src/main/java/shcm/shsupercm/fabric/citresewn/pack/cits/CITItem.java @@ -189,7 +189,7 @@ public class CITItem extends CIT { }; if (replacement != null) { - CITResewn.LOG.error("CIT Warning: Using deprecated sub item id \"" + subItem + "\" instead of \"" + replacement + "\" in " + pack.resourcePack.getName() + " -> " + propertiesIdentifier.getPath()); + CITResewn.logWarnLoading("CIT Warning: Using deprecated sub item id \"" + subItem + "\" instead of \"" + replacement + "\" in " + pack.resourcePack.getName() + " -> " + propertiesIdentifier.getPath()); return new Identifier("minecraft", "item/" + replacement); } |