Backport: Dual wielding causes ponies to defy gravity

This commit is contained in:
Sollace 2019-08-12 16:44:35 +02:00
parent 39727d3f9e
commit 46bc422d45

View file

@ -43,6 +43,7 @@ public abstract class AbstractPonyModel extends ModelPlayer implements IModel, P
public boolean isCrouching; public boolean isCrouching;
public boolean isRidingInteractive; public boolean isRidingInteractive;
public boolean headGear; public boolean headGear;
private boolean isLeftHanded;
/** /**
* Associated pony data. * Associated pony data.
@ -101,6 +102,7 @@ public abstract class AbstractPonyModel extends ModelPlayer implements IModel, P
headGear = pony.isWearingHeadgear(entity); headGear = pony.isWearingHeadgear(entity);
isRidingInteractive = pony.isRidingInteractive(entity); isRidingInteractive = pony.isRidingInteractive(entity);
interpolatorId = entity.getUniqueID(); interpolatorId = entity.getUniqueID();
isLeftHanded = entity.getPrimaryHand() == EnumHandSide.LEFT;
} }
/** /**
@ -477,16 +479,24 @@ public abstract class AbstractPonyModel extends ModelPlayer implements IModel, P
protected void alignArmForAction(ModelRenderer arm, ArmPose pose, ArmPose complement, boolean both, float swing, float reflect) { protected void alignArmForAction(ModelRenderer arm, ArmPose pose, ArmPose complement, boolean both, float swing, float reflect) {
switch (pose) { switch (pose) {
case ITEM: case ITEM:
arm.rotateAngleY = 0;
if ((!both || reflect == (isLeftHanded ? 1 : -1)) && complement != ArmPose.BLOCK) {
float swag = 1; float swag = 1;
if (!isFlying() && both) { if (!isFlying() && both) {
swag -= (float)Math.pow(swing, 2); swag -= (float)Math.pow(swing, 2);
} }
float mult = 1 - swag/2; float mult = 1 - swag/2;
arm.rotateAngleX = arm.rotateAngleX * mult - (PI / 10) * swag; arm.rotateAngleX = arm.rotateAngleX * mult - (PI / 10) * swag;
arm.rotateAngleZ = -reflect * (PI / 15); arm.rotateAngleZ = -reflect * (PI / 15);
if (isCrouching()) { if (isCrouching()) {
arm.rotationPointX -= reflect * 2; arm.rotationPointX -= reflect * 2;
} }
}
break;
case EMPTY: case EMPTY:
arm.rotateAngleY = 0; arm.rotateAngleY = 0;
break; break;
@ -564,12 +574,19 @@ public abstract class AbstractPonyModel extends ModelPlayer implements IModel, P
float cos = MathHelper.cos(ticks * 0.09F) * 0.05F + 0.05F; float cos = MathHelper.cos(ticks * 0.09F) * 0.05F + 0.05F;
float sin = MathHelper.sin(ticks * 0.067F) * 0.05F; float sin = MathHelper.sin(ticks * 0.067F) * 0.05F;
if (rightArmPose != ArmPose.EMPTY) { boolean animateLeft =
(leftArmPose != ArmPose.EMPTY && (leftArmPose != rightArmPose || isLeftHanded))
&& rightArmPose != ArmPose.BLOCK;
boolean animateRight =
(rightArmPose != ArmPose.EMPTY && (leftArmPose != rightArmPose || !isLeftHanded))
&& leftArmPose != ArmPose.BLOCK;
if (animateRight) {
bipedRightArm.rotateAngleZ += cos; bipedRightArm.rotateAngleZ += cos;
bipedRightArm.rotateAngleX += sin; bipedRightArm.rotateAngleX += sin;
} }
if (leftArmPose != ArmPose.EMPTY) { if (animateLeft) {
bipedLeftArm.rotateAngleZ += cos; bipedLeftArm.rotateAngleZ += cos;
bipedLeftArm.rotateAngleX += sin; bipedLeftArm.rotateAngleX += sin;
} }