|
1 | 1 | package org.polyfrost.polyweather.mixin.client; |
2 | 2 |
|
| 3 | +import com.llamalad7.mixinextras.injector.wrapoperation.Operation; |
| 4 | +import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; |
3 | 5 | import net.minecraft.client.multiplayer.ClientLevel; |
4 | 6 | import org.polyfrost.polyweather.client.ClientWeatherManager; |
5 | 7 | import org.polyfrost.polyweather.client.PolyWeatherConfig; |
6 | 8 | import org.spongepowered.asm.mixin.Mixin; |
7 | 9 | import org.spongepowered.asm.mixin.injection.At; |
8 | | -import org.spongepowered.asm.mixin.injection.Redirect; |
9 | 10 |
|
10 | 11 | @Mixin(ClientLevel.class) |
11 | 12 | public class Mixin_FixWorldColors { |
12 | | - @Redirect(method = "getSkyColor", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/multiplayer/ClientLevel;getRainLevel(F)F")) |
13 | | - private float fixSkyColors(ClientLevel instance, float delta) { |
| 13 | + @WrapOperation(method = "getSkyColor", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/multiplayer/ClientLevel;getRainLevel(F)F")) |
| 14 | + private float fixSkyColors(ClientLevel instance, float delta, Operation<Float> original) { |
14 | 15 | if (PolyWeatherConfig.isEnabled()) { |
15 | 16 | return ClientWeatherManager.getPrecipitationStrength(delta); |
16 | 17 | } |
17 | 18 |
|
18 | | - return instance.getRainLevel(delta); |
| 19 | + return original.call(instance, delta); |
19 | 20 | } |
20 | 21 |
|
21 | | - @Redirect(method = "getSkyColor", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/multiplayer/ClientLevel;getThunderLevel(F)F")) |
22 | | - private float fixSkyColorsThunder(ClientLevel instance, float delta) { |
| 22 | + @WrapOperation(method = "getSkyColor", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/multiplayer/ClientLevel;getThunderLevel(F)F")) |
| 23 | + private float fixSkyColorsThunder(ClientLevel instance, float delta, Operation<Float> original) { |
23 | 24 | if (PolyWeatherConfig.isEnabled()) { |
24 | 25 | return ClientWeatherManager.getStormStrength(delta); |
25 | 26 | } |
26 | 27 |
|
27 | | - return instance.getThunderLevel(delta); |
| 28 | + return original.call(instance, delta); |
28 | 29 | } |
29 | 30 |
|
30 | | - @Redirect(method = "getCloudColor", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/multiplayer/ClientLevel;getRainLevel(F)F")) |
31 | | - private float fixCloudColors(ClientLevel instance, float delta) { |
| 31 | + @WrapOperation(method = "getCloudColor", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/multiplayer/ClientLevel;getRainLevel(F)F")) |
| 32 | + private float fixCloudColors(ClientLevel instance, float delta, Operation<Float> original) { |
32 | 33 | if (PolyWeatherConfig.isEnabled()) { |
33 | 34 | return ClientWeatherManager.getPrecipitationStrength(delta); |
34 | 35 | } |
35 | 36 |
|
36 | | - return instance.getRainLevel(delta); |
| 37 | + return original.call(instance, delta); |
37 | 38 | } |
38 | 39 |
|
39 | | - @Redirect(method = "getCloudColor", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/multiplayer/ClientLevel;getThunderLevel(F)F")) |
40 | | - private float fixCloudColorsThunder(ClientLevel instance, float delta) { |
| 40 | + @WrapOperation(method = "getCloudColor", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/multiplayer/ClientLevel;getThunderLevel(F)F")) |
| 41 | + private float fixCloudColorsThunder(ClientLevel instance, float delta, Operation<Float> original) { |
41 | 42 | if (PolyWeatherConfig.isEnabled()) { |
42 | 43 | return ClientWeatherManager.getStormStrength(delta); |
43 | 44 | } |
44 | 45 |
|
45 | | - return instance.getThunderLevel(delta); |
| 46 | + return original.call(instance, delta); |
46 | 47 | } |
47 | 48 | } |
0 commit comments