MineLittlePony/src/main/java/com/minelittlepony/model/components/PegasusWings.java

58 lines
2.1 KiB
Java
Raw Normal View History

package com.minelittlepony.model.components;
import com.minelittlepony.model.AbstractPonyModel;
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;
import static com.minelittlepony.model.PonyModelConstants.*;
public class PegasusWings extends ModelBase {
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
public PegasusWings(AbstractPonyModel pony, float yOffset, float stretch) {
this.pony = pony;
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);
}
2018-04-24 17:12:23 +02: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) {
float bodySwingRotation = 0.0F;
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;
}
2018-04-24 16:46:53 +02:00
leftWing.updateModelRotation(bodySwingRotation);
rightWing.updateModelRotation(bodySwingRotation);
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);
}
2018-04-24 16:46:53 +02:00
leftWing.rotate(ROTATE_90);
rightWing.rotate(ROTATE_90);
}
2018-04-24 17:12:23 +02:00
@Override
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);
}
}
}