Update some parameter names

This commit is contained in:
Sollace 2023-03-29 21:35:01 +01:00
parent aa933861c4
commit b2fe56334f
7 changed files with 30 additions and 41 deletions

View file

@ -6,17 +6,15 @@ import net.minecraft.client.util.math.MatrixStack;
public interface IPart { public interface IPart {
/** /**
* Sets the model's various rotation angles. * Sets the model's various rotation angles.
* <p>
* See {@link AbstractPonyMode.setRotationAndAngle} for an explanation of the various parameters.
*/ */
default void setRotationAndAngles(ModelAttributes attributes, float move, float swing, float bodySwing, float ticks) { default void setPartAngles(ModelAttributes attributes, float limbAngle, float limbSpeed, float bodySwing, float animationProgress) {
} }
/** /**
* Renders this model component. * Renders this model component.
*/ */
void renderPart(MatrixStack stack, VertexConsumer vertices, int overlayUv, int lightUv, float red, float green, float blue, float alpha, ModelAttributes attributes); void renderPart(MatrixStack stack, VertexConsumer vertices, int overlay, int light, float red, float green, float blue, float alpha, ModelAttributes attributes);
/** /**
* Sets whether this part should be rendered. * Sets whether this part should be rendered.

View file

@ -2,7 +2,6 @@ package com.minelittlepony.client.hdskins;
import com.minelittlepony.api.pony.IPony; import com.minelittlepony.api.pony.IPony;
import com.minelittlepony.api.pony.IPonyData; import com.minelittlepony.api.pony.IPonyData;
import com.minelittlepony.api.pony.meta.Race;
import com.minelittlepony.api.pony.meta.Wearable; import com.minelittlepony.api.pony.meta.Wearable;
import com.minelittlepony.client.MineLittlePony; import com.minelittlepony.client.MineLittlePony;
import com.minelittlepony.client.SkinsProxy; import com.minelittlepony.client.SkinsProxy;

View file

@ -165,7 +165,7 @@ public abstract class AbstractPonyModel<T extends LivingEntity> extends ClientPo
ponySleep(); ponySleep();
} }
parts.forEach(part -> part.setRotationAndAngles(attributes, limbAngle, limbSpeed, wobbleAmount, animationProgress)); parts.forEach(part -> part.setPartAngles(attributes, limbAngle, limbSpeed, wobbleAmount, animationProgress));
} }
public void setHeadRotation(float animationProgress, float yaw, float pitch) { public void setHeadRotation(float animationProgress, float yaw, float pitch) {

View file

@ -18,17 +18,17 @@ public class LionTail implements IPart {
} }
@Override @Override
public void setRotationAndAngles(ModelAttributes attributes, float move, float swing, float bodySwing, float ticks) { public void setPartAngles(ModelAttributes attributes, float limbAngle, float limbSpeed, float bodySwing, float animationProgress) {
bodySwing *= 5; bodySwing *= 5;
float baseSail = 1F; float baseSail = 1F;
float speed = swing > 0.01F ? 6 : 90; float speed = limbSpeed > 0.01F ? 6 : 90;
Interpolator interpolator = attributes.getMainInterpolator(); Interpolator interpolator = attributes.getMainInterpolator();
float straightness = 1.6F * (1 + (float)Math.sin(ticks / speed) / 8F); float straightness = 1.6F * (1 + (float)Math.sin(animationProgress / speed) / 8F);
float twist = (float)Math.sin(Math.PI/2F + 2 * ticks / speed) / 16F; float twist = (float)Math.sin(Math.PI/2F + 2 * animationProgress / speed) / 16F;
float bend = attributes.motionRoll / 80F; float bend = attributes.motionRoll / 80F;
if (attributes.isCrouching) { if (attributes.isCrouching) {
@ -45,11 +45,11 @@ public class LionTail implements IPart {
bend = interpolator.interpolate("kirin_tail_bendiness", bend, 10); bend = interpolator.interpolate("kirin_tail_bendiness", bend, 10);
tail.pitch = baseSail; tail.pitch = baseSail;
tail.pitch += swing / 2; tail.pitch += limbSpeed / 2;
tail.yaw = twist; tail.yaw = twist;
tail.roll = bodySwing * 2; tail.roll = bodySwing * 2;
float sinTickFactor = MathHelper.sin(ticks * 0.067f) * 0.05f; float sinTickFactor = MathHelper.sin(animationProgress * 0.067f) * 0.05f;
tail.pitch += sinTickFactor; tail.pitch += sinTickFactor;
tail.yaw += sinTickFactor; tail.yaw += sinTickFactor;

View file

@ -12,8 +12,8 @@ import com.minelittlepony.client.model.AbstractPonyModel;
import com.minelittlepony.mson.api.*; import com.minelittlepony.mson.api.*;
import com.minelittlepony.util.MathUtil; import com.minelittlepony.util.MathUtil;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.stream.IntStream;
public class PonyTail implements IPart, MsonModel { public class PonyTail implements IPart, MsonModel {
private static final float TAIL_Z = 14; private static final float TAIL_Z = 14;
@ -27,7 +27,7 @@ public class PonyTail implements IPart, MsonModel {
private int tailStop = 0; private int tailStop = 0;
private TailShape shape = TailShape.STRAIGHT; private TailShape shape = TailShape.STRAIGHT;
private final List<Segment> segments = new ArrayList<>(); private List<Segment> segments = List.of();
public PonyTail(ModelPart tree) { public PonyTail(ModelPart tree) {
tail = tree.getChild("tail"); tail = tree.getChild("tail");
@ -36,38 +36,32 @@ public class PonyTail implements IPart, MsonModel {
@Override @Override
public void init(ModelView context) { public void init(ModelView context) {
model = context.getModel(); model = context.getModel();
segments = IntStream.range(0, (int)context.getLocalValue("segments", 4))
int segments = (int)context.getLocalValue("segments", 4); .mapToObj(i -> context.<Segment>findByName("segment_" + i))
.toList();
for (int i = 0; i < segments; i++) {
Segment segment = context.findByName("segment_" + i);
segment.tail = this;
segment.index = i;
this.segments.add(segment);
}
} }
@Override @Override
public void setRotationAndAngles(ModelAttributes attributes, float move, float swing, float bodySwing, float ticks) { public void setPartAngles(ModelAttributes attributes, float limbAngle, float limbSpeed, float bodySwing, float animationProgress) {
boolean rainboom = attributes.isSwimming || attributes.isGoingFast; boolean rainboom = attributes.isSwimming || attributes.isGoingFast;
tail.roll = rainboom ? 0 : MathHelper.cos(move * 0.8F) * 0.2f * swing; tail.roll = rainboom ? 0 : MathHelper.cos(limbAngle * 0.8F) * 0.2f * limbSpeed;
tail.yaw = bodySwing * 5; tail.yaw = bodySwing * 5;
if (model.getAttributes().isCrouching && !rainboom) { if (attributes.isCrouching && !rainboom) {
tail.setPivot(0, 0, TAIL_SNEAKING_Z); tail.setPivot(0, 0, TAIL_SNEAKING_Z);
tail.pitch = -model.body.pitch + 0.1F; tail.pitch = -model.body.pitch + 0.1F;
} else if (model.getAttributes().isSitting) { } else if (attributes.isSitting) {
tail.pivotZ = TAIL_RIDING_Z; tail.pivotZ = TAIL_RIDING_Z;
tail.pivotY = TAIL_RIDING_Y; tail.pivotY = TAIL_RIDING_Y;
tail.pitch = MathHelper.PI / 5; tail.pitch = MathHelper.PI / 5;
} else { } else {
tail.setPivot(0, 0, TAIL_Z); tail.setPivot(0, 0, TAIL_Z);
if (rainboom) { if (rainboom) {
tail.pitch = MathUtil.Angles._90_DEG + MathHelper.sin(move) / 10; tail.pitch = MathUtil.Angles._90_DEG + MathHelper.sin(limbAngle) / 10;
} else { } else {
tail.pitch = swing / 2; tail.pitch = limbSpeed / 2;
swingX(ticks); swingX(animationProgress);
} }
} }
@ -86,8 +80,8 @@ public class PonyTail implements IPart, MsonModel {
@Override @Override
public void setVisible(boolean visible, ModelAttributes attributes) { public void setVisible(boolean visible, ModelAttributes attributes) {
tail.visible = visible; tail.visible = visible;
tailStop = model.getMetadata().getTailLength().ordinal(); tailStop = attributes.metadata.getTailLength().ordinal();
shape = model.getMetadata().getTailShape(); shape = attributes.metadata.getTailShape();
} }
@Override @Override
@ -95,23 +89,21 @@ public class PonyTail implements IPart, MsonModel {
stack.push(); stack.push();
tail.rotate(stack); tail.rotate(stack);
segments.forEach(segment -> segment.render(stack, vertices, overlayUv, lightUv, red, green, blue, alpha)); for (int i = 0; i < segments.size(); i++) {
segments.get(i).render(this, stack, vertices, i, overlayUv, lightUv, red, green, blue, alpha);
}
stack.pop(); stack.pop();
} }
public static class Segment { public static class Segment {
public PonyTail tail;
public int index;
private final ModelPart tree; private final ModelPart tree;
public Segment(ModelPart tree) { public Segment(ModelPart tree) {
this.tree = tree; this.tree = tree;
} }
public void render(MatrixStack stack, VertexConsumer renderContext, int overlayUv, int lightUv, float red, float green, float blue, float alpha) { public void render(PonyTail tail, MatrixStack stack, VertexConsumer renderContext, int index, int overlayUv, int lightUv, float red, float green, float blue, float alpha) {
if (index >= tail.tailStop) { if (index >= tail.tailStop) {
return; return;
} }

View file

@ -53,7 +53,7 @@ public class PonyWings<T extends Model & IPegasus> implements IPart, MsonModel {
} }
@Override @Override
public void setRotationAndAngles(ModelAttributes attributes, float move, float swing, float bodySwing, float ticks) { public void setPartAngles(ModelAttributes attributes, float move, float swing, float bodySwing, float ticks) {
float flap = 0; float flap = 0;
float progress = pegasus.getSwingAmount(); float progress = pegasus.getSwingAmount();

View file

@ -22,8 +22,8 @@ public class SeaponyTail implements IPart, MsonModel {
} }
@Override @Override
public void setRotationAndAngles(ModelAttributes attributes, float move, float swing, float bodySwing, float ticks) { public void setPartAngles(ModelAttributes attributes, float limbAngle, float limbSpeed, float bodySwing, float animationProgress) {
float rotation = attributes.isSleeping ? 0 : MathHelper.sin(ticks * 0.536f) / 4; float rotation = attributes.isSleeping ? 0 : MathHelper.sin(animationProgress * 0.536f) / 4;
tailBase.pitch = MathHelper.HALF_PI + rotation; tailBase.pitch = MathHelper.HALF_PI + rotation;
tailTip.pitch = rotation; tailTip.pitch = rotation;