diff --git a/scripts/flyby-scenes/translucency-layers.txt b/scripts/flyby-scenes/translucency-layers.txt new file mode 100644 index 000000000..60b7053b8 --- /dev/null +++ b/scripts/flyby-scenes/translucency-layers.txt @@ -0,0 +1,58 @@ +# Translucency layer scene for a generated superflat (windows-flyby-kit/make_world.py). $x $y $z is the flight start; +# ground-standing level is $y-2. Start facing south (yaw 0), pitch 15. Use with -Dangelica.flyby.weather=RAIN. Torch +# flame and smoke and rain fall in front of a light blue glass wall and a water pool; one torch row stands behind the glass. + +gamerule doMobSpawning false + +# glass wall +setblock $x-1 $y-2 $z+9 stained_glass 3 replace +setblock $x-1 $y-1 $z+9 stained_glass 3 replace +setblock $x-1 $y+0 $z+9 stained_glass 3 replace +setblock $x+0 $y-2 $z+9 stained_glass 3 replace +setblock $x+0 $y-1 $z+9 stained_glass 3 replace +setblock $x+0 $y+0 $z+9 stained_glass 3 replace +setblock $x+1 $y-2 $z+9 stained_glass 3 replace +setblock $x+1 $y-1 $z+9 stained_glass 3 replace +setblock $x+1 $y+0 $z+9 stained_glass 3 replace +setblock $x+2 $y-2 $z+9 stained_glass 3 replace +setblock $x+2 $y-1 $z+9 stained_glass 3 replace +setblock $x+2 $y+0 $z+9 stained_glass 3 replace +setblock $x+3 $y-2 $z+9 stained_glass 3 replace +setblock $x+3 $y-1 $z+9 stained_glass 3 replace +setblock $x+3 $y+0 $z+9 stained_glass 3 replace + +# torches in front of and behind the glass +setblock $x-1 $y-2 $z+7 torch 5 replace +setblock $x-1 $y-2 $z+11 torch 5 replace +setblock $x+0 $y-2 $z+7 torch 5 replace +setblock $x+0 $y-2 $z+11 torch 5 replace +setblock $x+1 $y-2 $z+7 torch 5 replace +setblock $x+1 $y-2 $z+11 torch 5 replace +setblock $x+2 $y-2 $z+7 torch 5 replace +setblock $x+2 $y-2 $z+11 torch 5 replace +setblock $x+3 $y-2 $z+7 torch 5 replace +setblock $x+3 $y-2 $z+11 torch 5 replace + +# water pool with torches in front of it +setblock $x-6 $y-3 $z+7 water 0 replace +setblock $x-6 $y-3 $z+8 water 0 replace +setblock $x-6 $y-3 $z+9 water 0 replace +setblock $x-6 $y-3 $z+10 water 0 replace +setblock $x-5 $y-3 $z+7 water 0 replace +setblock $x-5 $y-3 $z+8 water 0 replace +setblock $x-5 $y-3 $z+9 water 0 replace +setblock $x-5 $y-3 $z+10 water 0 replace +setblock $x-4 $y-3 $z+7 water 0 replace +setblock $x-4 $y-3 $z+8 water 0 replace +setblock $x-4 $y-3 $z+9 water 0 replace +setblock $x-4 $y-3 $z+10 water 0 replace +setblock $x-3 $y-3 $z+7 water 0 replace +setblock $x-3 $y-3 $z+8 water 0 replace +setblock $x-3 $y-3 $z+9 water 0 replace +setblock $x-3 $y-3 $z+10 water 0 replace +setblock $x-2 $y-3 $z+7 water 0 replace +setblock $x-2 $y-3 $z+8 water 0 replace +setblock $x-2 $y-3 $z+9 water 0 replace +setblock $x-2 $y-3 $z+10 water 0 replace +setblock $x-5 $y-2 $z+6 torch 5 replace +setblock $x-3 $y-2 $z+6 torch 5 replace diff --git a/src/mixin/java/com/gtnewhorizons/angelica/mixins/early/angelica/rendering/MixinEntityRenderer_TranslucencyLayers.java b/src/mixin/java/com/gtnewhorizons/angelica/mixins/early/angelica/rendering/MixinEntityRenderer_TranslucencyLayers.java index 04bc827e2..bd1661e45 100644 --- a/src/mixin/java/com/gtnewhorizons/angelica/mixins/early/angelica/rendering/MixinEntityRenderer_TranslucencyLayers.java +++ b/src/mixin/java/com/gtnewhorizons/angelica/mixins/early/angelica/rendering/MixinEntityRenderer_TranslucencyLayers.java @@ -1,6 +1,11 @@ package com.gtnewhorizons.angelica.mixins.early.angelica.rendering; +import com.gtnewhorizons.angelica.experimental.surround.Surround; +import com.gtnewhorizons.angelica.glsm.GLSMDepthStencilAlpha; import com.gtnewhorizons.angelica.rendering.translucency.TranslucencyLayers; +import com.gtnewhorizons.angelica.rendering.translucency.TranslucentLayer; +import net.minecraft.client.Minecraft; +import net.minecraft.client.multiplayer.WorldClient; import net.minecraft.client.renderer.EntityRenderer; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; @@ -19,4 +24,40 @@ public class MixinEntityRenderer_TranslucencyLayers { private void angelica$compositeTranslucencyLayers(float partialTicks, long finishTimeNano, CallbackInfo ci) { TranslucencyLayers.INSTANCE.composite(); } + + @Surround(id = "translucencyParticles", method = "renderWorld(FJ)V", expect = 2, at = { + @At(value = "INVOKE", target = "Lnet/minecraft/client/particle/EffectRenderer;renderLitParticles(Lnet/minecraft/entity/Entity;F)V"), + @At(value = "INVOKE", target = "Lnet/minecraft/client/particle/EffectRenderer;renderParticles(Lnet/minecraft/entity/Entity;F)V") }) + private void angelica$particlesLayer() { + @Surround.Carry boolean layered = TranslucencyLayers.INSTANCE.beginIfActive(TranslucentLayer.PARTICLES); + } + + @Surround.Finally("translucencyParticles") + private void angelica$particlesLayerEnd(@Surround.Carry boolean layered) { + if (layered) TranslucencyLayers.INSTANCE.end(); + } + + @Surround(id = "translucencyWeather", method = "renderWorld(FJ)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/EntityRenderer;renderRainSnow(F)V")) + private void angelica$weatherLayer(@Surround.Local(argsOnly = true) float partialTicks) { + final WorldClient world = Minecraft.getMinecraft().theWorld; + @Surround.Carry boolean layered = (world.getRainStrength(partialTicks) > 0.0F || world.provider.getWeatherRenderer() != null) + && TranslucencyLayers.INSTANCE.beginIfActive(TranslucentLayer.WEATHER); + // Rain writes no depth, which would leave the layer sorting at the opaque depth behind it. + if (layered) GLSMDepthStencilAlpha.glDepthMask(true); + } + + @Surround.Finally("translucencyWeather") + private void angelica$weatherLayerEnd(@Surround.Carry boolean layered) { + if (layered) TranslucencyLayers.INSTANCE.end(); + } + + @Surround(id = "translucencyClouds", method = "renderWorld(FJ)V", at = @At(value = "INVOKE", ordinal = 1, target = "Lnet/minecraft/client/renderer/EntityRenderer;renderCloudsCheck(Lnet/minecraft/client/renderer/RenderGlobal;F)V")) + private void angelica$cloudsLayer() { + @Surround.Carry boolean layered = Minecraft.getMinecraft().gameSettings.shouldRenderClouds() && TranslucencyLayers.INSTANCE.beginIfActive(TranslucentLayer.CLOUDS); + } + + @Surround.Finally("translucencyClouds") + private void angelica$cloudsLayerEnd(@Surround.Carry boolean layered) { + if (layered) TranslucencyLayers.INSTANCE.end(); + } }