|
1 | 1 | package org.polyfrost.polyweather.mixin.client; |
2 | 2 |
|
3 | | -import com.llamalad7.mixinextras.injector.wrapoperation.Operation; |
| 3 | +//? if >=1.21.11 { |
| 4 | +import com.llamalad7.mixinextras.injector.ModifyReturnValue; |
| 5 | +import net.minecraft.world.attribute.WeatherAttributes; |
| 6 | +//?} else { |
| 7 | +/*import com.llamalad7.mixinextras.injector.wrapoperation.Operation; |
4 | 8 | import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; |
5 | 9 | import net.minecraft.client.multiplayer.ClientLevel; |
| 10 | +*///?} |
6 | 11 | import org.polyfrost.polyweather.client.ClientWeatherManager; |
7 | 12 | import org.polyfrost.polyweather.client.PolyWeatherConfig; |
8 | 13 | import org.spongepowered.asm.mixin.Mixin; |
9 | 14 | import org.spongepowered.asm.mixin.injection.At; |
10 | 15 |
|
11 | | -@Mixin(ClientLevel.class) |
12 | | -public class Mixin_FixWorldColors { |
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) { |
15 | | - if (PolyWeatherConfig.isEnabled()) { |
16 | | - return ClientWeatherManager.getPrecipitationStrength(delta); |
17 | | - } |
18 | | - |
19 | | - return original.call(instance, delta); |
| 16 | +//? if >=1.21.11 { |
| 17 | +@Mixin(WeatherAttributes.WeatherAccess.class) |
| 18 | +//?} else { |
| 19 | +/*@Mixin(ClientLevel.class) |
| 20 | +*///?} |
| 21 | +public /*? if >=1.21.11 {*/ interface /*?} else {*//* class *//*?}*/ Mixin_FixWorldColors { |
| 22 | + //? if >=1.21.11 { |
| 23 | + @ModifyReturnValue(method = "from", at = @At("RETURN")) |
| 24 | + private static WeatherAttributes.WeatherAccess modifyWeather(WeatherAttributes.WeatherAccess original) { |
| 25 | + return new WeatherAttributes.WeatherAccess() { |
| 26 | + @Override |
| 27 | + public float rainLevel() { |
| 28 | + if (!PolyWeatherConfig.isEnabled()) return original.rainLevel(); |
| 29 | + return ClientWeatherManager.getPrecipitationStrength(1.0f); |
| 30 | + } |
| 31 | + |
| 32 | + @Override |
| 33 | + public float thunderLevel() { |
| 34 | + if (!PolyWeatherConfig.isEnabled()) return original.thunderLevel(); |
| 35 | + return ClientWeatherManager.getStormStrength(1.0f); |
| 36 | + } |
| 37 | + }; |
20 | 38 | } |
21 | | - |
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) { |
24 | | - if (PolyWeatherConfig.isEnabled()) { |
25 | | - return ClientWeatherManager.getStormStrength(delta); |
26 | | - } |
27 | | - |
28 | | - return original.call(instance, delta); |
29 | | - } |
30 | | - |
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) { |
| 39 | + //?} else { |
| 40 | + /*@WrapOperation(method = {"getSkyColor", "getSkyDarken", "getCloudColor"}, at = @At(value = "INVOKE", target = "Lnet/minecraft/client/multiplayer/ClientLevel;getRainLevel(F)F")) |
| 41 | + private float modifyPrecipitationStrength(ClientLevel instance, float delta, Operation<Float> original) { |
33 | 42 | if (PolyWeatherConfig.isEnabled()) { |
34 | 43 | return ClientWeatherManager.getPrecipitationStrength(delta); |
35 | 44 | } |
36 | 45 |
|
37 | 46 | return original.call(instance, delta); |
38 | 47 | } |
39 | 48 |
|
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) { |
| 49 | + @WrapOperation(method = {"getSkyColor", "getSkyDarken", "getCloudColor"}, at = @At(value = "INVOKE", target = "Lnet/minecraft/client/multiplayer/ClientLevel;getThunderLevel(F)F")) |
| 50 | + private float modifyThunderStrength(ClientLevel instance, float delta, Operation<Float> original) { |
42 | 51 | if (PolyWeatherConfig.isEnabled()) { |
43 | 52 | return ClientWeatherManager.getStormStrength(delta); |
44 | 53 | } |
45 | 54 |
|
46 | 55 | return original.call(instance, delta); |
47 | 56 | } |
| 57 | + *///?} |
48 | 58 | } |
0 commit comments