2018-04-25 12:59:18 +02:00
|
|
|
package com.minelittlepony.model.components;
|
|
|
|
|
2016-05-04 03:23:57 +02:00
|
|
|
import net.minecraft.util.math.MathHelper;
|
2015-12-14 09:29:10 +01:00
|
|
|
|
2018-04-25 12:59:18 +02:00
|
|
|
import static com.minelittlepony.model.PonyModelConstants.*;
|
|
|
|
|
2018-04-25 16:40:47 +02:00
|
|
|
import com.minelittlepony.model.AbstractPonyModel;
|
2018-05-11 13:52:42 +02:00
|
|
|
import com.minelittlepony.model.capabilities.IModelPart;
|
2018-04-28 18:13:35 +02:00
|
|
|
import com.minelittlepony.model.capabilities.IModelPegasus;
|
2018-06-05 20:18:57 +02:00
|
|
|
import com.minelittlepony.pony.data.PonyWearable;
|
2018-04-25 16:40:47 +02:00
|
|
|
|
2018-05-11 13:52:42 +02:00
|
|
|
public class PegasusWings implements IModelPart {
|
2016-11-25 05:40:19 +01:00
|
|
|
|
2018-04-28 18:13:35 +02:00
|
|
|
private final IModelPegasus pegasus;
|
2018-04-24 17:12:23 +02:00
|
|
|
|
2018-06-04 22:24:32 +02:00
|
|
|
private final ModelWing leftWing;
|
|
|
|
private final ModelWing rightWing;
|
2018-04-24 17:12:23 +02:00
|
|
|
|
2018-06-05 20:18:57 +02:00
|
|
|
private final ModelWing legacyWing;
|
|
|
|
|
2018-04-28 18:13:35 +02:00
|
|
|
public <T extends AbstractPonyModel & IModelPegasus> PegasusWings(T model, float yOffset, float stretch) {
|
|
|
|
pegasus = model;
|
2018-04-27 13:49:33 +02:00
|
|
|
|
2018-06-05 20:18:57 +02:00
|
|
|
leftWing = new ModelWing(model, false, 4, yOffset, stretch, 32);
|
|
|
|
rightWing = new ModelWing(model, true, -6, yOffset, stretch, 16);
|
|
|
|
legacyWing = new ModelWing(model, true, -6, yOffset, stretch, 32);
|
2015-12-14 09:29:10 +01:00
|
|
|
}
|
2018-04-24 17:12:23 +02:00
|
|
|
|
2018-05-11 13:52:42 +02:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public void init(float yOffset, float stretch) {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2018-06-05 20:18:57 +02:00
|
|
|
public ModelWing getLeft() {
|
|
|
|
return leftWing;
|
|
|
|
}
|
|
|
|
|
|
|
|
public ModelWing getRight() {
|
|
|
|
return pegasus.isWearing(PonyWearable.SADDLE_BAGS) ? legacyWing : rightWing;
|
|
|
|
}
|
|
|
|
|
2018-05-11 13:52:42 +02:00
|
|
|
@Override
|
|
|
|
public void setRotationAndAngles(boolean rainboom, float move, float swing, float bodySwing, float ticks) {
|
2018-04-27 13:49:33 +02:00
|
|
|
float flap = 0;
|
2018-04-28 18:13:35 +02:00
|
|
|
float progress = pegasus.getSwingAmount();
|
2018-04-27 13:49:33 +02:00
|
|
|
|
2018-04-28 18:13:35 +02:00
|
|
|
if (progress > 0) {
|
|
|
|
flap = MathHelper.sin(MathHelper.sqrt(progress) * PI * 2);
|
2018-04-26 17:20:02 +02:00
|
|
|
} else {
|
2018-04-27 13:49:33 +02:00
|
|
|
float pi = PI * (float) Math.pow(swing, 16);
|
|
|
|
|
|
|
|
float mve = move * 0.6662f; // magic number ahoy
|
|
|
|
float srt = swing / 4;
|
|
|
|
|
|
|
|
flap = MathHelper.cos(mve + pi) * srt;
|
2018-04-26 17:20:02 +02:00
|
|
|
}
|
2018-04-27 13:49:33 +02:00
|
|
|
|
2018-06-05 20:18:57 +02:00
|
|
|
getLeft().rotateWalking(flap);
|
|
|
|
getRight().rotateWalking(-flap);
|
2018-04-27 13:49:33 +02:00
|
|
|
|
2018-04-28 18:13:35 +02:00
|
|
|
if (pegasus.wingsAreOpen()) {
|
2018-06-05 20:18:57 +02:00
|
|
|
float flapAngle = pegasus.getWingRotationFactor(ticks);
|
|
|
|
getLeft().rotateFlying(flapAngle);
|
|
|
|
getRight().rotateFlying(-flapAngle);
|
2015-12-14 09:29:10 +01:00
|
|
|
}
|
2018-04-27 13:49:33 +02:00
|
|
|
|
2018-04-26 17:20:02 +02:00
|
|
|
}
|
2018-04-27 13:49:33 +02:00
|
|
|
|
2018-05-11 13:52:42 +02:00
|
|
|
@Override
|
2018-06-04 19:34:31 +02:00
|
|
|
public void renderPart(float scale) {
|
2018-04-28 18:13:35 +02:00
|
|
|
boolean standing = pegasus.wingsAreOpen();
|
2018-06-05 20:18:57 +02:00
|
|
|
getLeft().render(standing, scale);
|
|
|
|
getRight().render(standing, scale);
|
2015-12-14 09:29:10 +01:00
|
|
|
}
|
|
|
|
}
|