Make the interpolatorId private

This commit is contained in:
Sollace 2023-03-28 16:11:38 +01:00
parent 232dc27d01
commit d10debe017
5 changed files with 13 additions and 7 deletions

View file

@ -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))

View file

@ -122,7 +122,7 @@ public abstract class AbstractPonyModel<T extends LivingEntity> 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<T extends LivingEntity> 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<T extends LivingEntity> 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

View file

@ -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;

View file

@ -83,7 +83,7 @@ public class PonyWings<T extends Model & IPegasus> 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);

View file

@ -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));