2018-04-25 12:59:18 +02:00
|
|
|
package com.minelittlepony.model.components;
|
|
|
|
|
2016-11-25 05:40:19 +01:00
|
|
|
import net.minecraft.client.model.ModelBase;
|
|
|
|
import net.minecraft.entity.Entity;
|
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-04-25 12:59:18 +02:00
|
|
|
public class PegasusWings extends ModelBase {
|
2016-11-25 05:40:19 +01:00
|
|
|
|
2016-04-09 08:24:15 +02:00
|
|
|
private final AbstractPonyModel pony;
|
2018-04-24 17:12:23 +02:00
|
|
|
|
2018-04-24 16:46:53 +02:00
|
|
|
public final ModelWing leftWing, rightWing;
|
2018-04-24 17:12:23 +02:00
|
|
|
|
2016-11-25 05:40:19 +01:00
|
|
|
public PegasusWings(AbstractPonyModel pony, float yOffset, float stretch) {
|
2015-12-14 09:29:10 +01:00
|
|
|
this.pony = pony;
|
2018-04-24 14:55:32 +02:00
|
|
|
|
2018-04-24 16:46:53 +02:00
|
|
|
leftWing = new ModelWing(pony, false, 4f, yOffset, stretch, 32);
|
|
|
|
rightWing = new ModelWing(pony, true, -6f, yOffset, stretch, 16);
|
2015-12-14 09:29:10 +01:00
|
|
|
}
|
2018-04-24 17:12:23 +02:00
|
|
|
|
2015-12-14 09:29:10 +01:00
|
|
|
@Override
|
2018-04-24 16:46:53 +02:00
|
|
|
public void setRotationAngles(float limbSwing, float limbSwingAmount, float ticks, float netHeadYaw, float headPitch, float scaleFactor, Entity entityIn) {
|
2015-12-14 09:29:10 +01:00
|
|
|
|
|
|
|
float bodySwingRotation = 0.0F;
|
2016-11-25 05:40:19 +01:00
|
|
|
if (pony.swingProgress > -9990.0F && !pony.metadata.hasMagic()) {
|
2016-11-17 05:45:04 +01:00
|
|
|
bodySwingRotation = MathHelper.sin(MathHelper.sqrt(pony.swingProgress) * 3.1415927F * 2.0F) * 0.2F;
|
2015-12-14 09:29:10 +01:00
|
|
|
}
|
2018-04-24 16:46:53 +02:00
|
|
|
|
|
|
|
leftWing.updateModelRotation(bodySwingRotation);
|
|
|
|
rightWing.updateModelRotation(bodySwingRotation);
|
|
|
|
|
2015-12-14 09:29:10 +01:00
|
|
|
if (pony.isSneak && !pony.isFlying) {
|
2018-04-24 16:46:53 +02:00
|
|
|
leftWing.rotateSneaked(LEFT_WING_ROTATE_ANGLE_Z_SNEAK);
|
2018-04-24 21:24:29 +02:00
|
|
|
rightWing.rotateSneaked(-LEFT_WING_ROTATE_ANGLE_Z_SNEAK);
|
2018-04-24 16:46:53 +02:00
|
|
|
} else if (pony.isFlying) {
|
|
|
|
float WingRotateAngleZ = (MathHelper.sin(ticks * 0.536F) * 1.0F) + ROTATE_270 + 0.4F;
|
|
|
|
|
2018-04-24 21:24:29 +02:00
|
|
|
leftWing.rotateUnsneaked(WingRotateAngleZ);
|
|
|
|
rightWing.rotateUnsneaked(-WingRotateAngleZ);
|
2015-12-14 09:29:10 +01:00
|
|
|
}
|
2018-04-24 16:46:53 +02:00
|
|
|
|
|
|
|
leftWing.rotate(ROTATE_90);
|
|
|
|
rightWing.rotate(ROTATE_90);
|
2015-12-14 09:29:10 +01:00
|
|
|
}
|
2018-04-24 17:12:23 +02:00
|
|
|
|
2015-12-14 09:29:10 +01:00
|
|
|
@Override
|
2016-11-25 05:40:19 +01:00
|
|
|
public void render(Entity entityIn, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch, float scale) {
|
2017-06-13 05:55:50 +02:00
|
|
|
if (pony.metadata.getRace().hasWings()) {
|
2018-04-24 16:46:53 +02:00
|
|
|
boolean standing = !pony.isFlying && !pony.isSneak;
|
|
|
|
leftWing.render(standing, scale);
|
|
|
|
rightWing.render(standing, scale);
|
2015-12-14 09:29:10 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|