From f73f053c062cbfff4e4c84c3b981eda5ec471774 Mon Sep 17 00:00:00 2001 From: Sollace Date: Tue, 25 Aug 2020 19:22:40 +0200 Subject: [PATCH] Implement piglin dancing --- .../client/model/AbstractPonyModel.java | 4 +- .../client/model/entity/PiglinPonyModel.java | 37 ++++++++++++++++--- 2 files changed, 33 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/minelittlepony/client/model/AbstractPonyModel.java b/src/main/java/com/minelittlepony/client/model/AbstractPonyModel.java index cc2aee4c..8396f258 100644 --- a/src/main/java/com/minelittlepony/client/model/AbstractPonyModel.java +++ b/src/main/java/com/minelittlepony/client/model/AbstractPonyModel.java @@ -70,7 +70,7 @@ public abstract class AbstractPonyModel extends ClientPo super.setAngles(entity, move, swing, ticks, headYaw, headPitch); - updateHeadRotation(headYaw, headPitch); + rotateHead(headYaw, headPitch); shakeBody(move, swing, getWobbleAmount(), ticks); rotateLegs(move, swing, ticks, entity); @@ -211,7 +211,7 @@ public abstract class AbstractPonyModel extends ClientPo * @param x New rotation X * @param y New rotation Y */ - private void updateHeadRotation(float headYaw, float headPitch) { + private void rotateHead(float headYaw, float headPitch) { headYaw = attributes.isSleeping ? (Math.abs(attributes.interpolatorId.getMostSignificantBits()) % 2.8F) - 1.9F : headYaw / 57.29578F; headPitch = attributes.isSleeping ? 0.1f : headPitch / 57.29578F; diff --git a/src/main/java/com/minelittlepony/client/model/entity/PiglinPonyModel.java b/src/main/java/com/minelittlepony/client/model/entity/PiglinPonyModel.java index 98e1a336..f09123f1 100644 --- a/src/main/java/com/minelittlepony/client/model/entity/PiglinPonyModel.java +++ b/src/main/java/com/minelittlepony/client/model/entity/PiglinPonyModel.java @@ -49,6 +49,16 @@ public class PiglinPonyModel extends ZomponyModel { public void setAngles(HostileEntity entity, float move, float swing, float ticks, float headYaw, float headPitch) { super.setAngles(entity, move, swing, ticks, headYaw, headPitch); + float progress = ticks * 0.1F + move * 0.5F; + float range = 0.08F + swing * 0.4F; + rightFlap.roll = -0.5235988F - MathHelper.cos(progress * 1.2F) * range; + leftFlap.roll = 0.5235988F + MathHelper.cos(progress) * range; + } + + @Override + protected void rotateLegs(float move, float swing, float ticks, HostileEntity entity) { + super.rotateLegs(move, swing, ticks, entity); + if (activity == PiglinActivity.ADMIRING_ITEM) { leftArm.yaw = 0.5F; leftArm.pitch = -1.9F; @@ -59,15 +69,30 @@ public class PiglinPonyModel extends ZomponyModel { head.yaw = 0; head.roll = MathHelper.sin(ticks / 10) / 3F; + } else if (activity == PiglinActivity.DANCING) { + float speed = ticks / 60; - helmet.copyPositionAndRotation(head); + head.pivotX = MathHelper.sin(speed * 10); + head.pivotY = MathHelper.sin(speed * 40) + 0.4F; + head.pitch += MathHelper.sin(speed * 40) / 4 + 0.4F; + + float bodyBob = MathHelper.sin(speed * 40) * 0.35F; + float legBob = MathHelper.sin(speed * 40) * 0.25F; + + neck.pivotY = bodyBob; + torso.pivotY = bodyBob; + upperTorso.pivotY = bodyBob; + + leftLeg.pitch += legBob; + rightLeg.pitch -= legBob; + + leftArm.roll -= legBob/4; + rightArm.roll += legBob/4; + + rightArm.pitch += legBob - 0.4F; + leftArm.pitch -= legBob + 0.4F; } - - float progress = ticks * 0.1F + move * 0.5F; - float range = 0.08F + swing * 0.4F; - rightFlap.roll = -0.5235988F - MathHelper.cos(progress * 1.2F) * range; - leftFlap.roll = 0.5235988F + MathHelper.cos(progress) * range; } @Override