From 82199b21d47f0e658f4ef4f03cab856116bd042b Mon Sep 17 00:00:00 2001 From: Sollace Date: Sat, 15 Oct 2022 14:04:51 +0200 Subject: [PATCH] Added a visual overlay when boats are frosted --- .../client/render/WorldRenderDelegate.java | 54 ++++++++++++++---- .../client/MixinEntityRenderDispatcher.java | 8 +-- .../textures/entity/boat/frosting.png | Bin 0 -> 2371 bytes .../textures/entity/chest_boat/frosting.png | Bin 0 -> 5858 bytes 4 files changed, 47 insertions(+), 15 deletions(-) create mode 100644 src/main/resources/assets/unicopia/textures/entity/boat/frosting.png create mode 100644 src/main/resources/assets/unicopia/textures/entity/chest_boat/frosting.png 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 96b3997b..0fc17037 100644 --- a/src/main/java/com/minelittlepony/unicopia/client/render/WorldRenderDelegate.java +++ b/src/main/java/com/minelittlepony/unicopia/client/render/WorldRenderDelegate.java @@ -2,6 +2,7 @@ package com.minelittlepony.unicopia.client.render; import org.jetbrains.annotations.Nullable; +import com.minelittlepony.unicopia.Unicopia; import com.minelittlepony.unicopia.ability.magic.Caster; import com.minelittlepony.unicopia.ability.magic.SpellPredicate; import com.minelittlepony.unicopia.entity.Creature; @@ -10,14 +11,14 @@ import com.minelittlepony.unicopia.entity.ItemImpl; import com.minelittlepony.unicopia.entity.Living; import com.minelittlepony.unicopia.entity.behaviour.EntityAppearance; import com.minelittlepony.unicopia.entity.behaviour.FallingBlockBehaviour; +import com.minelittlepony.unicopia.entity.duck.LavaAffine; import com.minelittlepony.unicopia.entity.player.Pony; import net.minecraft.block.BlockState; import net.minecraft.block.entity.BlockEntity; import net.minecraft.client.MinecraftClient; import net.minecraft.client.model.Model; -import net.minecraft.client.render.OverlayTexture; -import net.minecraft.client.render.VertexConsumerProvider; +import net.minecraft.client.render.*; import net.minecraft.client.render.block.entity.BlockEntityRenderer; import net.minecraft.client.render.entity.EntityRenderDispatcher; import net.minecraft.client.render.entity.EntityRenderer; @@ -25,10 +26,11 @@ import net.minecraft.client.render.entity.LivingEntityRenderer; import net.minecraft.client.render.entity.model.BipedEntityModel; import net.minecraft.client.util.math.MatrixStack; import net.minecraft.util.math.Vec3f; -import net.minecraft.entity.Entity; -import net.minecraft.entity.LivingEntity; +import net.minecraft.entity.*; import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.entity.vehicle.BoatEntity; import net.minecraft.state.property.Properties; +import net.minecraft.util.Identifier; import net.minecraft.util.math.Direction; import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.Vec3d; @@ -39,19 +41,47 @@ public class WorldRenderDelegate { private static final PassThroughVertexConsumer.Parameters MINION_OVERLAY = new PassThroughVertexConsumer.Parameters() .color((parent, r, g, b, a) -> parent.color((float)Math.random(), 0.6F, 1, a / 255F)); - private boolean recurse; + private boolean recurseMinion; + private boolean recurseFrosting; + + public boolean beforeEntityRender(EntityRenderDispatcher dispatcher, Entity entity, + double x, double y, double z, float yaw, + float tickDelta, MatrixStack matrices, VertexConsumerProvider vertices, int light) { + + if (!recurseFrosting && entity instanceof BoatEntity && entity instanceof LavaAffine affine && affine.isLavaAffine()) { + Identifier frostingTexture = Unicopia.id("textures/entity/" + EntityType.getId(entity.getType()).getPath() + "/frosting.png"); + + if (MinecraftClient.getInstance().getResourceManager().getResource(frostingTexture).isPresent()) { + recurseFrosting = true; + + dispatcher.render(entity, x, y, z, yaw, tickDelta, matrices, vertices, light); + dispatcher.setRenderShadows(false); + dispatcher.render(entity, x, y, z, yaw, tickDelta, matrices, layer -> { + return vertices.getBuffer(RenderLayers.getEntityTranslucent(frostingTexture)); + }, light); + dispatcher.setRenderShadows(true); + recurseFrosting = false; + return true; + } + } + + if (recurseFrosting) { + return false; + } + + return Equine.of(entity).filter(eq -> onEntityRender(dispatcher, eq, x, y, z, yaw, tickDelta, matrices, vertices, light)).isPresent(); + } public boolean onEntityRender(EntityRenderDispatcher dispatcher, Equine pony, double x, double y, double z, float yaw, float tickDelta, MatrixStack matrices, VertexConsumerProvider vertices, int light) { - if (!recurse && pony instanceof Creature && ((Creature)pony).isMinion()) { - recurse = true; - - dispatcher.render(((Creature)pony).getEntity(), x, y, z, yaw, tickDelta, matrices, layer -> { + if (!recurseMinion && pony instanceof Creature creature && creature.isMinion()) { + recurseMinion = true; + dispatcher.render(creature.getEntity(), x, y, z, yaw, tickDelta, matrices, layer -> { return PassThroughVertexConsumer.of(vertices.getBuffer(layer), MINION_OVERLAY); }, light); - recurse = false; + recurseMinion = false; return true; } @@ -136,6 +166,10 @@ public class WorldRenderDelegate { } public void afterEntityRender(Equine pony, MatrixStack matrices) { + if (recurseFrosting) { + return; + } + if (pony instanceof ItemImpl || pony instanceof Living) { matrices.pop(); 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 fa620ce8..adf12aae 100644 --- a/src/main/java/com/minelittlepony/unicopia/mixin/client/MixinEntityRenderDispatcher.java +++ b/src/main/java/com/minelittlepony/unicopia/mixin/client/MixinEntityRenderDispatcher.java @@ -20,11 +20,9 @@ abstract class MixinEntityRenderDispatcher { @Inject(method = RENDER, at = @At("HEAD"), cancellable = true) private void beforeRender(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 -> { - if (WorldRenderDelegate.INSTANCE.onEntityRender((EntityRenderDispatcher)(Object)this, eq, x, y, z, yaw, tickDelta, matrices, vertexConsumers, light)) { - info.cancel(); - } - }); + if (WorldRenderDelegate.INSTANCE.beforeEntityRender((EntityRenderDispatcher)(Object)this, entity, x, y, z, yaw, tickDelta, matrices, vertexConsumers, light)) { + info.cancel(); + } } @Inject(method = RENDER, at = @At("RETURN")) diff --git a/src/main/resources/assets/unicopia/textures/entity/boat/frosting.png b/src/main/resources/assets/unicopia/textures/entity/boat/frosting.png new file mode 100644 index 0000000000000000000000000000000000000000..06fd033185eb58d2fe366edc63e0963be5becbdb GIT binary patch literal 2371 zcmV-J3B2}+P)O%uK_rySYNDHHfL_q|&h#CV9kj9`HN80asde~i>qDhH#D6VPk4MdnhHnIZ{hHx|T)H9|gHH zeW8lyhUnnnk7e614@?{c@5R1?INy6}Fk}jNtO=V!7YKb&M z${GP8-|tK_`3%EwEAsu0q`#$Mc=;r4n&i1YsC%rBT!ou;rue}^-z$iG9|}XT z(f9;7eCMmU^MOuQR2PeCiur)=`yT^9tJT^op*2rU=^db~5uny=9y$4GWF6sHXHYR8 z@T9d|^wzhxZhn;B0iIPqz@#|oGD#R?HgZwb0j8m}Ilzn{kWC1ssAN-~3VT}p0JB2C z#j=0HZ^Nne15{*`{s?$hM}S_hx6*30+D2+SX@fu;z=nXfA={Exa@F?%0Md^D+>Lzy zZ5ngeIrkrW-rZUd+~t`wUrln(I0$syCgL&gMR8WVd! zjOFEc(sR!H;sXN>QRWGelVBvl^PHR$B&C4poCwGP4w=(r-nPz_rnMilUVjn5zsk1d zB(X^t9so!L>=~d4plm|AY{(r)qPWxq9uas{%o~Ph@CHES`=66M0I*5&{-FsHiAmA| zE)uv861LI!-ppG)38y3`&`SCc_n@-vWxm}3*`MG@f`RxEmx2dPG`fRiL?yPN`1mE|swpy+C%Q*KunRy40w2nuQd@L{5j?zoQ@V;#{ zE*_-=l()+!>AR;TEUe-b(;oqnF#KB57Xa>)`~u`xk`CZpwvHuhG-k=A>6#%g2)Ib{ zf}~}joHcA2NLm7Lc2W2Lhv|D_l`X#j0M0qMBmvSCiF1c#$Y$=6vYGvYqJx9=X?x*DIHP743#qR<@tJP}P zqy)f6CvEddUl-ccMsF zVrk9o@2^Svl;pjUY6l1FVHmz_fL~L(;xY$UP~;n_oi1_*0QrISyq-(b9)P|BsJ{*; zF`Nbf2W%T)yGV=t+>jroY5I`l4N2Dl+>ms=@E984w#(eeeYt?!g&yblND+C(0Bf}N z4`~#=9!1e^tybGD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