From b2fe56334f71c55d1d0d2290247f8462a97e8592 Mon Sep 17 00:00:00 2001 From: Sollace Date: Wed, 29 Mar 2023 21:35:01 +0100 Subject: [PATCH] Update some parameter names --- .../com/minelittlepony/api/model/IPart.java | 6 +-- .../client/hdskins/MineLPHDSkins.java | 1 - .../client/model/AbstractPonyModel.java | 2 +- .../client/model/part/LionTail.java | 12 ++--- .../client/model/part/PonyTail.java | 44 ++++++++----------- .../client/model/part/PonyWings.java | 2 +- .../client/model/part/SeaponyTail.java | 4 +- 7 files changed, 30 insertions(+), 41 deletions(-) diff --git a/src/main/java/com/minelittlepony/api/model/IPart.java b/src/main/java/com/minelittlepony/api/model/IPart.java index db6a059e..7e2239da 100644 --- a/src/main/java/com/minelittlepony/api/model/IPart.java +++ b/src/main/java/com/minelittlepony/api/model/IPart.java @@ -6,17 +6,15 @@ import net.minecraft.client.util.math.MatrixStack; public interface IPart { /** * Sets the model's various rotation angles. - *

- * 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. */ - 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. diff --git a/src/main/java/com/minelittlepony/client/hdskins/MineLPHDSkins.java b/src/main/java/com/minelittlepony/client/hdskins/MineLPHDSkins.java index 3e21a8b1..c7428a98 100644 --- a/src/main/java/com/minelittlepony/client/hdskins/MineLPHDSkins.java +++ b/src/main/java/com/minelittlepony/client/hdskins/MineLPHDSkins.java @@ -2,7 +2,6 @@ package com.minelittlepony.client.hdskins; import com.minelittlepony.api.pony.IPony; import com.minelittlepony.api.pony.IPonyData; -import com.minelittlepony.api.pony.meta.Race; import com.minelittlepony.api.pony.meta.Wearable; import com.minelittlepony.client.MineLittlePony; import com.minelittlepony.client.SkinsProxy; diff --git a/src/main/java/com/minelittlepony/client/model/AbstractPonyModel.java b/src/main/java/com/minelittlepony/client/model/AbstractPonyModel.java index f258c7d3..7f137d8d 100644 --- a/src/main/java/com/minelittlepony/client/model/AbstractPonyModel.java +++ b/src/main/java/com/minelittlepony/client/model/AbstractPonyModel.java @@ -165,7 +165,7 @@ public abstract class AbstractPonyModel extends ClientPo 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) { 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 3c6a2516..8528f2ef 100644 --- a/src/main/java/com/minelittlepony/client/model/part/LionTail.java +++ b/src/main/java/com/minelittlepony/client/model/part/LionTail.java @@ -18,17 +18,17 @@ public class LionTail implements IPart { } @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; float baseSail = 1F; - float speed = swing > 0.01F ? 6 : 90; + float speed = limbSpeed > 0.01F ? 6 : 90; 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; + float straightness = 1.6F * (1 + (float)Math.sin(animationProgress / speed) / 8F); + float twist = (float)Math.sin(Math.PI/2F + 2 * animationProgress / speed) / 16F; float bend = attributes.motionRoll / 80F; if (attributes.isCrouching) { @@ -45,11 +45,11 @@ public class LionTail implements IPart { bend = interpolator.interpolate("kirin_tail_bendiness", bend, 10); tail.pitch = baseSail; - tail.pitch += swing / 2; + tail.pitch += limbSpeed / 2; tail.yaw = twist; 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.yaw += sinTickFactor; diff --git a/src/main/java/com/minelittlepony/client/model/part/PonyTail.java b/src/main/java/com/minelittlepony/client/model/part/PonyTail.java index 6dc1c4df..57605901 100644 --- a/src/main/java/com/minelittlepony/client/model/part/PonyTail.java +++ b/src/main/java/com/minelittlepony/client/model/part/PonyTail.java @@ -12,8 +12,8 @@ import com.minelittlepony.client.model.AbstractPonyModel; import com.minelittlepony.mson.api.*; import com.minelittlepony.util.MathUtil; -import java.util.ArrayList; import java.util.List; +import java.util.stream.IntStream; public class PonyTail implements IPart, MsonModel { private static final float TAIL_Z = 14; @@ -27,7 +27,7 @@ public class PonyTail implements IPart, MsonModel { private int tailStop = 0; private TailShape shape = TailShape.STRAIGHT; - private final List segments = new ArrayList<>(); + private List segments = List.of(); public PonyTail(ModelPart tree) { tail = tree.getChild("tail"); @@ -36,38 +36,32 @@ public class PonyTail implements IPart, MsonModel { @Override public void init(ModelView context) { model = context.getModel(); - - int segments = (int)context.getLocalValue("segments", 4); - - for (int i = 0; i < segments; i++) { - Segment segment = context.findByName("segment_" + i); - segment.tail = this; - segment.index = i; - this.segments.add(segment); - } + segments = IntStream.range(0, (int)context.getLocalValue("segments", 4)) + .mapToObj(i -> context.findByName("segment_" + i)) + .toList(); } @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; - 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; - if (model.getAttributes().isCrouching && !rainboom) { + if (attributes.isCrouching && !rainboom) { tail.setPivot(0, 0, TAIL_SNEAKING_Z); tail.pitch = -model.body.pitch + 0.1F; - } else if (model.getAttributes().isSitting) { + } else if (attributes.isSitting) { tail.pivotZ = TAIL_RIDING_Z; tail.pivotY = TAIL_RIDING_Y; tail.pitch = MathHelper.PI / 5; } else { tail.setPivot(0, 0, TAIL_Z); if (rainboom) { - tail.pitch = MathUtil.Angles._90_DEG + MathHelper.sin(move) / 10; + tail.pitch = MathUtil.Angles._90_DEG + MathHelper.sin(limbAngle) / 10; } else { - tail.pitch = swing / 2; + tail.pitch = limbSpeed / 2; - swingX(ticks); + swingX(animationProgress); } } @@ -86,8 +80,8 @@ public class PonyTail implements IPart, MsonModel { @Override public void setVisible(boolean visible, ModelAttributes attributes) { tail.visible = visible; - tailStop = model.getMetadata().getTailLength().ordinal(); - shape = model.getMetadata().getTailShape(); + tailStop = attributes.metadata.getTailLength().ordinal(); + shape = attributes.metadata.getTailShape(); } @Override @@ -95,23 +89,21 @@ public class PonyTail implements IPart, MsonModel { stack.push(); 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(); } public static class Segment { - public PonyTail tail; - - public int index; - private final ModelPart tree; public Segment(ModelPart 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) { return; } 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 71b21905..ab79a9ac 100644 --- a/src/main/java/com/minelittlepony/client/model/part/PonyWings.java +++ b/src/main/java/com/minelittlepony/client/model/part/PonyWings.java @@ -53,7 +53,7 @@ public class PonyWings implements IPart, MsonModel { } @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 progress = pegasus.getSwingAmount(); diff --git a/src/main/java/com/minelittlepony/client/model/part/SeaponyTail.java b/src/main/java/com/minelittlepony/client/model/part/SeaponyTail.java index 22d37fe9..3af8b752 100644 --- a/src/main/java/com/minelittlepony/client/model/part/SeaponyTail.java +++ b/src/main/java/com/minelittlepony/client/model/part/SeaponyTail.java @@ -22,8 +22,8 @@ public class SeaponyTail implements IPart, MsonModel { } @Override - public void setRotationAndAngles(ModelAttributes attributes, float move, float swing, float bodySwing, float ticks) { - float rotation = attributes.isSleeping ? 0 : MathHelper.sin(ticks * 0.536f) / 4; + public void setPartAngles(ModelAttributes attributes, float limbAngle, float limbSpeed, float bodySwing, float animationProgress) { + float rotation = attributes.isSleeping ? 0 : MathHelper.sin(animationProgress * 0.536f) / 4; tailBase.pitch = MathHelper.HALF_PI + rotation; tailTip.pitch = rotation;