Skip to content

Commit

Permalink
Merge pull request #1 from SimplyRin/1.20.1
Browse files Browse the repository at this point in the history
Update to 1.20.1
  • Loading branch information
Lucaslah authored Jun 26, 2023
2 parents 32413ca + d502932 commit 7fe6efb
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 36 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
10 changes: 5 additions & 5 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
62 changes: 33 additions & 29 deletions src/main/java/me/lucaslah/weatherchanger/mixin/WorldMixin.java
Original file line number Diff line number Diff line change
@@ -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<World> registryRef, RegistryEntry<DimensionType> dimension, Supplier<Profiler> 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<Float> 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<Float> 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);
}

}
2 changes: 1 addition & 1 deletion src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"depends": {
"fabricloader": ">=0.14.6",
"fabric-api": "*",
"minecraft": ">=1.19.3",
"minecraft": ">=1.20.0",
"java": ">=17"
}
}

0 comments on commit 7fe6efb

Please sign in to comment.