2018-04-25 16:40:47 +02:00
|
|
|
package com.minelittlepony.model.components;
|
|
|
|
|
2018-04-26 23:53:49 +02:00
|
|
|
import com.minelittlepony.render.PonyRenderer;
|
2016-05-10 21:10:29 +02:00
|
|
|
|
|
|
|
import net.minecraft.client.entity.AbstractClientPlayer;
|
|
|
|
import net.minecraft.client.model.ModelBase;
|
|
|
|
import net.minecraft.client.renderer.GlStateManager;
|
|
|
|
import net.minecraft.entity.Entity;
|
|
|
|
import net.minecraft.entity.EntityLivingBase;
|
|
|
|
import net.minecraft.util.math.Vec3d;
|
|
|
|
|
2018-04-27 09:46:44 +02:00
|
|
|
import static com.minelittlepony.model.PonyModelConstants.*;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Modified from ModelElytra.
|
|
|
|
*/
|
2018-04-25 16:40:47 +02:00
|
|
|
public class PonyElytra extends ModelBase {
|
2018-04-26 23:53:49 +02:00
|
|
|
private PonyRenderer rightWing = new PonyRenderer(this, 22, 0);
|
|
|
|
private PonyRenderer leftWing = new PonyRenderer(this, 22, 0);
|
2016-05-10 21:10:29 +02:00
|
|
|
|
2018-04-25 16:40:47 +02:00
|
|
|
public PonyElytra() {
|
2018-04-27 13:49:33 +02:00
|
|
|
leftWing .box(-10, 0, 0, 10, 20, 2, 1);
|
2018-06-10 19:49:28 +02:00
|
|
|
rightWing.flip().box( 0, 0, 0, 10, 20, 2, 1);
|
2016-05-10 21:10:29 +02:00
|
|
|
}
|
|
|
|
|
2018-05-01 12:38:13 +02:00
|
|
|
/**
|
|
|
|
* Sets the model's various rotation angles.
|
|
|
|
*
|
|
|
|
* See {@link AbstractPonyModel.render} for an explanation of the various parameters.
|
|
|
|
*/
|
2016-05-10 21:10:29 +02:00
|
|
|
@Override
|
2018-05-01 12:38:13 +02:00
|
|
|
public void render(Entity entity, float move, float swing, float ticks, float headYaw, float headPitch, float scale) {
|
2016-05-10 21:10:29 +02:00
|
|
|
GlStateManager.disableRescaleNormal();
|
|
|
|
GlStateManager.disableCull();
|
2018-04-26 23:53:49 +02:00
|
|
|
leftWing.render(scale);
|
|
|
|
rightWing.render(scale);
|
2016-05-10 21:10:29 +02:00
|
|
|
}
|
|
|
|
|
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
|
2018-05-01 12:38:13 +02:00
|
|
|
public void setRotationAngles(float move, float swing, float ticks, float headYaw, float headPitch, float scale, Entity entity) {
|
|
|
|
super.setRotationAngles(move, swing, ticks, headYaw, headPitch, scale, entity);
|
2018-04-26 23:53:49 +02:00
|
|
|
|
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;
|
|
|
|
|
|
|
|
if (entity instanceof EntityLivingBase && ((EntityLivingBase) entity).isElytraFlying()) {
|
|
|
|
float velY = 1;
|
|
|
|
|
|
|
|
if (entity.motionY < 0) {
|
|
|
|
Vec3d motion = (new Vec3d(entity.motionX, entity.motionY, entity.motionZ)).normalize();
|
|
|
|
velY = 1 - (float) Math.pow(-motion.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;
|
|
|
|
} else if (entity.isSneaking()) {
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2018-04-27 09:46:44 +02:00
|
|
|
leftWing.rotationPointX = 5;
|
|
|
|
leftWing.rotationPointY = rpY;
|
|
|
|
|
|
|
|
if (entity instanceof AbstractClientPlayer) {
|
|
|
|
AbstractClientPlayer player = (AbstractClientPlayer) entity;
|
|
|
|
|
|
|
|
player.rotateElytraX += (rotateX - player.rotateElytraX) / 10;
|
|
|
|
player.rotateElytraY += (rotateY - player.rotateElytraY) / 10;
|
|
|
|
player.rotateElytraZ += (rotateZ - player.rotateElytraZ) / 10;
|
|
|
|
|
|
|
|
leftWing.rotateAngleX = player.rotateElytraX;
|
|
|
|
leftWing.rotateAngleY = player.rotateElytraY;
|
|
|
|
leftWing.rotateAngleZ = player.rotateElytraZ;
|
2016-05-10 21:10:29 +02:00
|
|
|
} else {
|
2018-04-27 09:46:44 +02:00
|
|
|
leftWing.rotateAngleX = rotateX;
|
|
|
|
leftWing.rotateAngleZ = rotateZ;
|
|
|
|
leftWing.rotateAngleY = rotateY;
|
2016-05-10 21:10:29 +02:00
|
|
|
}
|
|
|
|
|
2018-04-27 09:46:44 +02:00
|
|
|
rightWing.rotationPointX = -leftWing.rotationPointX;
|
|
|
|
rightWing.rotationPointY = leftWing.rotationPointY;
|
|
|
|
rightWing.rotateAngleX = leftWing.rotateAngleX;
|
|
|
|
rightWing.rotateAngleY = -leftWing.rotateAngleY;
|
|
|
|
rightWing.rotateAngleZ = -leftWing.rotateAngleZ;
|
2016-05-10 21:10:29 +02:00
|
|
|
}
|
|
|
|
|
2016-11-25 05:40:19 +01:00
|
|
|
}
|