Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions src/main/java/com/lambda/mixin/render/WeatherRenderingMixin.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
* Copyright 2025 Lambda
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

package com.lambda.mixin.render;

import com.lambda.module.modules.render.Weather;
import net.minecraft.client.render.WeatherRendering;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraft.world.biome.Biome;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;

@Mixin(WeatherRendering.class)
public class WeatherRenderingMixin {
@Inject(method = "getPrecipitationAt", at = @At("HEAD"), cancellable = true)
private void injectGetPrecipitationAt(World world, BlockPos pos, CallbackInfoReturnable<Biome.Precipitation> cir) {
if (Weather.INSTANCE.isEnabled()) {
Weather.WeatherMode mode = Weather.getWeatherMode();
if (world.getRegistryKey() == World.OVERWORLD) {
if (mode == Weather.WeatherMode.Rain && Weather.getOverrideSnow()) cir.setReturnValue(Biome.Precipitation.RAIN);
else if (mode == Weather.WeatherMode.Snow) cir.setReturnValue(Biome.Precipitation.SNOW);
} else {
if (mode == Weather.WeatherMode.Snow) cir.setReturnValue(Biome.Precipitation.SNOW);
else cir.setReturnValue(Biome.Precipitation.RAIN);
}
}
}
}
22 changes: 22 additions & 0 deletions src/main/java/com/lambda/mixin/world/WorldMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,40 @@

import com.lambda.event.EventFlow;
import com.lambda.event.events.WorldEvent;
import com.lambda.module.modules.render.Weather;
import net.minecraft.block.BlockState;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;

@Mixin(World.class)
public abstract class WorldMixin {
@Inject(method = "onBlockStateChanged", at = @At("TAIL"))
void onBlockChanged(BlockPos pos, BlockState oldBlock, BlockState newBlock, CallbackInfo ci) {
EventFlow.post(new WorldEvent.BlockUpdate.Client(pos, oldBlock, newBlock));
}

@Inject(method = "getThunderGradient(F)F", at = @At("HEAD"), cancellable = true)
private void injectGetThunderGradient(float tickProgress, CallbackInfoReturnable<Float> cir) {
if (Weather.INSTANCE.isEnabled()) {
if (Weather.getWeatherMode() == Weather.WeatherMode.Thunder) cir.setReturnValue(1f);
else cir.setReturnValue(0f);
}
}

@Inject(method = "getRainGradient", at = @At("HEAD"), cancellable = true)
private void injectGetRainGradient(float tickProgress, CallbackInfoReturnable<Float> cir) {
if (Weather.INSTANCE.isEnabled()) {
Weather.WeatherMode mode = Weather.getWeatherMode();
if (mode == Weather.WeatherMode.Rain ||
mode == Weather.WeatherMode.Snow ||
mode == Weather.WeatherMode.Thunder
) cir.setReturnValue(1f);
else cir.setReturnValue(0f);
}
}
}
58 changes: 58 additions & 0 deletions src/main/kotlin/com/lambda/module/modules/render/Weather.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/*
* Copyright 2025 Lambda
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

package com.lambda.module.modules.render

import com.lambda.module.Module
import com.lambda.module.tag.ModuleTag
import com.lambda.threading.runSafe
import com.lambda.util.NamedEnum
import net.minecraft.world.World

object Weather : Module(
name = "Weather",
description = "Modifies the client side weather",
tag = ModuleTag.RENDER
) {
private enum class Group(override val displayName: String) : NamedEnum {
Overworld("Overworld"),
Nether("Nether"),
End("End")
}

@JvmStatic val overworldMode by setting("Overworld Mode", WeatherMode.Clear).group(Group.Overworld)
@JvmStatic val overrideSnow by setting("Override Snow", false) { overworldMode == WeatherMode.Rain }.group(Group.Overworld)
@JvmStatic val netherMode by setting("Nether Mode", WeatherMode.Clear).group(Group.Nether)
@JvmStatic val endMode by setting("End Mode", WeatherMode.Clear).group(Group.End)

@JvmStatic fun getWeatherMode() =
runSafe {
val dimension = world.registryKey
when (dimension) {
World.OVERWORLD -> overworldMode
World.NETHER -> netherMode
else -> endMode
}
} ?: WeatherMode.Clear

enum class WeatherMode {
Clear,
Rain,
Thunder,
Snow
}
}
1 change: 1 addition & 0 deletions src/main/resources/lambda.mixins.common.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
"render.SplashOverlayMixin",
"render.SplashOverlayMixin$LogoTextureMixin",
"render.TooltipComponentMixin",
"render.WeatherRenderingMixin",
"render.WorldBorderRenderingMixin",
"render.WorldRendererMixin",
"world.BlockCollisionSpliteratorMixin",
Expand Down