diff --git a/src/main/java/com/minelittlepony/api/model/ModelAttributes.java b/src/main/java/com/minelittlepony/api/model/ModelAttributes.java index d91c3574..3a23165f 100644 --- a/src/main/java/com/minelittlepony/api/model/ModelAttributes.java +++ b/src/main/java/com/minelittlepony/api/model/ModelAttributes.java @@ -1,8 +1,10 @@ package com.minelittlepony.api.model; import com.minelittlepony.api.pony.*; +import com.minelittlepony.client.IPreviewModel; import com.minelittlepony.client.SkinsProxy; import com.minelittlepony.client.pony.PonyData; +import com.minelittlepony.common.util.animation.Interpolator; import com.minelittlepony.util.MathUtil; import java.util.*; @@ -82,7 +84,7 @@ public class ModelAttributes { * Unique id of the interpolator used for this model. * Usually the UUID of the entity being rendered. */ - public UUID interpolatorId = UUID.randomUUID(); + private UUID interpolatorId = UUID.randomUUID(); /** * The actual, visible height of this model when rendered. @@ -150,6 +152,10 @@ public class ModelAttributes { featureSkins = SkinsProxy.instance.getAvailableSkins(entity); } + public Interpolator getMainInterpolator() { + return metadata.getInterpolator(interpolatorId); + } + public boolean shouldLiftArm(ArmPose pose, ArmPose complement, float sigma) { return pose != ArmPose.EMPTY && (pose != complement || sigma == (isLeftHanded ? 1 : -1)) diff --git a/src/main/java/com/minelittlepony/client/model/AbstractPonyModel.java b/src/main/java/com/minelittlepony/client/model/AbstractPonyModel.java index 3a08c300..f258c7d3 100644 --- a/src/main/java/com/minelittlepony/client/model/AbstractPonyModel.java +++ b/src/main/java/com/minelittlepony/client/model/AbstractPonyModel.java @@ -122,7 +122,7 @@ public abstract class AbstractPonyModel extends ClientPo float pitch = (float)Math.toRadians(attributes.motionPitch); head.setAngles( MathHelper.clamp(attributes.isSleeping ? 0.1f : headPitch / 57.29578F, -1.25f - pitch, 0.5f - pitch), - attributes.isSleeping ? (Math.abs(attributes.interpolatorId.getMostSignificantBits()) % 2.8F) - 1.9F : headYaw / 57.29578F, + attributes.isSleeping ? (Math.abs(entity.getUuid().getMostSignificantBits()) % 2.8F) - 1.9F : headYaw / 57.29578F, 0 ); @@ -274,7 +274,7 @@ public abstract class AbstractPonyModel extends ClientPo rightArm.pivotZ = 2 + sin; leftArm.pivotZ = 2 - sin; - float legRPX = getMetadata().getInterpolator(attributes.interpolatorId).interpolate("legOffset", cos - getLegOutset() - 0.001F, 2); + float legRPX = attributes.getMainInterpolator().interpolate("legOffset", cos - getLegOutset() - 0.001F, 2); rightArm.pivotX = -legRPX; rightLeg.pivotX = -legRPX; @@ -319,7 +319,7 @@ public abstract class AbstractPonyModel extends ClientPo float baseRotation = move * 0.6662F; // magic number ahoy float scale = swing / 4; - float rainboomLegLotation = getMetadata().getInterpolator(attributes.interpolatorId).interpolate( + float rainboomLegLotation = attributes.getMainInterpolator().interpolate( "rainboom_leg_rotation", attributes.isGoingFast ? 1 : 0, 5 diff --git a/src/main/java/com/minelittlepony/client/model/part/LionTail.java b/src/main/java/com/minelittlepony/client/model/part/LionTail.java index 10082f75..3c6a2516 100644 --- a/src/main/java/com/minelittlepony/client/model/part/LionTail.java +++ b/src/main/java/com/minelittlepony/client/model/part/LionTail.java @@ -25,7 +25,7 @@ public class LionTail implements IPart { float baseSail = 1F; float speed = swing > 0.01F ? 6 : 90; - Interpolator interpolator = Interpolator.linear(attributes.interpolatorId); + Interpolator interpolator = attributes.getMainInterpolator(); float straightness = 1.6F * (1 + (float)Math.sin(ticks / speed) / 8F); float twist = (float)Math.sin(Math.PI/2F + 2 * ticks / speed) / 16F; diff --git a/src/main/java/com/minelittlepony/client/model/part/PonyWings.java b/src/main/java/com/minelittlepony/client/model/part/PonyWings.java index 880dcad9..488d93a5 100644 --- a/src/main/java/com/minelittlepony/client/model/part/PonyWings.java +++ b/src/main/java/com/minelittlepony/client/model/part/PonyWings.java @@ -83,7 +83,7 @@ public class PonyWings implements IPart, MsonModel { } if (!pegasus.isFlying()) { - flapAngle = pegasus.getMetadata().getInterpolator(attributes.interpolatorId).interpolate("wingFlap", flapAngle, 10); + flapAngle = attributes.getMainInterpolator().interpolate("wingFlap", flapAngle, 10); } getLeft().rotateFlying(flapAngle); diff --git a/src/main/java/com/minelittlepony/client/transform/PostureFlight.java b/src/main/java/com/minelittlepony/client/transform/PostureFlight.java index b019b215..ee1252f7 100644 --- a/src/main/java/com/minelittlepony/client/transform/PostureFlight.java +++ b/src/main/java/com/minelittlepony/client/transform/PostureFlight.java @@ -22,7 +22,7 @@ public class PostureFlight extends MotionCompositor implements PonyPosture { model.getAttributes().motionPitch = (float)calculateIncline(player, motionX, motionY, motionZ); model.getAttributes().motionRoll = (float)calculateRoll(player, motionX * xScale, motionY, motionZ * xScale); - model.getAttributes().motionRoll = model.getMetadata().getInterpolator(model.getAttributes().interpolatorId).interpolate("pegasusRoll", model.getAttributes().motionRoll, 10); + model.getAttributes().motionRoll = model.getAttributes().getMainInterpolator().interpolate("pegasusRoll", model.getAttributes().motionRoll, 10); stack.multiply(RotationAxis.POSITIVE_X.rotationDegrees(model.getAttributes().motionPitch)); stack.multiply(RotationAxis.POSITIVE_Z.rotationDegrees(model.getAttributes().motionRoll));