2019-11-23 22:07:39 +01:00
|
|
|
package com.minelittlepony.client.model;
|
2018-04-25 16:40:47 +02:00
|
|
|
|
2019-11-23 18:28:42 +01:00
|
|
|
import net.minecraft.client.model.ModelPart;
|
2019-05-27 17:59:15 +02:00
|
|
|
import net.minecraft.client.network.AbstractClientPlayerEntity;
|
2019-11-23 18:28:42 +01:00
|
|
|
import net.minecraft.client.render.entity.model.AnimalModel;
|
2019-05-27 17:59:15 +02:00
|
|
|
import net.minecraft.entity.LivingEntity;
|
2016-05-10 21:10:29 +02:00
|
|
|
import net.minecraft.util.math.Vec3d;
|
|
|
|
|
2019-11-23 18:28:42 +01:00
|
|
|
import com.google.common.collect.ImmutableList;
|
2019-11-27 13:09:53 +01:00
|
|
|
import com.minelittlepony.mson.api.ModelContext;
|
|
|
|
import com.minelittlepony.mson.api.MsonModel;
|
2018-09-05 10:12:38 +02:00
|
|
|
|
2019-03-23 20:58:50 +01:00
|
|
|
import static com.minelittlepony.model.PonyModelConstants.*;
|
2018-04-27 09:46:44 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Modified from ModelElytra.
|
|
|
|
*/
|
2019-11-27 13:09:53 +01:00
|
|
|
public class PonyElytra<T extends LivingEntity> extends AnimalModel<T> implements MsonModel {
|
2019-03-22 21:09:06 +01:00
|
|
|
|
|
|
|
public boolean isSneaking;
|
|
|
|
|
2019-11-23 22:59:33 +01:00
|
|
|
private ModelPart rightWing;
|
|
|
|
private ModelPart leftWing;
|
2016-05-10 21:10:29 +02:00
|
|
|
|
2019-11-27 13:09:53 +01:00
|
|
|
@Override
|
|
|
|
public void init(ModelContext context) {
|
|
|
|
rightWing = context.findByName("right_wing");
|
|
|
|
leftWing = context.findByName("left_wing");
|
|
|
|
}
|
|
|
|
|
2016-05-10 21:10:29 +02:00
|
|
|
@Override
|
2019-11-23 18:28:42 +01:00
|
|
|
protected Iterable<ModelPart> getHeadParts() {
|
|
|
|
return ImmutableList.of();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected Iterable<ModelPart> getBodyParts() {
|
|
|
|
return ImmutableList.of(leftWing, rightWing);
|
|
|
|
}
|
|
|
|
|
2018-05-01 12:38:13 +02:00
|
|
|
/**
|
|
|
|
* Sets the model's various rotation angles.
|
|
|
|
*
|
|
|
|
* See {@link AbstractPonyModel.setRotationAngles} for an explanation of the various parameters.
|
|
|
|
*/
|
2016-05-10 21:10:29 +02:00
|
|
|
@Override
|
2019-11-23 18:28:42 +01:00
|
|
|
public void setAngles(T entity, float limbDistance, float limbAngle, float age, float headYaw, float headPitch) {
|
2018-04-27 09:46:44 +02:00
|
|
|
float rotateX = PI / 2;
|
|
|
|
float rotateY = PI / 8;
|
2016-05-10 21:10:29 +02:00
|
|
|
float rotateZ = PI / 12;
|
2018-04-27 09:46:44 +02:00
|
|
|
|
|
|
|
float rpY = BODY_RP_Y_NOTSNEAK;
|
|
|
|
|
2019-05-27 17:59:15 +02:00
|
|
|
if (entity.isFallFlying()) {
|
2018-04-27 09:46:44 +02:00
|
|
|
float velY = 1;
|
|
|
|
|
2019-05-27 17:59:15 +02:00
|
|
|
Vec3d motion = entity.getVelocity();
|
|
|
|
if (motion.y < 0) {
|
|
|
|
velY = 1 - (float) Math.pow(-motion.normalize().y, 1.5);
|
2016-05-10 21:10:29 +02:00
|
|
|
}
|
|
|
|
|
2018-04-27 09:46:44 +02:00
|
|
|
rotateX = velY * PI * (2 / 3F) + (1 - velY) * rotateX;
|
|
|
|
rotateY = velY * (PI / 2) + (1 - velY) * rotateY;
|
2019-03-22 21:09:06 +01:00
|
|
|
} else if (isSneaking) {
|
2018-04-27 09:46:44 +02:00
|
|
|
rotateX = PI * 1.175F;
|
2016-05-10 21:10:29 +02:00
|
|
|
rotateY = PI / 2;
|
2018-04-27 09:46:44 +02:00
|
|
|
rotateZ = PI / 4;
|
|
|
|
rpY = BODY_RP_Y_SNEAK;
|
2016-05-10 21:10:29 +02:00
|
|
|
}
|
|
|
|
|
2019-11-22 18:24:22 +01:00
|
|
|
leftWing.pivotX = 5;
|
|
|
|
leftWing.pivotY = rpY;
|
2018-04-27 09:46:44 +02:00
|
|
|
|
2019-05-27 17:59:15 +02:00
|
|
|
if (entity instanceof AbstractClientPlayerEntity) {
|
|
|
|
AbstractClientPlayerEntity player = (AbstractClientPlayerEntity) entity;
|
2018-04-27 09:46:44 +02:00
|
|
|
|
2019-05-27 17:59:15 +02:00
|
|
|
player.elytraPitch += (rotateX - player.elytraPitch) / 10;
|
|
|
|
player.elytraYaw += (rotateY - player.elytraYaw) / 10;
|
|
|
|
player.elytraRoll += (rotateZ - player.elytraRoll) / 10;
|
2018-04-27 09:46:44 +02:00
|
|
|
|
2019-05-27 17:59:15 +02:00
|
|
|
leftWing.pitch = player.elytraPitch;
|
|
|
|
leftWing.yaw = player.elytraYaw;
|
|
|
|
leftWing.roll = player.elytraRoll;
|
2016-05-10 21:10:29 +02:00
|
|
|
} else {
|
2019-05-27 17:59:15 +02:00
|
|
|
leftWing.pitch = rotateX;
|
|
|
|
leftWing.yaw = rotateZ;
|
|
|
|
leftWing.roll = rotateY;
|
2016-05-10 21:10:29 +02:00
|
|
|
}
|
|
|
|
|
2019-11-22 18:24:22 +01:00
|
|
|
rightWing.pivotX = -leftWing.pivotX;
|
|
|
|
rightWing.pivotY = leftWing.pivotY;
|
2019-05-27 17:59:15 +02:00
|
|
|
rightWing.pitch = leftWing.pitch;
|
|
|
|
rightWing.yaw = -leftWing.yaw;
|
|
|
|
rightWing.roll = -leftWing.roll;
|
2016-05-10 21:10:29 +02:00
|
|
|
}
|
2016-11-25 05:40:19 +01:00
|
|
|
}
|