From 060c4abfffad3b0d5587b03f4c329c420d79a707 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 +++++ 2 files changed, 11 insertions(+) diff --git a/src/main/java/com/minelittlepony/api/model/ModelAttributes.java b/src/main/java/com/minelittlepony/api/model/ModelAttributes.java index abfdab8f..f314a8cb 100644 --- a/src/main/java/com/minelittlepony/api/model/ModelAttributes.java +++ b/src/main/java/com/minelittlepony/api/model/ModelAttributes.java @@ -10,6 +10,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; @@ -152,6 +153,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 aea6fd80..e8d4d5c3 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; } }