diff --git a/src/main/java/com/minelittlepony/api/model/RenderPass.java b/src/main/java/com/minelittlepony/api/model/RenderPass.java new file mode 100644 index 00000000..ca5c1be2 --- /dev/null +++ b/src/main/java/com/minelittlepony/api/model/RenderPass.java @@ -0,0 +1,17 @@ +package com.minelittlepony.api.model; + +public enum RenderPass { + GUI, + WORLD, + HUD; + + private static RenderPass CURRENT = WORLD; + + public static RenderPass getCurrent() { + return CURRENT; + } + + public static void swap(RenderPass pass) { + CURRENT = pass == null ? WORLD : pass; + } +} diff --git a/src/main/java/com/minelittlepony/client/mixin/MixinGameRenderer.java b/src/main/java/com/minelittlepony/client/mixin/MixinGameRenderer.java new file mode 100644 index 00000000..e8b09518 --- /dev/null +++ b/src/main/java/com/minelittlepony/client/mixin/MixinGameRenderer.java @@ -0,0 +1,37 @@ +package com.minelittlepony.client.mixin; + +import net.minecraft.client.render.*; +import net.minecraft.client.util.math.MatrixStack; + +import org.joml.Matrix4f; +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 com.minelittlepony.api.model.RenderPass; + +@Mixin(GameRenderer.class) +abstract class MixinGameRenderer { + @Inject(method = "renderWorld", at = @At("HEAD")) + private void beforeRenderWorld(float tickDelta, long limitTime, MatrixStack matrices, CallbackInfo info) { + RenderPass.swap(RenderPass.WORLD); + } + + @Inject(method = "renderWorld", at = @At("RETURN")) + private void afterRenderWorld(float tickDelta, long limitTime, MatrixStack matrices, CallbackInfo info) { + RenderPass.swap(RenderPass.GUI); + } +} + +@Mixin(value = WorldRenderer.class, priority = 0) +abstract class MixinWorldRenderer { + @Inject(method = "render", at = @At( + value = "INVOKE", + target = "net.minecraft.client.render.VertexConsumerProvider$Immediate.drawCurrentLayer()V", + ordinal = 0 + )) + private void onRender(MatrixStack matrices, float tickDelta, long limitTime, boolean renderBlockOutline, Camera camera, GameRenderer gameRenderer, LightmapTextureManager lightmapTextureManager, Matrix4f positionMatrix, CallbackInfo info) { + RenderPass.swap(RenderPass.HUD); + } +} \ No newline at end of file diff --git a/src/main/java/com/minelittlepony/client/model/AbstractPonyModel.java b/src/main/java/com/minelittlepony/client/model/AbstractPonyModel.java index 1d9c0ff2..5520611e 100644 --- a/src/main/java/com/minelittlepony/client/model/AbstractPonyModel.java +++ b/src/main/java/com/minelittlepony/client/model/AbstractPonyModel.java @@ -105,9 +105,7 @@ public abstract class AbstractPonyModel extends ClientPo PonyModelPrepareCallback.EVENT.invoker().onPonyModelPrepared(entity, this, ModelAttributes.Mode.OTHER); super.setAngles(entity, move, swing, ticks, headYaw, headPitch); - head.pivotY = head.getDefaultTransform().pivotY; - head.pivotX = head.getDefaultTransform().pivotX; - head.pivotZ = head.getDefaultTransform().pivotZ; + head.setPivot(head.getDefaultTransform().pivotX, head.getDefaultTransform().pivotY, head.getDefaultTransform().pivotZ); setModelAngles(entity, move, swing, ticks, headYaw, headPitch); diff --git a/src/main/java/com/minelittlepony/client/render/EquineRenderManager.java b/src/main/java/com/minelittlepony/client/render/EquineRenderManager.java index 597241f6..3c8fc402 100644 --- a/src/main/java/com/minelittlepony/client/render/EquineRenderManager.java +++ b/src/main/java/com/minelittlepony/client/render/EquineRenderManager.java @@ -162,12 +162,7 @@ public class EquineRenderManager { @@ -19,7 +20,7 @@ public interface PonyPosture { } default void apply(T player, IModel model, MatrixStack stack, float yaw, float ticks, int invert) { - if (applies(player)) { + if (RenderPass.getCurrent() == RenderPass.WORLD && applies(player)) { double motionX = player.getX() - player.prevX; double motionY = player.isOnGround() ? 0 : player.getY() - player.prevY; double motionZ = player.getZ() - player.prevZ; diff --git a/src/main/resources/minelp.mixin.json b/src/main/resources/minelp.mixin.json index 38d41c24..edb508ea 100644 --- a/src/main/resources/minelp.mixin.json +++ b/src/main/resources/minelp.mixin.json @@ -15,6 +15,8 @@ "MixinClientPlayerEntity", "MixinPlayerMoveC2SPacket", "MixinPlayerPositionLookS2CPacket", - "MixinVertextConsumers" + "MixinVertextConsumers", + "MixinGameRenderer", + "MixinWorldRenderer" ] }