Fixed: Dual weilding causes ponies to break the laws of physics

This commit is contained in:
Sollace 2019-07-06 18:29:28 +02:00
parent 53b2d0f370
commit 3cc128ef2f
3 changed files with 36 additions and 20 deletions

View file

@ -81,7 +81,10 @@ public abstract class AbstractPonyModel<T extends LivingEntity> extends ClientPo
rightLeg.rotationPointY = FRONT_LEG_RP_Y_NOTSNEAK;
leftLeg.rotationPointY = FRONT_LEG_RP_Y_NOTSNEAK;
if (!attributes.isSleeping) {
animateBreathing(ticks);
}
if (attributes.isSwimming) {
head.setRotationPoint(0, -2, -2);
@ -388,16 +391,24 @@ public abstract class AbstractPonyModel<T extends LivingEntity> extends ClientPo
protected void alignArmForAction(Cuboid arm, ArmPose pose, ArmPose complement, boolean both, float swing, float reflect) {
switch (pose) {
case ITEM:
arm.yaw = 0;
if ((!both || reflect == (attributes.isLeftHanded ? 1 : -1)) && complement != ArmPose.BLOCK) {
float swag = 1;
if (!isFlying() && both) {
swag -= (float)Math.pow(swing, 2);
}
float mult = 1 - swag/2;
arm.pitch = arm.pitch * mult - (PI / 10) * swag;
arm.roll = -reflect * (PI / 15);
if (attributes.isCrouching) {
arm.rotationPointX -= reflect * 2;
}
}
break;
case EMPTY:
arm.yaw = 0;
break;
@ -482,19 +493,22 @@ public abstract class AbstractPonyModel<T extends LivingEntity> extends ClientPo
* Used in animations together with {@code swing} and {@code move}.
*/
protected void animateBreathing(float ticks) {
if (attributes.isSleeping) {
return;
}
float cos = MathHelper.cos(ticks * 0.09F) * 0.05F + 0.05F;
float sin = MathHelper.sin(ticks * 0.067F) * 0.05F;
if (rightArmPose != ArmPose.EMPTY) {
boolean animateLeft =
(leftArmPose != ArmPose.EMPTY && (leftArmPose != rightArmPose || attributes.isLeftHanded))
&& rightArmPose != ArmPose.BLOCK;
boolean animateRight =
(rightArmPose != ArmPose.EMPTY && (leftArmPose != rightArmPose || !attributes.isLeftHanded))
&& leftArmPose != ArmPose.BLOCK;
if (animateRight) {
rightArm.roll += cos;
rightArm.pitch += sin;
}
if (leftArmPose != ArmPose.EMPTY) {
if (animateLeft) {
leftArm.roll += cos;
leftArm.pitch += sin;
}

View file

@ -90,10 +90,6 @@ public class ModelUnicorn<T extends LivingEntity> extends ModelEarthPony<T> impl
@Override
protected void animateBreathing(float ticks) {
if (attributes.isSleeping) {
return;
}
if (canCast()) {
float cos = MathHelper.cos(ticks * 0.09F) * 0.05F + 0.05F;
float sin = MathHelper.sin(ticks * 0.067F) * 0.05F;

View file

@ -3,6 +3,7 @@ package com.minelittlepony.model;
import com.minelittlepony.pony.IPony;
import com.minelittlepony.util.math.MathUtil;
import net.minecraft.entity.LivingEntity;
import net.minecraft.util.AbsoluteHand;
import net.minecraft.util.math.Vec3d;
import java.util.UUID;
@ -30,6 +31,10 @@ public class ModelAttributes<T extends LivingEntity> {
* True if the pony is crouching.
*/
public boolean isCrouching;
/**
* True if the entity is left-handed.
*/
public boolean isLeftHanded;
/**
* True if the model is sitting as in boats.
*/
@ -94,5 +99,6 @@ public class ModelAttributes<T extends LivingEntity> {
hasHeadGear = pony.isWearingHeadgear(entity);
isSitting = pony.isRidingInteractive(entity);
interpolatorId = entity.getUuid();
isLeftHanded = entity.getMainHand() == AbsoluteHand.LEFT;
}
}