Repository: MinecraftForge/MinecraftForge (language: java)

Issue:
Low-res texture packs are horribly broken. 
**Minecraft Version:** 1.20.1

**Forge Version:** 47.3.7, 47.3.11

**Logs:** N/A

**Steps to Reproduce:**
 1. Open Minecraft
 2. Enable a resource pack with a resolution less than 16x
 3. Raise render distance to 32
 4. Look at blocks in the distance. 

**Description of issue:** Blocks in very far away chunks will appear to be the entirely wrong color (ex. sand can be purple instead of yellow) and water may or may not stop rendering at those distances. Confirmed to happen without any mods, and with the experimental rendering pipeline enabled or disabled, on a freshly installed instance of Forge with either of these resource packs: F8thful or Pollachius. 
![image](https://github.com/user-attachments/assets/6597c8a2-d007-4747-b32a-d58af7721a16)
![image](https://github.com/user-attachments/assets/3892cbd6-2e44-4a01-b814-56e04804efeb)



Discussion / hints:
I suspect the issue is related to fog, as it becomes more noticeable with mods that render fog closer. 
Link/Include a reproduction texture pack so we can verify.
https://www.curseforge.com/minecraft/texture-packs/f8thful
it's caused by https://github.com/MinecraftForge/MinecraftForge/pull/8622, fyi
I know, it needs a config option to toggle this feature.
Just havent gotten around to doing it.
I *would* like to do a proper audit of popular modpacks to see if this feature is even needed anymore as it was originally done to fix things like pipes which didnt use standard sized textures. Which I dont think is a thing anymore. So the patch could just be killed.

Fix patch:
diff --git a/patches/minecraft/net/minecraft/client/renderer/texture/SpriteLoader.java.patch b/patches/minecraft/net/minecraft/client/renderer/texture/SpriteLoader.java.patch
index 4575645387a..743739e90ab 100644
--- a/patches/minecraft/net/minecraft/client/renderer/texture/SpriteLoader.java.patch
+++ b/patches/minecraft/net/minecraft/client/renderer/texture/SpriteLoader.java.patch
@@ -5,7 +5,7 @@
          int k1 = Mth.log2(j1);
          int l1;
 -        if (k1 < p_261919_) {
-+        if (false) { // Forge: Do not lower the mipmap level
++        if (k1 < p_261919_ && net.minecraftforge.common.ForgeConfig.CLIENT.allowMipmapLowering()) { // Forge: Do not lower the mipmap level
              LOGGER.warn("{}: dropping miplevel from {} to {}, because of minimum power of two: {}", this.location, p_261919_, k1, j1);
              l1 = k1;
          } else {
diff --git a/src/main/java/net/minecraftforge/common/ForgeConfig.java b/src/main/java/net/minecraftforge/common/ForgeConfig.java
index 8c8ab4a2a96..ba885cb1816 100644
--- a/src/main/java/net/minecraftforge/common/ForgeConfig.java
+++ b/src/main/java/net/minecraftforge/common/ForgeConfig.java
@@ -98,6 +98,8 @@ public static class Client {
 
         public final BooleanValue showLoadWarnings;
 
+        public final BooleanValue allowMipmapLowering;
+
         Client(ForgeConfigSpec.Builder builder) {
             builder.comment("Client only settings, mostly things related to rendering")
                    .push("client");
@@ -112,6 +114,11 @@ public static class Client {
                 .translation("forge.configgui.showLoadWarnings")
                 .define("showLoadWarnings", true);
 
+            allowMipmapLowering = builder
+                .comment("When enabled, Forge will allow mipmaps to be lowered in real-time. This is the default behavior in vanilla. Use this if you experience issues with resource packs that use textures lower than 8x8.")
+                .translation("forge.configgui.allowMipmapLowering")
+                .define("allowMipmapLowering", false);
+
             builder.pop();
         }
 
@@ -120,6 +127,10 @@ public static class Client {
         public final boolean showLoadWarnings() {
             return clientSpec.isLoaded() ? showLoadWarnings.get() : showLoadWarnings.getDefault();
         }
+
+        public final boolean allowMipmapLowering() {
+            return clientSpec.isLoaded() ? allowMipmapLowering.get() : allowMipmapLowering.getDefault();
+        }
     }
 
     static final ForgeConfigSpec clientSpec;
diff --git a/src/main/resources/assets/forge/lang/en_us.json b/src/main/resources/assets/forge/lang/en_us.json
index 2f52ab36f82..0bb4175ac6c 100644
--- a/src/main/resources/assets/forge/lang/en_us.json
+++ b/src/main/resources/assets/forge/lang/en_us.json
@@ -185,6 +185,8 @@
   "forge.configgui.selectiveResourceReloadEnabled": "Enable Selective Resource Loading",
   "forge.configgui.showLoadWarnings.tooltip": "When enabled, Forge will show any warnings that occurred during loading.",
   "forge.configgui.showLoadWarnings": "Show Load Warnings",
+  "forge.configgui.allowMipmapLowering.tooltip": "When enabled, Forge will allow mipmaps to be lowered in real-time. This is the default behavior in vanilla. Use this if you experience issues with resource packs that use textures lower than 8x8.",
+  "forge.configgui.allowMipmapLowering": "Allow mipmap lowering",
 
   "forge.configgui.disableVersionCheck.tooltip": "Set to true to disable Forge version check mechanics. Forge queries a small json file on our server for version information. For more details see the ForgeVersion class in our github.",
   "forge.configgui.disableVersionCheck": "Disable Forge Version Check",


Test patch: