diff --git a/README.md b/README.md index aac449b..1ef496f 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # Weather Changer Changes the weather on client side -Supports fabric 1.19.3+, forge support is coming soon!\ +Supports fabric 1.20.0+, forge support is coming soon!\ The fabric api is required. ## Links diff --git a/gradle.properties b/gradle.properties index 37f5cae..637f22f 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,15 +3,15 @@ org.gradle.jvmargs=-Xmx1G # Fabric Properties # check these on https://fabricmc.net/develop -minecraft_version=1.19.3 -yarn_mappings=1.19.3+build.1 -loader_version=0.14.11 +minecraft_version=1.20.1 +yarn_mappings=1.20.1+build.8 +loader_version=0.14.21 # Mod Properties -mod_version = 0.2.0 +mod_version = 0.3.0 version = 0.1.0 maven_group = me.lucaslah archives_base_name = weather-changer # Dependencies -fabric_version=0.68.1+1.19.3 +fabric_version=0.84.0+1.20.1 diff --git a/src/main/java/me/lucaslah/weatherchanger/mixin/WorldMixin.java b/src/main/java/me/lucaslah/weatherchanger/mixin/WorldMixin.java index 0dce50a..77f3f88 100644 --- a/src/main/java/me/lucaslah/weatherchanger/mixin/WorldMixin.java +++ b/src/main/java/me/lucaslah/weatherchanger/mixin/WorldMixin.java @@ -1,48 +1,52 @@ package me.lucaslah.weatherchanger.mixin; import me.lucaslah.weatherchanger.WeatherChanger; -import net.minecraft.client.world.ClientWorld; -import net.minecraft.registry.RegistryKey; -import net.minecraft.registry.entry.RegistryEntry; -import net.minecraft.util.profiler.Profiler; -import net.minecraft.world.MutableWorldProperties; +import net.minecraft.util.math.MathHelper; import net.minecraft.world.World; -import net.minecraft.world.dimension.DimensionType; import org.spongepowered.asm.mixin.Mixin; +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.callback.CallbackInfoReturnable; -import java.util.function.Supplier; - -@Mixin(ClientWorld.class) -public abstract class WorldMixin extends World { - protected WorldMixin(MutableWorldProperties properties, RegistryKey registryRef, RegistryEntry dimension, Supplier profiler, boolean isClient, boolean debugWorld, long seed, int maxChainedNeighborUpdates) { - super(properties, registryRef, dimension, profiler, isClient, debugWorld, seed, maxChainedNeighborUpdates); - } +@Mixin(World.class) +public class WorldMixin { private WeatherChanger mod = WeatherChanger.getInstance(); - @Override - public float getRainGradient(float delta) { - if (mod.mode == WeatherChanger.Mode.OFF) { - return super.getRainGradient(delta); - } else if (mod.mode == WeatherChanger.Mode.CLEAR) { - return 0; + @Shadow + protected float rainGradientPrev; + @Shadow + protected float rainGradient; + + @Inject(method = "getRainGradient", at = @At("HEAD"), cancellable = true) + public void changeRainGradient(float delta, CallbackInfoReturnable callback) { + if (mod.mode == WeatherChanger.Mode.CLEAR) { + callback.setReturnValue(0F); } else if (mod.mode == WeatherChanger.Mode.RAIN || mod.mode == WeatherChanger.Mode.THUNDER) { - return 1; + callback.setReturnValue(1F); + } else { + callback.setReturnValue(MathHelper.lerp(delta, this.rainGradientPrev, this.rainGradient)); } - return super.getRainGradient(delta); + callback.cancel(); } - @Override - public float getThunderGradient(float delta) { - if (mod.mode == WeatherChanger.Mode.OFF) { - return super.getRainGradient(delta); - } else if (mod.mode == WeatherChanger.Mode.CLEAR) { - return 0; + @Inject(method = "getThunderGradient", at = @At("HEAD"), cancellable = true) + public void getThunderGradient(float delta, CallbackInfoReturnable callback) { + if (mod.mode == WeatherChanger.Mode.CLEAR) { + callback.setReturnValue(0F); } else if (mod.mode == WeatherChanger.Mode.THUNDER) { - return 1; + callback.setReturnValue(1F); + } else { + callback.setReturnValue(this.getRainGradient(delta)); } - return super.getRainGradient(delta); + callback.cancel(); } + + public float getRainGradient(float delta) { + return MathHelper.lerp(delta, this.rainGradientPrev, this.rainGradient); + } + } diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index 72c0245..1bb9506 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -31,7 +31,7 @@ "depends": { "fabricloader": ">=0.14.6", "fabric-api": "*", - "minecraft": ">=1.19.3", + "minecraft": ">=1.20.0", "java": ">=17" } }