From 4717c9e458819c03615f4c272391ec0bdd81d514 Mon Sep 17 00:00:00 2001 From: Sollace Date: Thu, 5 Oct 2023 20:42:31 +0100 Subject: [PATCH] Ponies can now lie down by holding crouch and not moving --- .../java/com/minelittlepony/api/model/ModelAttributes.java | 6 ++++++ .../com/minelittlepony/client/model/AbstractPonyModel.java | 5 +++++ .../client/render/LevitatingItemRenderer.java | 1 - 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/minelittlepony/api/model/ModelAttributes.java b/src/main/java/com/minelittlepony/api/model/ModelAttributes.java index c12c18ff..6fa8304d 100644 --- a/src/main/java/com/minelittlepony/api/model/ModelAttributes.java +++ b/src/main/java/com/minelittlepony/api/model/ModelAttributes.java @@ -9,6 +9,7 @@ import java.util.*; import net.minecraft.client.render.entity.model.BipedEntityModel.ArmPose; import net.minecraft.entity.LivingEntity; +import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; import net.minecraft.util.*; import net.minecraft.util.math.MathHelper; @@ -151,6 +152,11 @@ public class ModelAttributes { isSitting = PonyPosture.isSitting(entity); isSleeping = entity.isAlive() && entity.isSleeping();; isLyingDown = isSleeping; + if (entity instanceof PlayerEntity) { + boolean moving = entity.getVelocity().multiply(1, 0, 1).length() == 0 && entity.isSneaking(); + isLyingDown |= getMainInterpolator().interpolate("lyingDown", moving ? 10 : 0, 10) >= 9; + } + isCrouching = !isLyingDown && !isSitting && mode == Mode.THIRD_PERSON && PonyPosture.isCrouching(pony, entity); isFlying = !isLyingDown && mode == Mode.THIRD_PERSON && PonyPosture.isFlying(entity); isGliding = entity.isFallFlying(); diff --git a/src/main/java/com/minelittlepony/client/model/AbstractPonyModel.java b/src/main/java/com/minelittlepony/client/model/AbstractPonyModel.java index 00dabc50..940a9c54 100644 --- a/src/main/java/com/minelittlepony/client/model/AbstractPonyModel.java +++ b/src/main/java/com/minelittlepony/client/model/AbstractPonyModel.java @@ -623,8 +623,11 @@ public abstract class AbstractPonyModel extends ClientPo stack.multiply(RotationAxis.POSITIVE_Y.rotationDegrees(180)); } + boolean crouching = attributes.isCrouching; + if (attributes.isLyingDown && !attributes.isSleeping) { stack.translate(0, 1.35F, 0); + attributes.isCrouching = sneaking; } if (attributes.isHorsey) { @@ -638,5 +641,7 @@ public abstract class AbstractPonyModel extends ClientPo } PonyTransformation.forSize(getSize()).transform(this, part, stack); + + attributes.isCrouching = crouching; } } diff --git a/src/main/java/com/minelittlepony/client/render/LevitatingItemRenderer.java b/src/main/java/com/minelittlepony/client/render/LevitatingItemRenderer.java index a62f000f..d08db471 100644 --- a/src/main/java/com/minelittlepony/client/render/LevitatingItemRenderer.java +++ b/src/main/java/com/minelittlepony/client/render/LevitatingItemRenderer.java @@ -11,7 +11,6 @@ import net.minecraft.client.render.item.ItemRenderer; import net.minecraft.client.render.model.json.ModelTransformationMode; import net.minecraft.client.util.math.MatrixStack; import net.minecraft.entity.LivingEntity; -import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.CrossbowItem; import net.minecraft.item.ItemStack; import net.minecraft.screen.PlayerScreenHandler;