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-06-10 23:04:58 +02:00
|
|
|
public class PegasusWings<T extends AbstractPonyModel & IModelPegasus> implements IModelPart {
|
2016-11-25 05:40:19 +01:00
|
|
|
|
2018-06-10 23:04:58 +02:00
|
|
|
private final T pegasus;
|
2018-04-24 17:12:23 +02:00
|
|
|
|
2018-06-10 23:04:58 +02:00
|
|
|
private ModelWing leftWing;
|
|
|
|
private ModelWing rightWing;
|
2018-04-24 17:12:23 +02:00
|
|
|
|
2018-06-10 23:04:58 +02:00
|
|
|
private ModelWing legacyWing;
|
2018-06-05 20:18:57 +02:00
|
|
|
|
2018-06-10 23:04:58 +02:00
|
|
|
public PegasusWings(T model, float yOffset, float stretch) {
|
2018-04-28 18:13:35 +02:00
|
|
|
pegasus = model;
|
2018-04-27 13:49:33 +02:00
|
|
|
|
2018-06-10 23:04:58 +02:00
|
|
|
init(yOffset, stretch);
|
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-10 23:04:58 +02:00
|
|
|
int x = 57;
|
|
|
|
|
|
|
|
leftWing = new ModelWing(pegasus, false, yOffset, stretch, x, 32);
|
|
|
|
rightWing = new ModelWing(pegasus, true, yOffset, stretch, x, 16);
|
2018-05-11 13:52:42 +02:00
|
|
|
|
2018-06-10 23:04:58 +02:00
|
|
|
legacyWing = new ModelWing(pegasus, true, yOffset, stretch, x - 1, 32);
|
2018-05-11 13:52:42 +02:00
|
|
|
}
|
|
|
|
|
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);
|
|
|
|
|
2018-06-08 01:05:16 +02:00
|
|
|
float mve = move * 0.6662f; // magic number ahoy (actually 2/3)
|
2018-04-27 13:49:33 +02:00
|
|
|
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);
|
2018-06-08 01:05:16 +02:00
|
|
|
if (pegasus.isWearing(PonyWearable.SADDLE_BAGS)) {
|
|
|
|
flapAngle -= 0.6F;
|
|
|
|
}
|
2018-06-05 20:18:57 +02:00
|
|
|
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-06-10 23:04:58 +02:00
|
|
|
getLeft().render(scale);
|
|
|
|
getRight().render(scale);
|
2015-12-14 09:29:10 +01:00
|
|
|
}
|
|
|
|
}
|