Skip to content

Commit 67679d0

Browse files
fix MC-298558 (#441)
* fix MC-298558 * use mixin extras expressions for MC-298558 fix --------- Co-authored-by: MicrocontrollersDev <microcontrollersyt@gmail.com>
1 parent 77c8327 commit 67679d0

5 files changed

Lines changed: 41 additions & 0 deletions

File tree

PATCHED.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
| Basic | [MC-217716](https://bugs.mojang.com/browse/MC-217716) | The green nausea overlay isn't removed when switching into spectator mode |
3232
| Basic | [MC-231097](https://bugs.mojang.com/browse/MC-231097) | Holding the "Use" button continues to slow down the player even after the used item has been dropped |
3333
| Basic | [MC-237493](https://bugs.mojang.com/browse/MC-237493) | Telemetry cannot be disabled |
34+
| Basic | [MC-298558](https://bugs.mojang.com/browse/MC-298558) | Rain fog calculation can overshoot while game is unresponsive |
3435
| Basic | [MC-268420](https://bugs.mojang.com/browse/MC-268420) | Cooldown indicator flashes when switching items with high attack speed attribute |
3536
| Basic | [MC-259512](https://bugs.mojang.com/browse/MC-259512) | Horizontal camera rotation lags when riding |
3637

build.gradle.kts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ loom {
4949
createRemapConfigurations(gametest.get())
5050

5151
accessWidenerPath.set(file("src/main/resources/debugify.accesswidener"))
52+
mixin.useLegacyMixinAp = false
5253
}
5354

5455
repositories {
@@ -77,6 +78,12 @@ dependencies {
7778
modImplementation(fabricApi.module("fabric-resource-loader-v0", fabricApiVersion))
7879
modImplementation("net.fabricmc.fabric-api:fabric-api:$fabricApiVersion")
7980

81+
"io.github.llamalad7:mixinextras-fabric:$mixinExtrasVersion".let {
82+
include(it)
83+
implementation(it)
84+
/*annotationProcessor(it)*/// only needed if `useLegacyMixinAp = true`
85+
}
86+
8087
"modClientImplementation"("dev.isxander:yet-another-config-lib:$yaclVersion") { exclude(module = "fabric-loader") }
8188
"modClientImplementation"("com.terraformersmc:modmenu:$modMenuVersion") { exclude(module = "fabric-loader") }
8289

gradle.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ org.gradle.parallel.threads=4
44

55
minecraftVersion=1.21.7
66
fabricLoaderVersion=0.16.14
7+
mixinExtrasVersion=0.5.0-rc.4
78

89
modrinthId=QwxR6Gcd
910
curseforgeId=596224
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package dev.isxander.debugify.client.mixins.basic.mc298558;
2+
3+
import com.llamalad7.mixinextras.expression.Definition;
4+
import com.llamalad7.mixinextras.expression.Expression;
5+
import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
6+
import com.llamalad7.mixinextras.sugar.Local;
7+
import dev.isxander.debugify.fixes.BugFix;
8+
import dev.isxander.debugify.fixes.FixCategory;
9+
import net.minecraft.client.renderer.fog.environment.AtmosphericFogEnvironment;
10+
import org.spongepowered.asm.mixin.Mixin;
11+
import org.spongepowered.asm.mixin.injection.At;
12+
13+
@BugFix(id = "MC-298558", category = FixCategory.BASIC, env = BugFix.Env.CLIENT, description = "Rain fog calculation can overshoot while game is unresponsive")
14+
@Mixin(AtmosphericFogEnvironment.class)
15+
public class AtmosphericFogEnvironmentMixin {
16+
17+
/**
18+
* The issue stems from the gtDeltaTicks * 0.2, which needs a maximum value of 1.
19+
*/
20+
@Definition(id = "rainFogMultiplier", field = "Lnet/minecraft/client/renderer/fog/environment/AtmosphericFogEnvironment;rainFogMultiplier:F")
21+
@Definition(id = "rainLevel", local = @Local(type = float.class, ordinal = 3))
22+
@Definition(id = "gtDeltaTicks", local = @Local(type = float.class, ordinal = 1))
23+
// `?.` instead of `this.` since the `this` is DUPed making it impossible to target
24+
@Expression("?.rainFogMultiplier = ?.rainFogMultiplier + (rainLevel - ?.rainFogMultiplier) * @(gtDeltaTicks) * 0.2")
25+
@ModifyExpressionValue(method = "setupFog", at = @At("MIXINEXTRAS:EXPRESSION"))
26+
private float clampFog(float original) {
27+
// it's impossible to target `gtDeltaTicks * 0.2` since in bytecode
28+
// it's `...) * gtDeltaTicks) * 0.2`. so instead just modify `gtDeltaTicks` with min 5, since 5 * 0.2 is 1
29+
return Math.min(5f, original);
30+
}
31+
}

src/client/resources/debugify.client.mixins.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
"basic.mc237493.TelemetryEventWidgetMixin",
3232
"basic.mc237493.TelemetryInfoScreenMixin",
3333
"basic.mc263865.KeyboardHandlerMixin",
34+
"basic.mc298558.AtmosphericFogEnvironmentMixin",
3435
"basic.mc268420.GuiMixin",
3536
"basic.mc4490.FishingHookRendererMixin",
3637
"basic.mc46503.ClientPacketListenerMixin",

0 commit comments

Comments
 (0)