Skip to content

Commit

Permalink
Add weather.enabled field
Browse files Browse the repository at this point in the history
`weather.enabled = <disable weather geometry> <disable splash particles>`
  • Loading branch information
IMS212 committed Nov 3, 2024
1 parent f9c974b commit 6a7223b
Show file tree
Hide file tree
Showing 6 changed files with 77 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
package net.irisshaders.iris.mixin.sky;

import com.llamalad7.mixinextras.injector.v2.WrapWithCondition;
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
import com.mojang.blaze3d.vertex.MeshData;
import com.mojang.blaze3d.vertex.VertexBuffer;
import net.irisshaders.iris.Iris;
import net.irisshaders.iris.pipeline.WorldRenderingPipeline;
import net.minecraft.client.OptionInstance;
import net.minecraft.client.ParticleStatus;
import net.minecraft.client.multiplayer.ClientLevel;
import net.minecraft.client.renderer.DimensionSpecialEffects;
import net.minecraft.client.renderer.LevelRenderer;
import net.minecraft.client.renderer.LightTexture;
import net.minecraft.client.renderer.ShaderInstance;
import net.minecraft.world.level.LevelHeightAccessor;
import org.joml.Matrix4f;
Expand All @@ -35,6 +39,19 @@ public class MixinLevelRenderer_SunMoonToggle {
}
}

@WrapWithCondition(method = "renderLevel", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/LevelRenderer;renderSnowAndRain(Lnet/minecraft/client/renderer/LightTexture;FDDD)V"))
private boolean iris$disableWeather(LevelRenderer instance, LightTexture lightTexture, float f, double d, double e, double g) {
return Iris.getPipelineManager().getPipeline().map(WorldRenderingPipeline::shouldRenderWeather).orElse(true);
}

@WrapOperation(method = "tickRain", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/OptionInstance;get()Ljava/lang/Object;", ordinal = 1))
private Object disableRainParticles(OptionInstance<?> instance, Operation<ParticleStatus> original) {
if (!Iris.getPipelineManager().getPipeline().map(WorldRenderingPipeline::shouldRenderWeatherParticles).orElse(true)) {
return ParticleStatus.MINIMAL;
}
return original.call(instance);
}

@WrapOperation(method = "renderSky",
at = @At(value = "INVOKE", target = "Lcom/mojang/blaze3d/vertex/BufferUploader;drawWithShader(Lcom/mojang/blaze3d/vertex/MeshData;)V"),
slice = @Slice(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,8 @@ public class IrisRenderingPipeline implements WorldRenderingPipeline, ShaderRend
private final boolean occlusionCulling;
private final CloudSetting cloudSetting;
private final boolean shouldRenderSun;
private final boolean shouldRenderWeather;
private final boolean shouldRenderWeatherParticles;
private final boolean shouldRenderMoon;
private final boolean shouldRenderStars;
private final boolean shouldRenderSkyDisc;
Expand Down Expand Up @@ -204,6 +206,8 @@ public IrisRenderingPipeline(ProgramSet programSet) {
this.cloudSetting = programSet.getPackDirectives().getCloudSetting();
this.dhCloudSetting = programSet.getPackDirectives().getDHCloudSetting();
this.shouldRenderSun = programSet.getPackDirectives().shouldRenderSun();
this.shouldRenderWeather = programSet.getPackDirectives().shouldRenderWeather();
this.shouldRenderWeatherParticles = programSet.getPackDirectives().shouldRenderWeatherParticles();
this.shouldRenderMoon = programSet.getPackDirectives().shouldRenderMoon();
this.shouldRenderStars = programSet.getPackDirectives().shouldRenderStars();
this.shouldRenderSkyDisc = programSet.getPackDirectives().shouldRenderSkyDisc();
Expand Down Expand Up @@ -1101,6 +1105,16 @@ public boolean shouldRenderSun() {
return shouldRenderSun;
}

@Override
public boolean shouldRenderWeather() {
return shouldRenderWeather;
}

@Override
public boolean shouldRenderWeatherParticles() {
return shouldRenderWeatherParticles;
}

@Override
public boolean shouldRenderMoon() {
return shouldRenderMoon;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,16 @@ public boolean shouldRenderSun() {
return true;
}

@Override
public boolean shouldRenderWeather() {
return true;
}

@Override
public boolean shouldRenderWeatherParticles() {
return true;
}

@Override
public boolean shouldRenderMoon() {
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ public interface WorldRenderingPipeline {

boolean shouldRenderSun();

boolean shouldRenderWeather();

boolean shouldRenderWeatherParticles();

boolean shouldRenderMoon();

boolean shouldRenderStars();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ public class PackDirectives {
private boolean underwaterOverlay;
private boolean vignette;
private boolean sun;
private boolean weather;
private boolean weatherParticles;
private boolean moon;
private boolean stars;
private boolean sky;
Expand Down Expand Up @@ -70,6 +72,8 @@ public PackDirectives(Set<Integer> supportedRenderTargets, ShaderProperties prop
underwaterOverlay = properties.getUnderwaterOverlay().orElse(false);
vignette = properties.getVignette().orElse(false);
sun = properties.getSun().orElse(true);
weather = properties.getWeather().orElse(true);
weatherParticles = properties.getWeatherParticles().orElse(true);
moon = properties.getMoon().orElse(true);
stars = properties.getStars().orElse(true);
sky = properties.getSky().orElse(true);
Expand Down Expand Up @@ -160,6 +164,14 @@ public boolean shouldRenderSun() {
return sun;
}

public boolean shouldRenderWeather() {
return weather;
}

public boolean shouldRenderWeatherParticles() {
return weatherParticles;
}

public boolean shouldRenderMoon() {
return moon;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ public class ShaderProperties {
private int customTexAmount;
private CloudSetting cloudSetting = CloudSetting.DEFAULT;
private CloudSetting dhCloudSetting = CloudSetting.DEFAULT;
private OptionalBoolean weather = OptionalBoolean.DEFAULT;
private OptionalBoolean weatherParticles = OptionalBoolean.DEFAULT;
private OptionalBoolean oldHandLight = OptionalBoolean.DEFAULT;
private OptionalBoolean dynamicHandLight = OptionalBoolean.DEFAULT;
private OptionalBoolean supportsColorCorrection = OptionalBoolean.DEFAULT;
Expand Down Expand Up @@ -248,6 +250,16 @@ public ShaderProperties(String contents, ShaderPackOptions shaderPackOptions, It
viewportScaleOverrides.put(pass, new ViewportData(scale, offsetX, offsetY));
});

if ("weather.enabled".equals(key)) {
String[] parts = value.split(" ");

weather = parts[0].equals("true") ? OptionalBoolean.TRUE : OptionalBoolean.FALSE;

if (parts.length > 1) {
weatherParticles = parts[1].equals("true") ? OptionalBoolean.TRUE : OptionalBoolean.FALSE;
}
}

handlePassDirective("size.buffer.", key, value, pass -> {
String[] parts = value.split(" ");

Expand Down Expand Up @@ -775,6 +787,14 @@ public OptionalBoolean getSun() {
return sun;
}

public OptionalBoolean getWeather() {
return weather;
}

public OptionalBoolean getWeatherParticles() {
return weatherParticles;
}

public OptionalBoolean getMoon() {
return moon;
}
Expand Down

0 comments on commit 6a7223b

Please sign in to comment.