From 5d7227f5472360ece48f35e6617a141246ff091f Mon Sep 17 00:00:00 2001 From: Sollace Date: Mon, 26 Feb 2024 21:21:44 +0000 Subject: [PATCH] Fixed frozen effect rendering on boats when sodium is installed --- .../spell/effect/ChillingBreathSpell.java | 1 + .../client/render/EntityDisguiseRenderer.java | 10 +++++----- .../client/render/WorldRenderDelegate.java | 20 ++++++++++++++----- .../client/MixinEntityRenderDispatcher.java | 2 +- 4 files changed, 22 insertions(+), 11 deletions(-) diff --git a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/ChillingBreathSpell.java b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/ChillingBreathSpell.java index 18965bd4..90bcfd2d 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/ChillingBreathSpell.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/ChillingBreathSpell.java @@ -30,6 +30,7 @@ public class ChillingBreathSpell extends AbstractSpell implements HomingSpell { public boolean setTarget(Entity target) { if (target instanceof LavaAffine affine) { affine.setLavaAffine(!affine.isLavaAffine()); + setDead(); } return true; } diff --git a/src/main/java/com/minelittlepony/unicopia/client/render/EntityDisguiseRenderer.java b/src/main/java/com/minelittlepony/unicopia/client/render/EntityDisguiseRenderer.java index 1e0aba0c..4d8ecef3 100644 --- a/src/main/java/com/minelittlepony/unicopia/client/render/EntityDisguiseRenderer.java +++ b/src/main/java/com/minelittlepony/unicopia/client/render/EntityDisguiseRenderer.java @@ -34,7 +34,7 @@ class EntityDisguiseRenderer { public boolean render(Living pony, Disguise disguise, double x, double y, double z, - float tickDelta, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light) { + float tickDelta, MatrixStack matrices, VertexConsumerProvider vertices, int light) { int fireTicks = pony.asEntity().doesRenderOnFire() ? 1 : 0; disguise.update(pony, false); @@ -51,20 +51,20 @@ class EntityDisguiseRenderer { e.setBoundingBox(pony.asEntity().getBoundingBox()); } - render(ve, e, x, y, z, fireTicks, tickDelta, matrices, vertexConsumers, light); + render(ve, e, x, y, z, fireTicks, tickDelta, matrices, vertices, light); ve.getAttachments().forEach(ee -> { PehkUtil.copyScale(pony.asEntity(), ee); Vec3d difference = ee.getPos().subtract(e.getPos()); - render(ve, ee, x + difference.x, y + difference.y, z + difference.z, fireTicks, tickDelta, matrices, vertexConsumers, light); + render(ve, ee, x + difference.x, y + difference.y, z + difference.z, fireTicks, tickDelta, matrices, vertices, light); PehkUtil.clearScale(ee); }); matrices.push(); matrices.translate(x, y, z); - SpellEffectsRenderDispatcher.INSTANCE.render(matrices, vertexConsumers, light, pony, 0, 0, tickDelta, pony.asEntity().age + tickDelta, 0, 0); + SpellEffectsRenderDispatcher.INSTANCE.render(matrices, vertices, light, pony, 0, 0, tickDelta, pony.asEntity().age + tickDelta, 0, 0); matrices.pop(); - delegate.afterEntityRender(pony, matrices, light); + delegate.afterEntityRender(pony, matrices, vertices, light); PehkUtil.clearScale(e); return true; } diff --git a/src/main/java/com/minelittlepony/unicopia/client/render/WorldRenderDelegate.java b/src/main/java/com/minelittlepony/unicopia/client/render/WorldRenderDelegate.java index 70a7c975..2d813635 100644 --- a/src/main/java/com/minelittlepony/unicopia/client/render/WorldRenderDelegate.java +++ b/src/main/java/com/minelittlepony/unicopia/client/render/WorldRenderDelegate.java @@ -31,6 +31,7 @@ import net.minecraft.util.math.*; public class WorldRenderDelegate { public static final WorldRenderDelegate INSTANCE = new WorldRenderDelegate(); private static final Optional RED_SKY_COLOR = Optional.of(new Vec3d(1, 0, 0)); + private static final Identifier SHADOW_TEXTURE = new Identifier("textures/misc/shadow.png"); private final EntityReplacementManager disguiseLookup = new EntityReplacementManager(); private final EntityDisguiseRenderer disguiseRenderer = new EntityDisguiseRenderer(this); @@ -71,13 +72,23 @@ public class WorldRenderDelegate { if (MinecraftClient.getInstance().getResourceManager().getResource(frostingTexture).isPresent()) { recurseFrosting = true; + + Immediate immediate = MinecraftClient.getInstance().getBufferBuilders().getEffectVertexConsumers(); + client.getEntityRenderDispatcher().render(entity, x, y, z, yaw, tickDelta, matrices, layer -> { - if (RenderLayerUtil.getTexture(layer).orElse(null) == null) { + + Identifier texture = RenderLayerUtil.getTexture(layer).orElse(null); + + if (texture == null || texture.equals(SHADOW_TEXTURE)) { return vertices.getBuffer(layer); } - return VertexConsumers.union(vertices.getBuffer(layer), vertices.getBuffer(RenderLayers.getEntityTranslucent(frostingTexture))); + return VertexConsumers.union( + vertices.getBuffer(layer), + immediate.getBuffer(RenderLayers.getEntityTranslucent(frostingTexture)) + ); }, light); recurseFrosting = false; + immediate.draw(); return true; } } @@ -89,14 +100,13 @@ public class WorldRenderDelegate { return Equine.of(entity).filter(eq -> onEntityRender(eq, x, y, z, yaw, tickDelta, matrices, vertices, light)).isPresent(); } - public void afterEntityRender(Equine pony, MatrixStack matrices, int light) { + public void afterEntityRender(Equine pony, MatrixStack matrices, VertexConsumerProvider vertices, int light) { if (recurseFrosting) { return; } if (pony instanceof Creature creature && smittenEyesRenderer.isSmitten(creature)) { - Immediate immediate = MinecraftClient.getInstance().getBufferBuilders().getEntityVertexConsumers(); - smittenEyesRenderer.render(creature, matrices, immediate, light, 0); + smittenEyesRenderer.render(creature, matrices, vertices, light, 0); } if (pony instanceof Pony p) { diff --git a/src/main/java/com/minelittlepony/unicopia/mixin/client/MixinEntityRenderDispatcher.java b/src/main/java/com/minelittlepony/unicopia/mixin/client/MixinEntityRenderDispatcher.java index b81bb782..2d784220 100644 --- a/src/main/java/com/minelittlepony/unicopia/mixin/client/MixinEntityRenderDispatcher.java +++ b/src/main/java/com/minelittlepony/unicopia/mixin/client/MixinEntityRenderDispatcher.java @@ -27,6 +27,6 @@ abstract class MixinEntityRenderDispatcher { @Inject(method = RENDER, at = @At("RETURN")) private void afterRender(E entity, double x, double y, double z, float yaw, float tickDelta, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, CallbackInfo info) { - Equine.of(entity).ifPresent(eq -> WorldRenderDelegate.INSTANCE.afterEntityRender(eq, matrices, light)); + Equine.of(entity).ifPresent(eq -> WorldRenderDelegate.INSTANCE.afterEntityRender(eq, matrices, vertexConsumers, light)); } }