mirror of
https://github.com/MineLittlePony/MineLittlePony.git
synced 2025-02-13 08:14:23 +01:00
Fix loading error when instantiating the pony tail
This commit is contained in:
parent
d6233c5266
commit
b6e8d1f2d8
1 changed files with 24 additions and 25 deletions
|
@ -14,27 +14,26 @@ import com.minelittlepony.mson.api.MsonModel;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.concurrent.ExecutionException;
|
import java.util.concurrent.ExecutionException;
|
||||||
|
|
||||||
public class PonyTail extends ModelPart implements IPart, MsonModel {
|
public class PonyTail implements IPart, MsonModel {
|
||||||
|
|
||||||
private final AbstractPonyModel<?> theModel;
|
private ModelPart tail;
|
||||||
|
private AbstractPonyModel<?> theModel;
|
||||||
|
|
||||||
private int tailStop = 0;
|
private int tailStop = 0;
|
||||||
|
|
||||||
public PonyTail(AbstractPonyModel<?> model) {
|
|
||||||
super(model);
|
|
||||||
theModel = model;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void init(ModelContext context) {
|
public void init(ModelContext context) {
|
||||||
|
theModel = (AbstractPonyModel<?>)context.getModel();
|
||||||
|
|
||||||
|
tail = new ModelPart(theModel);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
int segments = context.getLocals().getValue("segments").get().intValue();
|
int segments = context.getLocals().getValue("segments").get().intValue();
|
||||||
|
|
||||||
for (int i = 0; i < segments; i++) {
|
for (int i = 0; i < segments; i++) {
|
||||||
Segment segment = context.findByName("segment_" + i);
|
Segment segment = context.findByName("segment_" + i);
|
||||||
segment.index = i;
|
segment.index = i;
|
||||||
addChild(segment);
|
tail.addChild(segment);
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (InterruptedException | ExecutionException e) {
|
} catch (InterruptedException | ExecutionException e) {
|
||||||
|
@ -44,29 +43,29 @@ public class PonyTail extends ModelPart implements IPart, MsonModel {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setRotationAndAngles(boolean rainboom, UUID interpolatorId, float move, float swing, float bodySwing, float ticks) {
|
public void setRotationAndAngles(boolean rainboom, UUID interpolatorId, float move, float swing, float bodySwing, float ticks) {
|
||||||
roll = rainboom ? 0 : MathHelper.cos(move * 0.8F) * 0.2f * swing;
|
tail.roll = rainboom ? 0 : MathHelper.cos(move * 0.8F) * 0.2f * swing;
|
||||||
yaw = bodySwing;
|
tail.yaw = bodySwing;
|
||||||
|
|
||||||
if (theModel.getAttributes().isCrouching && !rainboom) {
|
if (theModel.getAttributes().isCrouching && !rainboom) {
|
||||||
rotateSneak();
|
rotateSneak();
|
||||||
} else if (theModel.isRiding()) {
|
} else if (theModel.isRiding()) {
|
||||||
pivotZ = TAIL_RP_Z_RIDING;
|
tail.pivotZ = TAIL_RP_Z_RIDING;
|
||||||
pivotY = TAIL_RP_Y_RIDING;
|
tail.pivotY = TAIL_RP_Y_RIDING;
|
||||||
pitch = PI / 5;
|
tail.pitch = PI / 5;
|
||||||
} else {
|
} else {
|
||||||
setPivot(TAIL_RP_X, TAIL_RP_Y, TAIL_RP_Z_NOTSNEAK);
|
tail.setPivot(TAIL_RP_X, TAIL_RP_Y, TAIL_RP_Z_NOTSNEAK);
|
||||||
if (rainboom) {
|
if (rainboom) {
|
||||||
pitch = ROTATE_90 + MathHelper.sin(move) / 10;
|
tail.pitch = ROTATE_90 + MathHelper.sin(move) / 10;
|
||||||
} else {
|
} else {
|
||||||
pitch = swing / 2;
|
tail.pitch = swing / 2;
|
||||||
|
|
||||||
swingX(ticks);
|
swingX(ticks);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rainboom) {
|
if (rainboom) {
|
||||||
pivotY += 6;
|
tail.pivotY += 6;
|
||||||
pivotZ++;
|
tail.pivotZ++;
|
||||||
}
|
}
|
||||||
|
|
||||||
tailStop = theModel.getMetadata().getTail().ordinal();
|
tailStop = theModel.getMetadata().getTail().ordinal();
|
||||||
|
@ -74,23 +73,23 @@ public class PonyTail extends ModelPart implements IPart, MsonModel {
|
||||||
|
|
||||||
private void swingX(float ticks) {
|
private void swingX(float ticks) {
|
||||||
float sinTickFactor = MathHelper.sin(ticks * 0.067f) * 0.05f;
|
float sinTickFactor = MathHelper.sin(ticks * 0.067f) * 0.05f;
|
||||||
pitch += sinTickFactor;
|
tail.pitch += sinTickFactor;
|
||||||
yaw += sinTickFactor;
|
tail.yaw += sinTickFactor;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void rotateSneak() {
|
private void rotateSneak() {
|
||||||
setPivot(TAIL_RP_X, TAIL_RP_Y, TAIL_RP_Z_SNEAK);
|
tail.setPivot(TAIL_RP_X, TAIL_RP_Y, TAIL_RP_Z_SNEAK);
|
||||||
pitch = -BODY_ROT_X_SNEAK + 0.1F;
|
tail.pitch = -BODY_ROT_X_SNEAK + 0.1F;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setVisible(boolean visible) {
|
public void setVisible(boolean visible) {
|
||||||
this.visible = visible;
|
tail.visible = visible;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void renderPart(MatrixStack stack, VertexConsumer vertices, int overlayUv, int lightUv, float red, float green, float blue, float alpha, UUID interpolatorId) {
|
public void renderPart(MatrixStack stack, VertexConsumer vertices, int overlayUv, int lightUv, float red, float green, float blue, float alpha, UUID interpolatorId) {
|
||||||
render(stack, vertices, overlayUv, lightUv, red, green, blue, alpha);
|
tail.render(stack, vertices, overlayUv, lightUv, red, green, blue, alpha);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class Segment extends ModelPart implements MsonModel {
|
private static class Segment extends ModelPart implements MsonModel {
|
||||||
|
|
Loading…
Reference in a new issue