From c2748e2358e001f12298eedbe2a40879ff1fd6b8 Mon Sep 17 00:00:00 2001 From: kurrycat Date: Wed, 20 Nov 2024 20:45:03 +0100 Subject: [PATCH 1/4] switch config to gtnhlib config annotation + add ingame config gui --- .../angelica/loading/AngelicaTweaker.java | 2 + .../gtnewhorizons/angelica/mixins/Mixins.java | 34 +- .../java/com/prupe/mcpatcher/MCLogger.java | 29 +- .../com/prupe/mcpatcher/cc/ColorizeBlock.java | 16 +- .../com/prupe/mcpatcher/cc/ColorizeWorld.java | 2 +- .../com/prupe/mcpatcher/cc/Colorizer.java | 18 +- .../java/com/prupe/mcpatcher/cc/Lightmap.java | 2 +- .../com/prupe/mcpatcher/cit/CITUtils.java | 6 +- .../com/prupe/mcpatcher/ctm/CTMUtils.java | 5 +- .../mcpatcher/ctm/GlassPaneRenderer.java | 2 +- .../mcpatcher/ctm/TileOverrideIterator.java | 2 +- .../prupe/mcpatcher/hd/CustomAnimation.java | 2 +- .../com/prupe/mcpatcher/hd/FancyDial.java | 8 +- .../com/prupe/mcpatcher/hd/FontUtils.java | 4 +- .../com/prupe/mcpatcher/hd/MipmapHelper.java | 8 +- .../prupe/mcpatcher/mal/biome/ColorMap.java | 4 +- .../mal/block/RenderBlocksUtils.java | 2 +- .../prupe/mcpatcher/mal/tile/TileLoader.java | 2 +- .../com/prupe/mcpatcher/mob/LineRenderer.java | 2 +- .../prupe/mcpatcher/sky/FireworksHelper.java | 2 +- .../com/prupe/mcpatcher/sky/SkyRenderer.java | 6 +- src/main/java/jss/notfine/McPatcherForge.java | 3 +- .../java/jss/notfine/asm/AsmTransformers.java | 2 +- .../notfine/config/MCPatcherForgeConfig.java | 457 +++++++++++------- .../config/MCPatcherForgeGuiConfig.java | 18 + .../MCPatcherForgeGuiConfigFactory.java | 11 + .../mcpatcherforge/base/MixinMinecraft.java | 9 +- 27 files changed, 403 insertions(+), 255 deletions(-) create mode 100644 src/main/java/jss/notfine/config/MCPatcherForgeGuiConfig.java create mode 100644 src/main/java/jss/notfine/config/MCPatcherForgeGuiConfigFactory.java diff --git a/src/main/java/com/gtnewhorizons/angelica/loading/AngelicaTweaker.java b/src/main/java/com/gtnewhorizons/angelica/loading/AngelicaTweaker.java index 7425e43c7..cc18582d8 100644 --- a/src/main/java/com/gtnewhorizons/angelica/loading/AngelicaTweaker.java +++ b/src/main/java/com/gtnewhorizons/angelica/loading/AngelicaTweaker.java @@ -15,6 +15,7 @@ import cpw.mods.fml.relauncher.IFMLLoadingPlugin; import jss.notfine.asm.AsmTransformers; import jss.notfine.asm.mappings.Namer; +import jss.notfine.config.MCPatcherForgeConfig; import org.apache.logging.log4j.Level; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -56,6 +57,7 @@ public class AngelicaTweaker implements IFMLLoadingPlugin, IEarlyMixinLoader { // Angelica Config ConfigurationManager.registerConfig(AngelicaConfig.class); ConfigurationManager.registerConfig(CompatConfig.class); + MCPatcherForgeConfig.registerConfig(); final LoggerContext ctx = (LoggerContext) LogManager.getContext(false); final Configuration config = ctx.getConfiguration(); final LoggerConfig loggerConfig = config.getLoggerConfig(LogManager.ROOT_LOGGER_NAME); diff --git a/src/main/java/com/gtnewhorizons/angelica/mixins/Mixins.java b/src/main/java/com/gtnewhorizons/angelica/mixins/Mixins.java index f5b5318be..39dfd6d69 100644 --- a/src/main/java/com/gtnewhorizons/angelica/mixins/Mixins.java +++ b/src/main/java/com/gtnewhorizons/angelica/mixins/Mixins.java @@ -302,7 +302,7 @@ public enum Mixins { ), NOTFINE_NO_CUSTOM_ITEM_TEXTURES(new Builder("NotFine no Custom Item Textures") .setSide(Side.CLIENT).setPhase(Phase.EARLY) - .setApplyIf(() -> !AngelicaConfig.enableMCPatcherForgeFeatures || !MCPatcherForgeConfig.instance().customItemTexturesEnabled) + .setApplyIf(() -> !AngelicaConfig.enableMCPatcherForgeFeatures || !MCPatcherForgeConfig.CustomItemTextures.enabled) .addTargetedMod(TargetedMod.VANILLA) .addMixinClasses(addPrefix("notfine.glint.", "MixinItemRenderer", @@ -386,7 +386,7 @@ public enum Mixins { ), MCPATCHER_FORGE_CUSTOM_COLORS(new Builder("MCP:F Custom Colors") .setSide(Mixins.Side.CLIENT).setPhase(Phase.EARLY) - .setApplyIf(() -> AngelicaConfig.enableMCPatcherForgeFeatures && MCPatcherForgeConfig.instance().customColorsEnabled) + .setApplyIf(() -> AngelicaConfig.enableMCPatcherForgeFeatures && MCPatcherForgeConfig.CustomColors.enabled) .addTargetedMod(TargetedMod.VANILLA) .addMixinClasses(addPrefix("mcpatcherforge.cc.", "block.material.MixinMapColor", @@ -442,7 +442,7 @@ public enum Mixins { ), MCPATCHER_FORGE_CUSTOM_ITEM_TEXTURES(new Builder("MCP:F Custom Item Textures") .setSide(Side.CLIENT).setPhase(Phase.EARLY) - .setApplyIf(() -> AngelicaConfig.enableMCPatcherForgeFeatures && MCPatcherForgeConfig.instance().customItemTexturesEnabled) + .setApplyIf(() -> AngelicaConfig.enableMCPatcherForgeFeatures && MCPatcherForgeConfig.CustomItemTextures.enabled) .addTargetedMod(TargetedMod.VANILLA) .addMixinClasses(addPrefix("mcpatcherforge.cit.", "client.renderer.entity.MixinRenderBiped", @@ -461,13 +461,13 @@ public enum Mixins { ), MCPATCHER_FORGE_CONNECTED_TEXTURES(new Builder("MCP:F Connected Textures") .setSide(Side.CLIENT).setPhase(Phase.EARLY) - .setApplyIf(() -> AngelicaConfig.enableMCPatcherForgeFeatures && MCPatcherForgeConfig.instance().connectedTexturesEnabled) + .setApplyIf(() -> AngelicaConfig.enableMCPatcherForgeFeatures && MCPatcherForgeConfig.ConnectedTextures.enabled) .addTargetedMod(TargetedMod.VANILLA) .addMixinClasses("mcpatcherforge.ctm.MixinRenderBlocks") ), MCPATCHER_FORGE_EXTENDED_HD(new Builder("MCP:F Extended hd") .setSide(Side.CLIENT).setPhase(Phase.EARLY) - .setApplyIf(() -> AngelicaConfig.enableMCPatcherForgeFeatures && MCPatcherForgeConfig.instance().extendedHDEnabled) + .setApplyIf(() -> AngelicaConfig.enableMCPatcherForgeFeatures && MCPatcherForgeConfig.ExtendedHD.enabled) .addTargetedMod(TargetedMod.VANILLA) .addMixinClasses(addPrefix("mcpatcherforge.hd.", "MixinTextureClock", @@ -477,14 +477,14 @@ public enum Mixins { ), MCPATCHER_FORGE_EXTENDED_HD_FONT(new Builder("MCP:F Extended HD Font") .setSide(Side.CLIENT).setPhase(Phase.EARLY) - .setApplyIf(() -> (AngelicaConfig.enableMCPatcherForgeFeatures && MCPatcherForgeConfig.instance().extendedHDEnabled && MCPatcherForgeConfig.instance().hdFont)) + .setApplyIf(() -> (AngelicaConfig.enableMCPatcherForgeFeatures && MCPatcherForgeConfig.ExtendedHD.enabled && MCPatcherForgeConfig.ExtendedHD.hdFont)) .addTargetedMod(TargetedMod.VANILLA) .addExcludedMod(TargetedMod.COFHCORE) .addMixinClasses("mcpatcherforge.hd.MixinFontRenderer") ), MCPATCHER_FORGE_RANDOM_MOBS(new Builder("MCP:F Random Mobs") .setSide(Side.CLIENT).setPhase(Phase.EARLY) - .setApplyIf(() -> AngelicaConfig.enableMCPatcherForgeFeatures && MCPatcherForgeConfig.instance().randomMobsEnabled) + .setApplyIf(() -> AngelicaConfig.enableMCPatcherForgeFeatures && MCPatcherForgeConfig.RandomMobs.enabled) .addTargetedMod(TargetedMod.VANILLA) .addMixinClasses(addPrefix("mcpatcherforge.mob.", "MixinRender", @@ -501,7 +501,7 @@ public enum Mixins { ), MCPATCHER_FORGE_SKY(new Builder("MCP:F Sky") .setSide(Side.CLIENT).setPhase(Phase.EARLY) - .setApplyIf(() -> AngelicaConfig.enableMCPatcherForgeFeatures && MCPatcherForgeConfig.instance().betterSkiesEnabled) + .setApplyIf(() -> AngelicaConfig.enableMCPatcherForgeFeatures && MCPatcherForgeConfig.BetterSkies.enabled) .addTargetedMod(TargetedMod.VANILLA) .addMixinClasses(addPrefix("mcpatcherforge.sky.", "MixinEffectRenderer", @@ -511,32 +511,32 @@ public enum Mixins { MCPATCHER_FORGE_CC_NO_CTM(new Builder("MCP:F Custom Colors, no Connected Textures") .setSide(Side.CLIENT).setPhase(Phase.EARLY) .setApplyIf(() -> AngelicaConfig.enableMCPatcherForgeFeatures - && !MCPatcherForgeConfig.instance().connectedTexturesEnabled - && MCPatcherForgeConfig.instance().customColorsEnabled) + && !MCPatcherForgeConfig.ConnectedTextures.enabled + && MCPatcherForgeConfig.CustomColors.enabled) .addTargetedMod(TargetedMod.VANILLA) .addMixinClasses("mcpatcherforge.cc_ctm.MixinRenderBlocksNoCTM") ), MCPATCHER_FORGE_CTM_NO_CC(new Builder("MCP:F Connected Textures, no Custom Colours") .setSide(Side.CLIENT).setPhase(Phase.EARLY) .setApplyIf(() -> AngelicaConfig.enableMCPatcherForgeFeatures - && MCPatcherForgeConfig.instance().connectedTexturesEnabled - && !MCPatcherForgeConfig.instance().customColorsEnabled) + && MCPatcherForgeConfig.ConnectedTextures.enabled + && !MCPatcherForgeConfig.CustomColors.enabled) .addTargetedMod(TargetedMod.VANILLA) .addMixinClasses("mcpatcherforge.ctm_cc.MixinRenderBlocksNoCC") ), MCPATCHER_FORGE_CTM_AND_CC(new Builder("MCP:F Connected Textures and Custom Colors") .setSide(Side.CLIENT).setPhase(Phase.EARLY) .setApplyIf(() -> AngelicaConfig.enableMCPatcherForgeFeatures - && MCPatcherForgeConfig.instance().connectedTexturesEnabled - && MCPatcherForgeConfig.instance().customColorsEnabled) + && MCPatcherForgeConfig.ConnectedTextures.enabled + && MCPatcherForgeConfig.CustomColors.enabled) .addTargetedMod(TargetedMod.VANILLA) .addMixinClasses("mcpatcherforge.ctm_cc.MixinRenderBlocks") ), MCPATCHER_FORGE_CTM_OR_CC(new Builder("MCP:F Connected Textures or Custom Colors") .setSide(Side.CLIENT).setPhase(Phase.EARLY) .setApplyIf(() -> AngelicaConfig.enableMCPatcherForgeFeatures - && MCPatcherForgeConfig.instance().connectedTexturesEnabled - || MCPatcherForgeConfig.instance().customColorsEnabled) + && MCPatcherForgeConfig.ConnectedTextures.enabled + || MCPatcherForgeConfig.CustomColors.enabled) .addTargetedMod(TargetedMod.VANILLA) .addMixinClasses("mcpatcherforge.ctm_cc.MixinTextureMap") ), @@ -579,7 +579,7 @@ public static List getEarlyMixins(Set loadedCoreMods) { NotFineConfig.loadSettings(); //This may be possible to handle differently or fix. if(loadedCoreMods.contains("cofh.asm.LoadingPlugin")) { - MCPatcherForgeConfig.instance().hdFont = false; + MCPatcherForgeConfig.ExtendedHD.hdFont = false; } final List mixins = new ArrayList<>(); final List notLoading = new ArrayList<>(); diff --git a/src/main/java/com/prupe/mcpatcher/MCLogger.java b/src/main/java/com/prupe/mcpatcher/MCLogger.java index b8c43f727..7d06b90ac 100644 --- a/src/main/java/com/prupe/mcpatcher/MCLogger.java +++ b/src/main/java/com/prupe/mcpatcher/MCLogger.java @@ -1,14 +1,10 @@ package com.prupe.mcpatcher; +import jss.notfine.config.MCPatcherForgeConfig; + import java.util.HashMap; import java.util.Map; -import java.util.logging.Formatter; -import java.util.logging.Handler; -import java.util.logging.Level; -import java.util.logging.LogRecord; -import java.util.logging.Logger; - -import jss.notfine.config.MCPatcherForgeConfig; +import java.util.logging.*; public class MCLogger { @@ -44,16 +40,15 @@ public static synchronized MCLogger getLogger(Category category, String logPrefi private MCLogger(Category category, String logPrefix) { this.logPrefix = logPrefix; logger = Logger.getLogger(category.name); - MCPatcherForgeConfig config = MCPatcherForgeConfig.instance(); - logger.setLevel(Level.parse(switch (category) { - case CUSTOM_COLORS -> config.customColorsLoggingLevel; - case CUSTOM_ITEM_TEXTURES -> config.customItemTexturesLoggingLevel; - case CONNECTED_TEXTURES -> config.connectedTexturesLoggingLevel; - case EXTENDED_HD -> config.extendedHDLoggingLevel; - case RANDOM_MOBS -> config.randomMobsLoggingLevel; - case BETTER_SKIES -> config.betterSkiesLoggingLevel; - default -> Level.INFO.getName(); - })); + logger.setLevel(switch (category) { + case CUSTOM_COLORS -> MCPatcherForgeConfig.CustomColors.logging.level; + case CUSTOM_ITEM_TEXTURES -> MCPatcherForgeConfig.CustomItemTextures.logging.level; + case CONNECTED_TEXTURES -> MCPatcherForgeConfig.ConnectedTextures.logging.level; + case EXTENDED_HD -> MCPatcherForgeConfig.ExtendedHD.logging.level; + case RANDOM_MOBS -> MCPatcherForgeConfig.RandomMobs.logging.level; + case BETTER_SKIES -> MCPatcherForgeConfig.BetterSkies.logging.level; + default -> Level.INFO; + }); logger.setUseParentHandlers(false); logger.addHandler(new Handler() { diff --git a/src/main/java/com/prupe/mcpatcher/cc/ColorizeBlock.java b/src/main/java/com/prupe/mcpatcher/cc/ColorizeBlock.java index c7d2066d2..ff43808e0 100644 --- a/src/main/java/com/prupe/mcpatcher/cc/ColorizeBlock.java +++ b/src/main/java/com/prupe/mcpatcher/cc/ColorizeBlock.java @@ -34,14 +34,14 @@ public class ColorizeBlock { private static final MCLogger logger = MCLogger.getLogger(MCLogger.Category.CUSTOM_COLORS); - private static final boolean useWaterColors = MCPatcherForgeConfig.instance().ccWater; - private static final boolean useTreeColors = MCPatcherForgeConfig.instance().ccTree; - private static final boolean useRedstoneColors = MCPatcherForgeConfig.instance().ccRedstone; - private static final boolean useStemColors = MCPatcherForgeConfig.instance().ccStem; - private static final boolean useBlockColors = MCPatcherForgeConfig.instance().ccOtherBlocks; + private static final boolean useWaterColors = MCPatcherForgeConfig.CustomColors.water; + private static final boolean useTreeColors = MCPatcherForgeConfig.CustomColors.tree; + private static final boolean useRedstoneColors = MCPatcherForgeConfig.CustomColors.redstone; + private static final boolean useStemColors = MCPatcherForgeConfig.CustomColors.stem; + private static final boolean useBlockColors = MCPatcherForgeConfig.CustomColors.otherBlocks; - private static final boolean enableSmoothBiomes = MCPatcherForgeConfig.instance().smoothBiomes; - private static final boolean enableTestColorSmoothing = MCPatcherForgeConfig.instance().testColorSmoothing; + private static final boolean enableSmoothBiomes = MCPatcherForgeConfig.CustomColors.smoothBiomes; + private static final boolean enableTestColorSmoothing = MCPatcherForgeConfig.CustomColors.testColorSmoothing; private static final ResourceLocation REDSTONE_COLORS = TexturePackAPI .newMCPatcherResourceLocation("colormap/redstone.png"); @@ -73,7 +73,7 @@ public class ColorizeBlock { private static IColorMap waterColorMap; private static float[][] redstoneColor; // colormap/redstone.png - private static final int blockBlendRadius = MCPatcherForgeConfig.instance().blockBlendRadius; + private static final int blockBlendRadius = MCPatcherForgeConfig.CustomColors.blockBlendRadius; public static int blockColor; public static boolean isSmooth; diff --git a/src/main/java/com/prupe/mcpatcher/cc/ColorizeWorld.java b/src/main/java/com/prupe/mcpatcher/cc/ColorizeWorld.java index 362f73b99..17ceed792 100644 --- a/src/main/java/com/prupe/mcpatcher/cc/ColorizeWorld.java +++ b/src/main/java/com/prupe/mcpatcher/cc/ColorizeWorld.java @@ -26,7 +26,7 @@ public class ColorizeWorld { - private static final int fogBlendRadius = MCPatcherForgeConfig.instance().fogBlendRadius; + private static final int fogBlendRadius = MCPatcherForgeConfig.CustomColors.fogBlendRadius; private static final ResourceLocation UNDERWATERCOLOR = TexturePackAPI .newMCPatcherResourceLocation("colormap/underwater.png"); diff --git a/src/main/java/com/prupe/mcpatcher/cc/Colorizer.java b/src/main/java/com/prupe/mcpatcher/cc/Colorizer.java index 5f29a96d0..01eeaba97 100644 --- a/src/main/java/com/prupe/mcpatcher/cc/Colorizer.java +++ b/src/main/java/com/prupe/mcpatcher/cc/Colorizer.java @@ -20,15 +20,15 @@ public class Colorizer { static final ResourceLocation COLOR_PROPERTIES = TexturePackAPI.newMCPatcherResourceLocation("color.properties"); private static PropertiesFile properties; - static final boolean usePotionColors = MCPatcherForgeConfig.instance().ccPotion; - static final boolean useParticleColors = MCPatcherForgeConfig.instance().ccParticle; - static final boolean useFogColors = MCPatcherForgeConfig.instance().ccFog; - static final boolean useCloudType = MCPatcherForgeConfig.instance().ccClouds; - static final boolean useMapColors = MCPatcherForgeConfig.instance().ccMap; - static final boolean useDyeColors = MCPatcherForgeConfig.instance().ccDye; - static final boolean useTextColors = MCPatcherForgeConfig.instance().ccText; - static final boolean useXPOrbColors = MCPatcherForgeConfig.instance().ccXPOrb; - static final boolean useEggColors = MCPatcherForgeConfig.instance().ccEgg; + static final boolean usePotionColors = MCPatcherForgeConfig.CustomColors.potion; + static final boolean useParticleColors = MCPatcherForgeConfig.CustomColors.particle; + static final boolean useFogColors = MCPatcherForgeConfig.CustomColors.fog; + static final boolean useCloudType = MCPatcherForgeConfig.CustomColors.clouds; + static final boolean useMapColors = MCPatcherForgeConfig.CustomColors.map; + static final boolean useDyeColors = MCPatcherForgeConfig.CustomColors.dye; + static final boolean useTextColors = MCPatcherForgeConfig.CustomColors.text; + static final boolean useXPOrbColors = MCPatcherForgeConfig.CustomColors.xporb; + static final boolean useEggColors = MCPatcherForgeConfig.CustomColors.egg; public static final float[] setColor = new float[3]; diff --git a/src/main/java/com/prupe/mcpatcher/cc/Lightmap.java b/src/main/java/com/prupe/mcpatcher/cc/Lightmap.java index d0b49f29f..4a848be1d 100644 --- a/src/main/java/com/prupe/mcpatcher/cc/Lightmap.java +++ b/src/main/java/com/prupe/mcpatcher/cc/Lightmap.java @@ -24,7 +24,7 @@ public final class Lightmap { private static final int HEIGHT_WITHOUT_NIGHTVISION = 2 * LIGHTMAP_SIZE; private static final int HEIGHT_WITH_NIGHTVISION = 4 * LIGHTMAP_SIZE; - private static final boolean useLightmaps = MCPatcherForgeConfig.instance().ccLightmaps; + private static final boolean useLightmaps = MCPatcherForgeConfig.CustomColors.lightmaps; private static final Map lightmaps = new HashMap<>(); diff --git a/src/main/java/com/prupe/mcpatcher/cit/CITUtils.java b/src/main/java/com/prupe/mcpatcher/cit/CITUtils.java index 7be97f162..0445c89b6 100644 --- a/src/main/java/com/prupe/mcpatcher/cit/CITUtils.java +++ b/src/main/java/com/prupe/mcpatcher/cit/CITUtils.java @@ -46,9 +46,9 @@ public class CITUtils { static Item itemCompass; static Item itemClock; - static final boolean enableItems = MCPatcherForgeConfig.instance().citItems; - static final boolean enableEnchantments = MCPatcherForgeConfig.instance().citEnchantments; - static final boolean enableArmor = MCPatcherForgeConfig.instance().citArmor; + static final boolean enableItems = MCPatcherForgeConfig.CustomItemTextures.items; + static final boolean enableEnchantments = MCPatcherForgeConfig.CustomItemTextures.enchantments; + static final boolean enableArmor = MCPatcherForgeConfig.CustomItemTextures.armor; private static TileLoader tileLoader; private static final Map> items = new IdentityHashMap<>(); diff --git a/src/main/java/com/prupe/mcpatcher/ctm/CTMUtils.java b/src/main/java/com/prupe/mcpatcher/ctm/CTMUtils.java index 9d9f273fe..ad48f77e5 100644 --- a/src/main/java/com/prupe/mcpatcher/ctm/CTMUtils.java +++ b/src/main/java/com/prupe/mcpatcher/ctm/CTMUtils.java @@ -9,7 +9,6 @@ import java.util.Set; import net.minecraft.block.Block; -import net.minecraft.client.renderer.RenderBlocks; import net.minecraft.util.IIcon; import net.minecraft.util.ResourceLocation; import net.minecraft.world.IBlockAccess; @@ -32,8 +31,8 @@ public class CTMUtils { private static final MCLogger logger = MCLogger.getLogger(MCLogger.Category.CONNECTED_TEXTURES, "CTM"); - private static final boolean enableStandard = MCPatcherForgeConfig.instance().ctmStandard; - private static final boolean enableNonStandard = MCPatcherForgeConfig.instance().ctmNonStandard; + private static final boolean enableStandard = MCPatcherForgeConfig.ConnectedTextures.standard; + private static final boolean enableNonStandard = MCPatcherForgeConfig.ConnectedTextures.nonStandard; private static final List allOverrides = new ArrayList<>(); private static final Map> blockOverrides = new IdentityHashMap<>(); diff --git a/src/main/java/com/prupe/mcpatcher/ctm/GlassPaneRenderer.java b/src/main/java/com/prupe/mcpatcher/ctm/GlassPaneRenderer.java index 5338e5c4b..cbfad2c22 100644 --- a/src/main/java/com/prupe/mcpatcher/ctm/GlassPaneRenderer.java +++ b/src/main/java/com/prupe/mcpatcher/ctm/GlassPaneRenderer.java @@ -12,7 +12,7 @@ public class GlassPaneRenderer { - private static final boolean enable = MCPatcherForgeConfig.instance().ctmGlassPane; + private static final boolean enable = MCPatcherForgeConfig.ConnectedTextures.glassPane; public static boolean skipPaneRendering; public static boolean skipTopEdgeRendering; diff --git a/src/main/java/com/prupe/mcpatcher/ctm/TileOverrideIterator.java b/src/main/java/com/prupe/mcpatcher/ctm/TileOverrideIterator.java index e845312d0..54d15c64b 100644 --- a/src/main/java/com/prupe/mcpatcher/ctm/TileOverrideIterator.java +++ b/src/main/java/com/prupe/mcpatcher/ctm/TileOverrideIterator.java @@ -15,7 +15,7 @@ abstract public class TileOverrideIterator implements Iterator { - private static final int MAX_RECURSION = MCPatcherForgeConfig.instance().maxRecursion; + private static final int MAX_RECURSION = MCPatcherForgeConfig.ConnectedTextures.maxRecursion; private final Map> allBlockOverrides; private final Map> allTileOverrides; diff --git a/src/main/java/com/prupe/mcpatcher/hd/CustomAnimation.java b/src/main/java/com/prupe/mcpatcher/hd/CustomAnimation.java index 9abdcc1cd..a3d0d1462 100644 --- a/src/main/java/com/prupe/mcpatcher/hd/CustomAnimation.java +++ b/src/main/java/com/prupe/mcpatcher/hd/CustomAnimation.java @@ -28,7 +28,7 @@ public class CustomAnimation implements Comparable { private static final MCLogger logger = MCLogger.getLogger(MCLogger.Category.EXTENDED_HD, "Animation"); - private static final boolean enable = MCPatcherForgeConfig.instance().animations; + private static final boolean enable = MCPatcherForgeConfig.ExtendedHD.animations; private static final Set pending = new HashSet<>(); private static final List animations = new ArrayList<>(); diff --git a/src/main/java/com/prupe/mcpatcher/hd/FancyDial.java b/src/main/java/com/prupe/mcpatcher/hd/FancyDial.java index 869360e05..c51884fe5 100644 --- a/src/main/java/com/prupe/mcpatcher/hd/FancyDial.java +++ b/src/main/java/com/prupe/mcpatcher/hd/FancyDial.java @@ -48,10 +48,10 @@ public class FancyDial { private static final boolean fboSupported = GLContext.getCapabilities().GL_EXT_framebuffer_object; private static final boolean gl13Supported = GLContext.getCapabilities().OpenGL13; - private static final boolean enableCompass = MCPatcherForgeConfig.instance().fancyCompass; - private static final boolean enableClock = MCPatcherForgeConfig.instance().fancyClock; - private static final boolean useGL13 = gl13Supported && MCPatcherForgeConfig.instance().useGL13; - private static final boolean useScratchTexture = MCPatcherForgeConfig.instance().useScratchTexture; + private static final boolean enableCompass = MCPatcherForgeConfig.ExtendedHD.fancyCompass; + private static final boolean enableClock = MCPatcherForgeConfig.ExtendedHD.fancyClock; + private static final boolean useGL13 = gl13Supported && MCPatcherForgeConfig.ExtendedHD.useGL13; + private static final boolean useScratchTexture = MCPatcherForgeConfig.ExtendedHD.useScratchTexture; private static final int glAttributes; private static boolean initialized; private static boolean active; diff --git a/src/main/java/com/prupe/mcpatcher/hd/FontUtils.java b/src/main/java/com/prupe/mcpatcher/hd/FontUtils.java index fc8142110..de8e297d6 100644 --- a/src/main/java/com/prupe/mcpatcher/hd/FontUtils.java +++ b/src/main/java/com/prupe/mcpatcher/hd/FontUtils.java @@ -21,8 +21,8 @@ public class FontUtils { private static final MCLogger logger = MCLogger.getLogger(MCLogger.Category.EXTENDED_HD); - private static final boolean enable = MCPatcherForgeConfig.instance().hdFont; - private static final boolean enableNonHD = MCPatcherForgeConfig.instance().nonHDFontWidth; + private static final boolean enable = MCPatcherForgeConfig.ExtendedHD.hdFont; + private static final boolean enableNonHD = MCPatcherForgeConfig.ExtendedHD.nonHDFontWidth; private static final int ROWS = 16; private static final int COLS = 16; diff --git a/src/main/java/com/prupe/mcpatcher/hd/MipmapHelper.java b/src/main/java/com/prupe/mcpatcher/hd/MipmapHelper.java index 76cfd0472..18bf250f7 100644 --- a/src/main/java/com/prupe/mcpatcher/hd/MipmapHelper.java +++ b/src/main/java/com/prupe/mcpatcher/hd/MipmapHelper.java @@ -32,8 +32,8 @@ public class MipmapHelper { static final int TEX_DATA_TYPE = GL12.GL_UNSIGNED_INT_8_8_8_8_REV; private static final boolean mipmapSupported; - static final boolean mipmapEnabled = MCPatcherForgeConfig.instance().mipmap; - static final int maxMipmapLevel = MCPatcherForgeConfig.instance().maxMipMapLevel; + static final boolean mipmapEnabled = MCPatcherForgeConfig.ExtendedHD.mipmap; + static final int maxMipmapLevel = MCPatcherForgeConfig.ExtendedHD.maxMipMapLevel; private static final boolean useMipmap; private static final boolean anisoSupported; @@ -53,14 +53,14 @@ public class MipmapHelper { if (anisoSupported) { anisoMax = (int) GL11.glGetFloat(EXTTextureFilterAnisotropic.GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT); checkGLError("glGetFloat(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT)"); - anisoLevel = Math.max(Math.min(MCPatcherForgeConfig.instance().anisotropicFiltering, anisoMax), 1); + anisoLevel = Math.max(Math.min(MCPatcherForgeConfig.ExtendedHD.anisotropicFiltering, anisoMax), 1); } else { anisoMax = anisoLevel = 1; } lodSupported = GLContext.getCapabilities().GL_EXT_texture_lod_bias; if (lodSupported) { - lodBias = MCPatcherForgeConfig.instance().lodBias; + lodBias = MCPatcherForgeConfig.ExtendedHD.lodBias; } else { lodBias = 0; } diff --git a/src/main/java/com/prupe/mcpatcher/mal/biome/ColorMap.java b/src/main/java/com/prupe/mcpatcher/mal/biome/ColorMap.java index 61a275cda..ff1d3a3cb 100644 --- a/src/main/java/com/prupe/mcpatcher/mal/biome/ColorMap.java +++ b/src/main/java/com/prupe/mcpatcher/mal/biome/ColorMap.java @@ -25,7 +25,7 @@ abstract public class ColorMap implements IColorMap { private static final MCLogger logger = MCLogger.getLogger(MCLogger.Category.CUSTOM_COLORS); - public static final boolean useSwampColors = MCPatcherForgeConfig.instance().swampColors; + public static final boolean useSwampColors = MCPatcherForgeConfig.CustomColors.swampColors; private static final int FIXED = 0; private static final int TEMPERATURE_HUMIDITY = 1; @@ -165,7 +165,7 @@ public static void reset() { unusedPNGs.clear(); defaultColorMapFormat = TEMPERATURE_HUMIDITY; defaultFlipY = false; - defaultYVariance = MCPatcherForgeConfig.instance().yVariance; + defaultYVariance = MCPatcherForgeConfig.CustomColors.yVariance; } public static void reloadColorMapSettings(PropertiesFile properties) { diff --git a/src/main/java/com/prupe/mcpatcher/mal/block/RenderBlocksUtils.java b/src/main/java/com/prupe/mcpatcher/mal/block/RenderBlocksUtils.java index 7b0b0be9b..012bce479 100644 --- a/src/main/java/com/prupe/mcpatcher/mal/block/RenderBlocksUtils.java +++ b/src/main/java/com/prupe/mcpatcher/mal/block/RenderBlocksUtils.java @@ -11,7 +11,7 @@ // Shared by both CTM and Custom Colors. public class RenderBlocksUtils { - public static final boolean enableBetterGrass = MCPatcherForgeConfig.instance().betterGrass; + public static final boolean enableBetterGrass = MCPatcherForgeConfig.ConnectedTextures.betterGrass; private static final int COLOR = 0; private static final int NONCOLOR = 1; diff --git a/src/main/java/com/prupe/mcpatcher/mal/tile/TileLoader.java b/src/main/java/com/prupe/mcpatcher/mal/tile/TileLoader.java index a2cd40c1c..135faceb0 100644 --- a/src/main/java/com/prupe/mcpatcher/mal/tile/TileLoader.java +++ b/src/main/java/com/prupe/mcpatcher/mal/tile/TileLoader.java @@ -31,7 +31,7 @@ public class TileLoader { private static final List loaders = new ArrayList<>(); - private static final boolean debugTextures = MCPatcherForgeConfig.instance().debugTextures; + private static final boolean debugTextures = MCPatcherForgeConfig.ConnectedTextures.debugTextures; private static final Map specialTextures = new HashMap<>(); private static final TexturePackChangeHandler changeHandler; diff --git a/src/main/java/com/prupe/mcpatcher/mob/LineRenderer.java b/src/main/java/com/prupe/mcpatcher/mob/LineRenderer.java index 7ab4247cf..cd106bb72 100644 --- a/src/main/java/com/prupe/mcpatcher/mob/LineRenderer.java +++ b/src/main/java/com/prupe/mcpatcher/mob/LineRenderer.java @@ -20,7 +20,7 @@ public class LineRenderer { private static final double D_WIDTH = 1.0 / 1024.0; private static final double D_POS = 1.0 / 256.0; - private static final boolean enable = MCPatcherForgeConfig.instance().leashLine; + private static final boolean enable = MCPatcherForgeConfig.RandomMobs.leashLine; private static final LineRenderer[] renderers = new LineRenderer[2]; private final ResourceLocation texture; diff --git a/src/main/java/com/prupe/mcpatcher/sky/FireworksHelper.java b/src/main/java/com/prupe/mcpatcher/sky/FireworksHelper.java index 6749f95d9..2cfc8623a 100644 --- a/src/main/java/com/prupe/mcpatcher/sky/FireworksHelper.java +++ b/src/main/java/com/prupe/mcpatcher/sky/FireworksHelper.java @@ -23,7 +23,7 @@ public class FireworksHelper { .newMCPatcherResourceLocation("particle.properties"); private static final MCLogger logger = MCLogger.getLogger(MCLogger.Category.BETTER_SKIES); - private static final boolean enable = MCPatcherForgeConfig.instance().brightenFireworks; + private static final boolean enable = MCPatcherForgeConfig.BetterSkies.brightenFireworks; private static BlendMethod blendMethod; public static int getFXLayer(EntityFX entity) { diff --git a/src/main/java/com/prupe/mcpatcher/sky/SkyRenderer.java b/src/main/java/com/prupe/mcpatcher/sky/SkyRenderer.java index 698e66e61..9aca2470a 100644 --- a/src/main/java/com/prupe/mcpatcher/sky/SkyRenderer.java +++ b/src/main/java/com/prupe/mcpatcher/sky/SkyRenderer.java @@ -28,9 +28,9 @@ public class SkyRenderer { private static final MCLogger logger = MCLogger.getLogger(MCLogger.Category.BETTER_SKIES); - private static final boolean enable = MCPatcherForgeConfig.instance().skybox; - private static final boolean unloadTextures = MCPatcherForgeConfig.instance().unloadTextures; - public static final double horizonHeight = MCPatcherForgeConfig.instance().horizon; + private static final boolean enable = MCPatcherForgeConfig.BetterSkies.skybox; + private static final boolean unloadTextures = MCPatcherForgeConfig.BetterSkies.unloadTextures; + public static final double horizonHeight = MCPatcherForgeConfig.BetterSkies.horizon; private static double worldTime; private static float celestialAngle; diff --git a/src/main/java/jss/notfine/McPatcherForge.java b/src/main/java/jss/notfine/McPatcherForge.java index 27edca6fe..458d5e83f 100644 --- a/src/main/java/jss/notfine/McPatcherForge.java +++ b/src/main/java/jss/notfine/McPatcherForge.java @@ -7,6 +7,7 @@ version = "1.0.0-alpha", name = "MCPatcherForge", acceptedMinecraftVersions = "[1.7.10]", - acceptableRemoteVersions = "*") + acceptableRemoteVersions = "*", + guiFactory = "jss.notfine.config.MCPatcherForgeGuiConfigFactory") public class McPatcherForge { } diff --git a/src/main/java/jss/notfine/asm/AsmTransformers.java b/src/main/java/jss/notfine/asm/AsmTransformers.java index 072fdfdfe..794689f20 100644 --- a/src/main/java/jss/notfine/asm/AsmTransformers.java +++ b/src/main/java/jss/notfine/asm/AsmTransformers.java @@ -18,7 +18,7 @@ public enum AsmTransformers { RENDERBLOCKS("RenderBlocks transformer", () -> AngelicaConfig.enableMCPatcherForgeFeatures - && MCPatcherForgeConfig.instance().customColorsEnabled, + && MCPatcherForgeConfig.CustomColors.enabled, Side.CLIENT, "jss.notfine.asm.RenderBlocksTransformer"), WORLDRENDERER("WorldRenderer transformer", () -> NotFineConfig.renderPass, Side.CLIENT, "jss.notfine.asm.WorldRendererTransformer"); diff --git a/src/main/java/jss/notfine/config/MCPatcherForgeConfig.java b/src/main/java/jss/notfine/config/MCPatcherForgeConfig.java index 69e917b9e..ad35dc642 100644 --- a/src/main/java/jss/notfine/config/MCPatcherForgeConfig.java +++ b/src/main/java/jss/notfine/config/MCPatcherForgeConfig.java @@ -1,179 +1,302 @@ package jss.notfine.config; -import java.io.File; -import java.util.logging.Level; +import com.gtnewhorizon.gtnhlib.config.Config; +import com.gtnewhorizon.gtnhlib.config.ConfigException; +import com.gtnewhorizon.gtnhlib.config.ConfigurationManager; -import net.minecraft.launchwrapper.Launch; -import net.minecraftforge.common.config.Configuration; +import java.util.logging.Level; -// Adapted from hodgepodge public class MCPatcherForgeConfig { - private static MCPatcherForgeConfig config; - - // CUSTOM_COLORS - public boolean customColorsEnabled; - public String customColorsLoggingLevel; - public int yVariance; - public int blockBlendRadius; - public int fogBlendRadius; - public boolean swampColors; - public boolean ccWater; - public boolean ccTree; - public boolean ccRedstone; - public boolean ccStem; - public boolean ccOtherBlocks; - public boolean smoothBiomes; - public boolean testColorSmoothing; - public boolean ccPotion; - public boolean ccParticle; - public boolean ccFog; - public boolean ccClouds; - public boolean ccMap; - public boolean ccDye; - public boolean ccText; - public boolean ccXPOrb; - public boolean ccEgg; - public boolean ccLightmaps; - - // CUSTOM_ITEM_TEXTURES - public boolean customItemTexturesEnabled; - public String customItemTexturesLoggingLevel; - public boolean citItems; - public boolean citEnchantments; - public boolean citArmor; - - // CONNECTED_TEXTURES - public boolean connectedTexturesEnabled; - public String connectedTexturesLoggingLevel; - public int maxRecursion; - public boolean debugTextures; - public boolean betterGrass; - public boolean ctmStandard; - public boolean ctmNonStandard; - public boolean ctmGlassPane; - - // EXTENDED_HD - public boolean extendedHDEnabled; - public String extendedHDLoggingLevel; - public int maxMipMapLevel; - public int anisotropicFiltering; - public int lodBias; - public boolean animations; - public boolean fancyCompass; - public boolean fancyClock; - public boolean useGL13; - public boolean useScratchTexture; - public boolean hdFont; - public boolean nonHDFontWidth; - public boolean mipmap; - - // RANDOM_MOBS - public boolean randomMobsEnabled; - public String randomMobsLoggingLevel; - public boolean leashLine; - - // BETTER_SKIES - public boolean betterSkiesEnabled; - public String betterSkiesLoggingLevel; - public int horizon; - public boolean brightenFireworks; - public boolean skybox; - public boolean unloadTextures; - - public enum Category { - - CUSTOM_COLORS, - CUSTOM_ITEM_TEXTURES, - CONNECTED_TEXTURES, - EXTENDED_HD, - RANDOM_MOBS, - BETTER_SKIES; - - @Override - public String toString() { - return name().toLowerCase(); - } + @Config(modid = "mcpatcherforge", category = "custom_colors") + public static class CustomColors { + @Config.Comment("Enable the custom colors module") + @Config.DefaultBoolean(true) + @Config.RequiresMcRestart + public static boolean enabled; + + @Config.Comment("logging level") + @Config.DefaultEnum("INFO") + @Config.RequiresMcRestart + public static LogLevel logging; + + @Config.DefaultInt(0) + @Config.RequiresMcRestart + public static int yVariance; + + @Config.DefaultInt(4) + @Config.RequiresMcRestart + public static int blockBlendRadius; + + @Config.DefaultInt(7) + @Config.RequiresMcRestart + public static int fogBlendRadius; + + @Config.DefaultBoolean(true) + @Config.RequiresMcRestart + public static boolean swampColors; + + @Config.DefaultBoolean(true) + @Config.RequiresMcRestart + public static boolean water; + + @Config.DefaultBoolean(true) + @Config.RequiresMcRestart + public static boolean tree; + + @Config.DefaultBoolean(true) + @Config.RequiresMcRestart + public static boolean redstone; + + @Config.DefaultBoolean(true) + @Config.RequiresMcRestart + public static boolean stem; + + @Config.DefaultBoolean(true) + @Config.RequiresMcRestart + public static boolean otherBlocks; + + @Config.DefaultBoolean(true) + @Config.RequiresMcRestart + public static boolean smoothBiomes; + + @Config.DefaultBoolean(false) + @Config.RequiresMcRestart + public static boolean testColorSmoothing; + + @Config.DefaultBoolean(true) + @Config.RequiresMcRestart + public static boolean potion; + + @Config.DefaultBoolean(true) + @Config.RequiresMcRestart + public static boolean particle; + + @Config.DefaultBoolean(true) + @Config.RequiresMcRestart + public static boolean fog; + + @Config.DefaultBoolean(true) + @Config.RequiresMcRestart + public static boolean clouds; + + @Config.DefaultBoolean(true) + @Config.RequiresMcRestart + public static boolean map; + + @Config.DefaultBoolean(true) + @Config.RequiresMcRestart + public static boolean dye; + + @Config.DefaultBoolean(true) + @Config.RequiresMcRestart + public static boolean text; + + @Config.DefaultBoolean(true) + @Config.RequiresMcRestart + public static boolean xporb; + + @Config.DefaultBoolean(true) + @Config.RequiresMcRestart + public static boolean egg; + + @Config.DefaultBoolean(true) + @Config.RequiresMcRestart + public static boolean lightmaps; } - public static MCPatcherForgeConfig instance() { - if (config == null) { - config = new MCPatcherForgeConfig(new File(Launch.minecraftHome, "config/mcpatcherforge.cfg")); - } - return config; + @Config(modid = "mcpatcherforge", category = "custom_item_textures") + public static class CustomItemTextures { + @Config.Comment("Enable the custom item textures module") + @Config.DefaultBoolean(true) + @Config.RequiresMcRestart + public static boolean enabled; + + @Config.Comment("logging level") + @Config.DefaultEnum("INFO") + @Config.RequiresMcRestart + public static LogLevel logging; + + @Config.DefaultBoolean(true) + @Config.RequiresMcRestart + public static boolean items; + + @Config.DefaultBoolean(true) + @Config.RequiresMcRestart + public static boolean enchantments; + + @Config.DefaultBoolean(true) + @Config.RequiresMcRestart + public static boolean armor; } - public MCPatcherForgeConfig(File file) { - Configuration config = new Configuration(file); - - // spotless:off - - customColorsEnabled = config.get(Category.CUSTOM_COLORS.toString(),"enabled",true,"Enable the custom colors module").getBoolean(); - customColorsLoggingLevel = config.get(Category.CUSTOM_COLORS.toString(),"logging",Level.INFO.getName(),"logging level").getString(); - yVariance = config.get(Category.CUSTOM_COLORS.toString(),"yVariance",0).getInt(); - blockBlendRadius = config.get(Category.CUSTOM_COLORS.toString(),"blockBlendRadius",4).getInt(); - fogBlendRadius = config.get(Category.CUSTOM_COLORS.toString(),"fogBlendRadius",7).getInt(); - swampColors = config.get(Category.CUSTOM_COLORS.toString(),"swampColors",true).getBoolean(); - ccWater = config.get(Category.CUSTOM_COLORS.toString(),"water",true).getBoolean(); - ccTree = config.get(Category.CUSTOM_COLORS.toString(),"tree",true).getBoolean(); - ccRedstone = config.get(Category.CUSTOM_COLORS.toString(),"redstone",true).getBoolean(); - ccStem = config.get(Category.CUSTOM_COLORS.toString(),"stem",true).getBoolean(); - ccOtherBlocks = config.get(Category.CUSTOM_COLORS.toString(),"otherBlocks",true).getBoolean(); - smoothBiomes = config.get(Category.CUSTOM_COLORS.toString(),"smoothBiomes",true).getBoolean(); - testColorSmoothing = config.get(Category.CUSTOM_COLORS.toString(),"testColorSmoothing",false).getBoolean(); - ccPotion = config.get(Category.CUSTOM_COLORS.toString(),"potion",true).getBoolean(); - ccParticle = config.get(Category.CUSTOM_COLORS.toString(),"particle",true).getBoolean(); - ccFog = config.get(Category.CUSTOM_COLORS.toString(),"fog",true).getBoolean(); - ccClouds = config.get(Category.CUSTOM_COLORS.toString(),"clouds",true).getBoolean(); - ccMap = config.get(Category.CUSTOM_COLORS.toString(),"map",true).getBoolean(); - ccDye = config.get(Category.CUSTOM_COLORS.toString(),"dye",true).getBoolean(); - ccText = config.get(Category.CUSTOM_COLORS.toString(),"text",true).getBoolean(); - ccXPOrb = config.get(Category.CUSTOM_COLORS.toString(),"xporb",true).getBoolean(); - ccEgg = config.get(Category.CUSTOM_COLORS.toString(),"egg",true).getBoolean(); - ccLightmaps = config.get(Category.CUSTOM_COLORS.toString(),"lightmaps",true).getBoolean(); - - customItemTexturesEnabled = config.get(Category.CUSTOM_ITEM_TEXTURES.toString(),"enabled",true,"Enable the custom item textures module").getBoolean(); - customItemTexturesLoggingLevel = config.get(Category.CUSTOM_ITEM_TEXTURES.toString(),"logging",Level.INFO.getName(),"logging level").getString(); - citItems = config.get(Category.CUSTOM_ITEM_TEXTURES.toString(),"items",true).getBoolean(); - citEnchantments = config.get(Category.CUSTOM_ITEM_TEXTURES.toString(),"enchantments",true).getBoolean(); - citArmor = config.get(Category.CUSTOM_ITEM_TEXTURES.toString(),"armor",true).getBoolean(); - - connectedTexturesEnabled = config.get(Category.CONNECTED_TEXTURES.toString(),"enabled",true,"Enable the connected textures module").getBoolean(); - connectedTexturesLoggingLevel = config.get(Category.CONNECTED_TEXTURES.toString(),"logging",Level.INFO.getName(),"logging level").getString(); - maxRecursion = config.get(Category.CONNECTED_TEXTURES.toString(),"maxRecursion",4).getInt(); - debugTextures = config.get(Category.CONNECTED_TEXTURES.toString(),"debugTextures",false).getBoolean(); - betterGrass = config.get(Category.CONNECTED_TEXTURES.toString(),"betterGrass",false).getBoolean(); - ctmStandard = config.get(Category.CONNECTED_TEXTURES.toString(),"standard",true).getBoolean(); - ctmNonStandard = config.get(Category.CONNECTED_TEXTURES.toString(),"nonStandard",true).getBoolean(); - ctmGlassPane = config.get(Category.CONNECTED_TEXTURES.toString(),"glassPane",false).getBoolean(); - - extendedHDEnabled = config.get(Category.EXTENDED_HD.toString(),"enabled",true,"Enable the extended hd module").getBoolean(); - extendedHDLoggingLevel = config.get(Category.EXTENDED_HD.toString(),"logging",Level.INFO.getName(),"logging level").getString(); - maxMipMapLevel = config.get(Category.EXTENDED_HD.toString(),"maxMipMapLevel",3).getInt(); - anisotropicFiltering = config.get(Category.EXTENDED_HD.toString(),"anisotropicFiltering",1).getInt(); - lodBias = config.get(Category.EXTENDED_HD.toString(),"lod bias",0).getInt(); - - animations = config.get(Category.EXTENDED_HD.toString(),"animations",true).getBoolean(); - fancyCompass = config.get(Category.EXTENDED_HD.toString(),"fancyCompass",true).getBoolean(); - fancyClock = config.get(Category.EXTENDED_HD.toString(),"fancyClock",true).getBoolean(); - useGL13 = config.get(Category.EXTENDED_HD.toString(),"useGL13",true).getBoolean(); - useScratchTexture = config.get(Category.EXTENDED_HD.toString(),"useScratchTexture",true).getBoolean(); - hdFont = config.get(Category.EXTENDED_HD.toString(),"HDFont",true).getBoolean(); - nonHDFontWidth = config.get(Category.EXTENDED_HD.toString(),"nonHDFontWidth",false).getBoolean(); - mipmap = config.get(Category.EXTENDED_HD.toString(),"mipmap",false).getBoolean(); - - randomMobsEnabled = config.get(Category.RANDOM_MOBS.toString(),"enabled",true,"Enable the random mobs module").getBoolean(); - randomMobsLoggingLevel = config.get(Category.RANDOM_MOBS.toString(),"logging",Level.INFO.getName(),"logging level").getString(); - leashLine = config.get(Category.RANDOM_MOBS.toString(),"leashLine",true).getBoolean(); - - betterSkiesEnabled = config.get(Category.BETTER_SKIES.toString(),"enabled",true,"Enable the better skies module").getBoolean(); - betterSkiesLoggingLevel = config.get(Category.BETTER_SKIES.toString(),"logging",Level.INFO.getName(),"logging level").getString(); - horizon = config.get(Category.BETTER_SKIES.toString(),"horizon",16).getInt(); - brightenFireworks = config.get(Category.BETTER_SKIES.toString(),"brightenFireworks",true).getBoolean(); - skybox = config.get(Category.BETTER_SKIES.toString(),"skybox",true).getBoolean(); - unloadTextures = config.get(Category.BETTER_SKIES.toString(),"unloadTextures",true).getBoolean(); - - // spotless:on - if (config.hasChanged()) config.save(); + @Config(modid = "mcpatcherforge", category = "connected_textures") + public static class ConnectedTextures { + @Config.Comment("Enable the connected textures module") + @Config.DefaultBoolean(true) + @Config.RequiresMcRestart + public static boolean enabled; + + @Config.Comment("logging level") + @Config.DefaultEnum("INFO") + @Config.RequiresMcRestart + public static LogLevel logging; + + @Config.DefaultInt(4) + @Config.RequiresMcRestart + public static int maxRecursion; + + @Config.DefaultBoolean(false) + @Config.RequiresMcRestart + public static boolean debugTextures; + + @Config.DefaultBoolean(false) + @Config.RequiresMcRestart + public static boolean betterGrass; + + @Config.DefaultBoolean(true) + @Config.RequiresMcRestart + public static boolean standard; + + @Config.DefaultBoolean(true) + @Config.RequiresMcRestart + public static boolean nonStandard; + + @Config.DefaultBoolean(false) + @Config.RequiresMcRestart + public static boolean glassPane; + } + + @Config(modid = "mcpatcherforge", category = "extended_hd") + public static class ExtendedHD { + @Config.Comment("Enable the extended hd module") + @Config.DefaultBoolean(true) + @Config.RequiresMcRestart + public static boolean enabled; + + @Config.Comment("logging level") + @Config.DefaultEnum("INFO") + @Config.RequiresMcRestart + public static LogLevel logging; + + @Config.DefaultInt(3) + @Config.RequiresMcRestart + public static int maxMipMapLevel; + + @Config.DefaultInt(1) + @Config.RequiresMcRestart + public static int anisotropicFiltering; + + @Config.DefaultInt(0) + @Config.RequiresMcRestart + @Config.Name("lod bias") + public static int lodBias; + + @Config.DefaultBoolean(true) + @Config.RequiresMcRestart + public static boolean animations; + + @Config.DefaultBoolean(true) + @Config.RequiresMcRestart + public static boolean fancyCompass; + + @Config.DefaultBoolean(true) + @Config.RequiresMcRestart + public static boolean fancyClock; + + @Config.DefaultBoolean(true) + @Config.RequiresMcRestart + public static boolean useGL13; + + @Config.DefaultBoolean(true) + @Config.RequiresMcRestart + public static boolean useScratchTexture; + + @Config.DefaultBoolean(true) + @Config.RequiresMcRestart + @Config.Name("HDFont") + public static boolean hdFont; + + @Config.DefaultBoolean(false) + @Config.RequiresMcRestart + public static boolean nonHDFontWidth; + + @Config.DefaultBoolean(false) + @Config.RequiresMcRestart + public static boolean mipmap; + } + + @Config(modid = "mcpatcherforge", category = "random_mobs") + public static class RandomMobs { + @Config.Comment("Enable the random mobs module") + @Config.DefaultBoolean(true) + @Config.RequiresMcRestart + public static boolean enabled; + + @Config.Comment("logging level") + @Config.DefaultEnum("INFO") + @Config.RequiresMcRestart + public static LogLevel logging; + + @Config.DefaultBoolean(true) + @Config.RequiresMcRestart + public static boolean leashLine; + } + + @Config(modid = "mcpatcherforge", category = "better_skies") + public static class BetterSkies { + @Config.Comment("Enable the better skies module") + @Config.DefaultBoolean(true) + @Config.RequiresMcRestart + public static boolean enabled; + + @Config.Comment("logging level") + @Config.DefaultEnum("INFO") + @Config.RequiresMcRestart + public static LogLevel logging; + + @Config.DefaultInt(16) + @Config.RequiresMcRestart + public static int horizon; + + @Config.DefaultBoolean(true) + @Config.RequiresMcRestart + public static boolean brightenFireworks; + + @Config.DefaultBoolean(true) + @Config.RequiresMcRestart + public static boolean skybox; + + @Config.DefaultBoolean(true) + @Config.RequiresMcRestart + public static boolean unloadTextures; + } + + public static void registerConfig() throws ConfigException { + ConfigurationManager.registerConfig(CustomColors.class); + ConfigurationManager.registerConfig(CustomItemTextures.class); + ConfigurationManager.registerConfig(ConnectedTextures.class); + ConfigurationManager.registerConfig(ExtendedHD.class); + ConfigurationManager.registerConfig(RandomMobs.class); + ConfigurationManager.registerConfig(BetterSkies.class); + } + + public enum LogLevel { + OFF(Level.OFF), + SEVERE(Level.SEVERE), + WARNING(Level.WARNING), + INFO(Level.INFO), + CONFIG(Level.CONFIG), + FINE(Level.FINE), + FINER(Level.FINER), + FINEST(Level.FINEST), + ALL(Level.ALL); + + @Config.Ignore + public final Level level; + + LogLevel(Level level) { + this.level = level; + } } } diff --git a/src/main/java/jss/notfine/config/MCPatcherForgeGuiConfig.java b/src/main/java/jss/notfine/config/MCPatcherForgeGuiConfig.java new file mode 100644 index 000000000..aff4ba81a --- /dev/null +++ b/src/main/java/jss/notfine/config/MCPatcherForgeGuiConfig.java @@ -0,0 +1,18 @@ +package jss.notfine.config; + +import com.gtnewhorizon.gtnhlib.config.ConfigException; +import com.gtnewhorizon.gtnhlib.config.SimpleGuiConfig; +import net.minecraft.client.gui.GuiScreen; + +public class MCPatcherForgeGuiConfig extends SimpleGuiConfig { + public MCPatcherForgeGuiConfig(GuiScreen parent) throws ConfigException { + super(parent, "mcpatcherforge", "MCPatcherForge", true, + MCPatcherForgeConfig.CustomColors.class, + MCPatcherForgeConfig.CustomItemTextures.class, + MCPatcherForgeConfig.ConnectedTextures.class, + MCPatcherForgeConfig.ExtendedHD.class, + MCPatcherForgeConfig.RandomMobs.class, + MCPatcherForgeConfig.BetterSkies.class + ); + } +} diff --git a/src/main/java/jss/notfine/config/MCPatcherForgeGuiConfigFactory.java b/src/main/java/jss/notfine/config/MCPatcherForgeGuiConfigFactory.java new file mode 100644 index 000000000..9a6fe95d2 --- /dev/null +++ b/src/main/java/jss/notfine/config/MCPatcherForgeGuiConfigFactory.java @@ -0,0 +1,11 @@ +package jss.notfine.config; + +import com.gtnewhorizon.gtnhlib.config.SimpleGuiFactory; +import net.minecraft.client.gui.GuiScreen; + +public class MCPatcherForgeGuiConfigFactory implements SimpleGuiFactory { + @Override + public Class mainConfigGuiClass() { + return MCPatcherForgeGuiConfig.class; + } +} diff --git a/src/mixin/java/com/gtnewhorizons/angelica/mixins/early/mcpatcherforge/base/MixinMinecraft.java b/src/mixin/java/com/gtnewhorizons/angelica/mixins/early/mcpatcherforge/base/MixinMinecraft.java index 8682b7dfc..ddbdc8afd 100644 --- a/src/mixin/java/com/gtnewhorizons/angelica/mixins/early/mcpatcherforge/base/MixinMinecraft.java +++ b/src/mixin/java/com/gtnewhorizons/angelica/mixins/early/mcpatcherforge/base/MixinMinecraft.java @@ -61,17 +61,16 @@ private void modifyConstructor(Session sessionIn, int displayWidth, int displayH private void modifyStartGame1(CallbackInfo ci) { TileLoader.init(); CTMUtils.reset(); - MCPatcherForgeConfig config = MCPatcherForgeConfig.instance(); - if (config.customItemTexturesEnabled) { + if (MCPatcherForgeConfig.CustomItemTextures.enabled) { CITUtils.init(); } - if (config.extendedHDEnabled) { + if (MCPatcherForgeConfig.ExtendedHD.enabled) { FontUtils.init(); } - if (config.randomMobsEnabled) { + if (MCPatcherForgeConfig.RandomMobs.enabled) { MobRandomizer.init(); } - if (config.customColorsEnabled) { + if (MCPatcherForgeConfig.CustomColors.enabled) { Colorizer.init(); } } From 1c8c01e90465a46aedac34c18998dc476f32a502 Mon Sep 17 00:00:00 2001 From: kurrycat Date: Wed, 20 Nov 2024 23:25:11 +0100 Subject: [PATCH 2/4] fix connected textures --- .../com/prupe/mcpatcher/ctm/CTMUtils.java | 7 +- .../mcpatcher/ctm/GlassPaneRenderer.java | 4 +- .../mcpatcher/ctm/TileOverrideIterator.java | 4 +- .../mal/block/RenderBlocksUtils.java | 6 +- .../prupe/mcpatcher/mal/tile/TileLoader.java | 3 +- .../notfine/config/MCPatcherForgeConfig.java | 6 -- .../mcpatcherforge/ctm/MixinRenderBlocks.java | 74 +++++++++++++------ 7 files changed, 57 insertions(+), 47 deletions(-) diff --git a/src/main/java/com/prupe/mcpatcher/ctm/CTMUtils.java b/src/main/java/com/prupe/mcpatcher/ctm/CTMUtils.java index ad48f77e5..8db741a31 100644 --- a/src/main/java/com/prupe/mcpatcher/ctm/CTMUtils.java +++ b/src/main/java/com/prupe/mcpatcher/ctm/CTMUtils.java @@ -31,9 +31,6 @@ public class CTMUtils { private static final MCLogger logger = MCLogger.getLogger(MCLogger.Category.CONNECTED_TEXTURES, "CTM"); - private static final boolean enableStandard = MCPatcherForgeConfig.ConnectedTextures.standard; - private static final boolean enableNonStandard = MCPatcherForgeConfig.ConnectedTextures.nonStandard; - private static final List allOverrides = new ArrayList<>(); private static final Map> blockOverrides = new IdentityHashMap<>(); private static final Map> tileOverrides = new HashMap<>(); @@ -80,7 +77,7 @@ public void beforeChange() { tileLoader = new TileLoader("textures/blocks", logger); RenderPassAPI.instance.refreshBlendingOptions(); - if (enableStandard || enableNonStandard) { + if (MCPatcherForgeConfig.ConnectedTextures.standard || MCPatcherForgeConfig.ConnectedTextures.nonStandard) { for (ResourceLocation resource : ResourceList.getInstance() .listResources(TexturePackAPI.MCPATCHER_SUBDIR + "ctm", ".properties", true)) { registerOverride(TileOverride.create(resource, tileLoader)); @@ -159,7 +156,7 @@ public static IIcon getBlockIcon(IIcon icon, Block block, int face) { public static void reset() {} private static boolean checkFace(int face) { - return face < 0 ? enableNonStandard : enableStandard; + return face < 0 ? MCPatcherForgeConfig.ConnectedTextures.nonStandard : MCPatcherForgeConfig.ConnectedTextures.standard; } private static boolean checkRenderType(Block block) { diff --git a/src/main/java/com/prupe/mcpatcher/ctm/GlassPaneRenderer.java b/src/main/java/com/prupe/mcpatcher/ctm/GlassPaneRenderer.java index cbfad2c22..e97d7b3c3 100644 --- a/src/main/java/com/prupe/mcpatcher/ctm/GlassPaneRenderer.java +++ b/src/main/java/com/prupe/mcpatcher/ctm/GlassPaneRenderer.java @@ -12,8 +12,6 @@ public class GlassPaneRenderer { - private static final boolean enable = MCPatcherForgeConfig.ConnectedTextures.glassPane; - public static boolean skipPaneRendering; public static boolean skipTopEdgeRendering; public static boolean skipBottomEdgeRendering; @@ -47,7 +45,7 @@ public static void renderThick(RenderBlocks renderBlocks, Block blockPane, IIcon private static boolean setupIcons(RenderBlocks renderBlocks, Block blockPane, IIcon origIcon, int x, int y, int z) { skipPaneRendering = skipBottomEdgeRendering = skipTopEdgeRendering = false; - if (!enable) { + if (!MCPatcherForgeConfig.ConnectedTextures.glassPane) { return false; } for (int face = BlockOrientation.NORTH_FACE; face <= BlockOrientation.EAST_FACE; face++) { diff --git a/src/main/java/com/prupe/mcpatcher/ctm/TileOverrideIterator.java b/src/main/java/com/prupe/mcpatcher/ctm/TileOverrideIterator.java index 54d15c64b..f949b7721 100644 --- a/src/main/java/com/prupe/mcpatcher/ctm/TileOverrideIterator.java +++ b/src/main/java/com/prupe/mcpatcher/ctm/TileOverrideIterator.java @@ -15,8 +15,6 @@ abstract public class TileOverrideIterator implements Iterator { - private static final int MAX_RECURSION = MCPatcherForgeConfig.ConnectedTextures.maxRecursion; - private final Map> allBlockOverrides; private final Map> allTileOverrides; @@ -118,7 +116,7 @@ public synchronized TileOverride go(RenderBlockState renderBlockState, IIcon ori lastMatchedOverride = null; skipOverrides.clear(); - pass: for (int pass = 0; pass < MAX_RECURSION; pass++) { + pass: for (int pass = 0; pass < MCPatcherForgeConfig.ConnectedTextures.maxRecursion; pass++) { while (hasNext()) { TileOverride override = next(); IIcon newIcon = getTile(override, renderBlockState, origIcon); diff --git a/src/main/java/com/prupe/mcpatcher/mal/block/RenderBlocksUtils.java b/src/main/java/com/prupe/mcpatcher/mal/block/RenderBlocksUtils.java index 012bce479..bd4fd1488 100644 --- a/src/main/java/com/prupe/mcpatcher/mal/block/RenderBlocksUtils.java +++ b/src/main/java/com/prupe/mcpatcher/mal/block/RenderBlocksUtils.java @@ -11,8 +11,6 @@ // Shared by both CTM and Custom Colors. public class RenderBlocksUtils { - public static final boolean enableBetterGrass = MCPatcherForgeConfig.ConnectedTextures.betterGrass; - private static final int COLOR = 0; private static final int NONCOLOR = 1; private static final int COLOR_AND_NONCOLOR = 2; @@ -35,7 +33,7 @@ public static void setupColorMultiplier(Block block, IBlockAccess blockAccess, i colorMultiplierType[5] = COLOR; } else if (block == Blocks.grass) { colorMultiplierType[0] = NONCOLOR; - if (enableBetterGrass) { + if (MCPatcherForgeConfig.ConnectedTextures.betterGrass) { if (isSnowCovered(blockAccess, x, y, z)) { colorMultiplierType[2] = NONCOLOR; colorMultiplierType[3] = NONCOLOR; @@ -135,7 +133,7 @@ private static int getFaceIndex(int face) { public static IIcon getGrassTexture(Block block, IBlockAccess blockAccess, int x, int y, int z, int face, IIcon topIcon) { - if (!enableBetterGrass || face < 2) { + if (!MCPatcherForgeConfig.ConnectedTextures.betterGrass || face < 2) { return null; } boolean isSnow = isSnowCovered(blockAccess, x, y, z); diff --git a/src/main/java/com/prupe/mcpatcher/mal/tile/TileLoader.java b/src/main/java/com/prupe/mcpatcher/mal/tile/TileLoader.java index 135faceb0..03f32eff4 100644 --- a/src/main/java/com/prupe/mcpatcher/mal/tile/TileLoader.java +++ b/src/main/java/com/prupe/mcpatcher/mal/tile/TileLoader.java @@ -31,7 +31,6 @@ public class TileLoader { private static final List loaders = new ArrayList<>(); - private static final boolean debugTextures = MCPatcherForgeConfig.ConnectedTextures.debugTextures; private static final Map specialTextures = new HashMap<>(); private static final TexturePackChangeHandler changeHandler; @@ -220,7 +219,7 @@ public boolean preloadTile(ResourceLocation resource, boolean alternate, String return true; } BufferedImage image = null; - if (!debugTextures) { + if (!MCPatcherForgeConfig.ConnectedTextures.debugTextures) { image = TexturePackAPI.getImage(resource); if (image == null) { subLogger.warning("missing %s", resource); diff --git a/src/main/java/jss/notfine/config/MCPatcherForgeConfig.java b/src/main/java/jss/notfine/config/MCPatcherForgeConfig.java index ad35dc642..cfd2f4132 100644 --- a/src/main/java/jss/notfine/config/MCPatcherForgeConfig.java +++ b/src/main/java/jss/notfine/config/MCPatcherForgeConfig.java @@ -143,27 +143,21 @@ public static class ConnectedTextures { public static LogLevel logging; @Config.DefaultInt(4) - @Config.RequiresMcRestart public static int maxRecursion; @Config.DefaultBoolean(false) - @Config.RequiresMcRestart public static boolean debugTextures; @Config.DefaultBoolean(false) - @Config.RequiresMcRestart public static boolean betterGrass; @Config.DefaultBoolean(true) - @Config.RequiresMcRestart public static boolean standard; @Config.DefaultBoolean(true) - @Config.RequiresMcRestart public static boolean nonStandard; @Config.DefaultBoolean(false) - @Config.RequiresMcRestart public static boolean glassPane; } diff --git a/src/mixin/java/com/gtnewhorizons/angelica/mixins/early/mcpatcherforge/ctm/MixinRenderBlocks.java b/src/mixin/java/com/gtnewhorizons/angelica/mixins/early/mcpatcherforge/ctm/MixinRenderBlocks.java index 9e1a99dcc..37c2ff794 100644 --- a/src/mixin/java/com/gtnewhorizons/angelica/mixins/early/mcpatcherforge/ctm/MixinRenderBlocks.java +++ b/src/mixin/java/com/gtnewhorizons/angelica/mixins/early/mcpatcherforge/ctm/MixinRenderBlocks.java @@ -1,10 +1,5 @@ package com.gtnewhorizons.angelica.mixins.early.mcpatcherforge.ctm; -import static net.minecraftforge.common.util.ForgeDirection.EAST; -import static net.minecraftforge.common.util.ForgeDirection.NORTH; -import static net.minecraftforge.common.util.ForgeDirection.SOUTH; -import static net.minecraftforge.common.util.ForgeDirection.WEST; - import com.llamalad7.mixinextras.sugar.Local; import net.minecraft.block.Block; import net.minecraft.block.BlockAnvil; @@ -16,19 +11,14 @@ import net.minecraft.block.BlockPane; import net.minecraft.block.BlockRailBase; import net.minecraft.block.BlockRedstoneDiode; -import net.minecraft.block.BlockStainedGlassPane; -import net.minecraft.client.renderer.EntityRenderer; import net.minecraft.client.renderer.RenderBlocks; import net.minecraft.client.renderer.Tessellator; import net.minecraft.util.IIcon; import net.minecraft.world.IBlockAccess; import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Overwrite; import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.Redirect; +import org.spongepowered.asm.mixin.injection.*; import com.prupe.mcpatcher.ctm.CTMUtils; import com.prupe.mcpatcher.ctm.GlassPaneRenderer; @@ -65,7 +55,7 @@ public abstract class MixinRenderBlocks { target = "Lnet/minecraft/client/renderer/RenderBlocks;getBlockIconFromSideAndMetadata(Lnet/minecraft/block/Block;II)Lnet/minecraft/util/IIcon;")) private IIcon modifyRenderBlockMinecartTrack(RenderBlocks instance, Block block, int side, int meta, BlockRailBase specializedBlock, int x, int y, int z) { - return getBlockIcon(block, blockAccess, x, y, z, side); + return CTMUtils.getBlockIcon(getIconSafe(block.getIcon(side, meta)), block, side, meta); } @Redirect( @@ -92,7 +82,7 @@ private IIcon redirectGetBlockIconFromSide(RenderBlocks instance, Block block, i target = "Lnet/minecraft/client/renderer/RenderBlocks;getBlockIconFromSideAndMetadata(Lnet/minecraft/block/Block;II)Lnet/minecraft/util/IIcon;")) private IIcon modifyRenderBlockBrewingStand(RenderBlocks instance, Block block, int side, int meta, BlockBrewingStand specializedBlock, int x, int y, int z) { - return getBlockIcon(block, blockAccess, x, y, z, side); + return CTMUtils.getBlockIcon(getIconSafe(block.getIcon(side, meta)), block, side, meta); } @Redirect( @@ -112,7 +102,7 @@ private IIcon modifyRenderBlockFlowerpot(RenderBlocks instance, Block block, int target = "Lnet/minecraft/client/renderer/RenderBlocks;getBlockIconFromSideAndMetadata(Lnet/minecraft/block/Block;II)Lnet/minecraft/util/IIcon;")) private IIcon modifyRenderBlockAnvilRotate(RenderBlocks instance, Block block, int side, int meta, BlockAnvil specializedBlock, int x, int y, int z) { - return getBlockIcon(block, blockAccess, x, y, z, side); + return CTMUtils.getBlockIcon(getIconSafe(block.getIcon(side, meta)), block, side, meta); } @Redirect( @@ -122,14 +112,13 @@ private IIcon modifyRenderBlockAnvilRotate(RenderBlocks instance, Block block, i target = "Lnet/minecraft/client/renderer/RenderBlocks;getBlockIconFromSideAndMetadata(Lnet/minecraft/block/Block;II)Lnet/minecraft/util/IIcon;")) private IIcon modifyRenderRedstoneDiodeMetadata(RenderBlocks instance, Block block, int side, int meta, BlockRedstoneDiode specializedBlock, int x, int y, int z) { - return getBlockIcon(block, blockAccess, x, y, z, side); + return CTMUtils.getBlockIcon(getIconSafe(block.getIcon(side, meta)), block, side, meta); } @Redirect(method = "renderBlockPane", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/RenderBlocks;getBlockIconFromSideAndMetadata(Lnet/minecraft/block/Block;II)Lnet/minecraft/util/IIcon;")) - private IIcon tweakPaneIcons(RenderBlocks instance, Block block, int side, int meta_unused, - @Local(name = "p_147767_2_") int x, @Local(name = "p_147767_3_") int y, @Local(name = "p_147767_4_") int z) { - return this.getBlockIcon(block, this.blockAccess, x, y, z, side); + private IIcon tweakPaneIcons(RenderBlocks instance, Block block, int side, int meta) { + return CTMUtils.getBlockIcon(getIconSafe(block.getIcon(side, meta)), block, side, meta); } /** @@ -497,9 +486,8 @@ private void tweakPaneRenderer(BlockPane block, int x, int y, int z, CallbackInf } @Redirect(method = "renderBlockStainedGlassPane", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/RenderBlocks;getBlockIconFromSideAndMetadata(Lnet/minecraft/block/Block;II)Lnet/minecraft/util/IIcon;")) - private IIcon tweakStainedPaneIcons(RenderBlocks instance, Block block, int side, int meta_unused, - @Local(name = "p_147733_2_") int x, @Local(name = "p_147733_3_") int y, @Local(name = "p_147733_4_") int z) { - return this.getBlockIcon(block, this.blockAccess, x, y, z, side); + private IIcon tweakStainedPaneIcons(RenderBlocks instance, Block block, int side, int meta) { + return CTMUtils.getBlockIcon(getIconSafe(block.getIcon(side, meta)), block, side, meta); } /** @@ -845,7 +833,7 @@ private void tweakStainedPaneRenderer(Block block, int x, int y, int z, Callback target = "Lnet/minecraft/client/renderer/RenderBlocks;getBlockIconFromSideAndMetadata(Lnet/minecraft/block/Block;II)Lnet/minecraft/util/IIcon;")) private IIcon redirectGetBlockIconFromSideAndMetadata(RenderBlocks instance, Block block, int side, int meta, Block specializedBlock, int x, int y, int z) { - return getBlockIcon(block, blockAccess, x, y, z, side); + return CTMUtils.getBlockIcon(getIconSafe(block.getIcon(side, meta)), block, side, meta); } @Redirect( @@ -865,6 +853,44 @@ private IIcon modifyRenderBlockDoublePlant(BlockDoublePlant block, boolean top, -1); } + @Inject( + method = "renderStandardBlockWithColorMultiplier", + at = { + @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/RenderBlocks;renderFaceZNeg(Lnet/minecraft/block/Block;DDDLnet/minecraft/util/IIcon;)V", ordinal = 0), + @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/RenderBlocks;renderFaceZPos(Lnet/minecraft/block/Block;DDDLnet/minecraft/util/IIcon;)V", ordinal = 0), + } + ) + private void fixBetterGrassColorMultiplierZ(Block block, int x, int y, int z, float red, float green, float blue, + CallbackInfoReturnable cir, + @Local(name = "tessellator") Tessellator tessellator, + @Local(name = "iicon") IIcon iicon, + @Local(name = "f11") float r, + @Local(name = "f14") float g, + @Local(name = "f17") float b) { + if (iicon.getIconName().equals("grass_top")) { + tessellator.setColorOpaque_F(r * red, g * green, b * blue); + } + } + + @Inject( + method = "renderStandardBlockWithColorMultiplier", + at = { + @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/RenderBlocks;renderFaceXNeg(Lnet/minecraft/block/Block;DDDLnet/minecraft/util/IIcon;)V", ordinal = 0), + @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/RenderBlocks;renderFaceXPos(Lnet/minecraft/block/Block;DDDLnet/minecraft/util/IIcon;)V", ordinal = 0), + } + ) + private void fixBetterGrassColorMultiplierX(Block block, int x, int y, int z, float red, float green, float blue, + CallbackInfoReturnable cir, + @Local(name = "tessellator") Tessellator tessellator, + @Local(name = "iicon") IIcon iicon, + @Local(name = "f12") float r, + @Local(name = "f15") float g, + @Local(name = "f18") float b) { + if (iicon.getIconName().equals("grass_top")) { + tessellator.setColorOpaque_F(r * red, g * green, b * blue); + } + } + @Redirect( method = { "renderStandardBlockWithColorMultiplier(Lnet/minecraft/block/Block;IIIFFF)Z", "renderStandardBlockWithAmbientOcclusionPartial(Lnet/minecraft/block/Block;IIIFFF)Z", @@ -948,7 +974,7 @@ private IIcon redirectGrassSideOverLay4(Block block, int x, int y, int z, float target = "Lnet/minecraft/client/renderer/RenderBlocks;getBlockIconFromSideAndMetadata(Lnet/minecraft/block/Block;II)Lnet/minecraft/util/IIcon;")) private IIcon modifyRenderBlockHopperMetadata(RenderBlocks instance, Block block, int side, int meta, BlockHopper specializedBlock, int x, int y, int z) { - return getBlockIcon(block, blockAccess, x, y, z, side); + return CTMUtils.getBlockIcon(getIconSafe(block.getIcon(side, meta)), block, side, meta); } @Redirect( @@ -999,7 +1025,7 @@ private IIcon modifyGetBlockIconFromSide(RenderBlocks instance, IIcon texture, B ordinal = 1)) private IIcon mcpatcherforge$redirectToGetBlockIcon(RenderBlocks instance, Block block, int side, int meta, Block specializedBlock, int x, int y, int z) { - return getBlockIcon(block, blockAccess, x, y, z, side); + return CTMUtils.getBlockIcon(getIconSafe(block.getIcon(side, meta)), block, side, meta); } @Redirect( From 5c4479df14f042f1e276e6944f07bd55a3feb36f Mon Sep 17 00:00:00 2001 From: kurrycat Date: Thu, 21 Nov 2024 22:50:44 +0100 Subject: [PATCH 3/4] fix mcpatcher logger printing with stack info prefix --- src/main/java/com/prupe/mcpatcher/MCLogger.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/prupe/mcpatcher/MCLogger.java b/src/main/java/com/prupe/mcpatcher/MCLogger.java index 7d06b90ac..8d93c9c3d 100644 --- a/src/main/java/com/prupe/mcpatcher/MCLogger.java +++ b/src/main/java/com/prupe/mcpatcher/MCLogger.java @@ -8,6 +8,8 @@ public class MCLogger { + private static final org.apache.logging.log4j.Logger MAIN_LOGGER = org.apache.logging.log4j.LogManager.getLogger("MCPatcherForge"); + private static final Map allLoggers = new HashMap<>(); public static final Level ERROR = new ErrorLevel(); @@ -67,14 +69,14 @@ public String format(LogRecord record) { prefix.append("\n"); message = message.substring(1); } - return prefix + "[" + MCLogger.this.logPrefix + "] " + level.toString() + ": " + message; + return prefix + "[" + MCLogger.this.logPrefix + "/" + level.toString() + "]: " + message; } } }; @Override public void publish(LogRecord record) { - System.out.println(formatter.format(record)); + MAIN_LOGGER.info(formatter.format(record)); } @Override From e4322446baafaf910a25e84920ec3e6274d16035 Mon Sep 17 00:00:00 2001 From: kurrycat Date: Fri, 22 Nov 2024 01:51:39 +0100 Subject: [PATCH 4/4] remove star imports --- src/main/java/com/prupe/mcpatcher/MCLogger.java | 6 +++++- .../mixins/early/mcpatcherforge/ctm/MixinRenderBlocks.java | 4 +++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/prupe/mcpatcher/MCLogger.java b/src/main/java/com/prupe/mcpatcher/MCLogger.java index 8d93c9c3d..642a8978a 100644 --- a/src/main/java/com/prupe/mcpatcher/MCLogger.java +++ b/src/main/java/com/prupe/mcpatcher/MCLogger.java @@ -4,7 +4,11 @@ import java.util.HashMap; import java.util.Map; -import java.util.logging.*; +import java.util.logging.Formatter; +import java.util.logging.Handler; +import java.util.logging.Level; +import java.util.logging.LogRecord; +import java.util.logging.Logger; public class MCLogger { diff --git a/src/mixin/java/com/gtnewhorizons/angelica/mixins/early/mcpatcherforge/ctm/MixinRenderBlocks.java b/src/mixin/java/com/gtnewhorizons/angelica/mixins/early/mcpatcherforge/ctm/MixinRenderBlocks.java index 37c2ff794..dc706c866 100644 --- a/src/mixin/java/com/gtnewhorizons/angelica/mixins/early/mcpatcherforge/ctm/MixinRenderBlocks.java +++ b/src/mixin/java/com/gtnewhorizons/angelica/mixins/early/mcpatcherforge/ctm/MixinRenderBlocks.java @@ -18,7 +18,9 @@ import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.injection.*; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.Redirect; import com.prupe.mcpatcher.ctm.CTMUtils; import com.prupe.mcpatcher.ctm.GlassPaneRenderer;