mirror of
https://github.com/MineLittlePony/MineLittlePony.git
synced 2024-11-25 13:57:59 +01:00
It's a bird! it's a plane! As requested, flying ponies will now wear elytra as capes.
This commit is contained in:
parent
5b3836c2df
commit
9e81492a49
6 changed files with 25 additions and 24 deletions
|
@ -17,7 +17,6 @@ import net.minecraft.client.model.ModelPlayer;
|
|||
import net.minecraft.client.model.ModelRenderer;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.util.EnumHandSide;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
|
||||
|
@ -202,7 +201,7 @@ public abstract class AbstractPonyModel extends ModelPlayer implements IModel {
|
|||
*
|
||||
*/
|
||||
protected void setLegs(float move, float swing, float ticks, Entity entity) {
|
||||
if (isFlying(entity)) {
|
||||
if (isFlying()) {
|
||||
rotateLegsInFlight(move, swing, ticks, entity);
|
||||
} else {
|
||||
rotateLegsOnGround(move, swing, ticks, entity);
|
||||
|
@ -663,18 +662,12 @@ public abstract class AbstractPonyModel extends ModelPlayer implements IModel {
|
|||
* Checks flying and speed conditions and sets rainboom to true if we're a species with wings and is going faaast.
|
||||
*/
|
||||
protected void checkRainboom(Entity entity, float swing) {
|
||||
rainboom = isFlying(entity) && swing >= 0.9999F;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFlying(Entity entity) {
|
||||
return (isFlying && metadata.getRace().hasWings()) ||
|
||||
(entity instanceof EntityLivingBase && ((EntityLivingBase) entity).isElytraFlying());
|
||||
rainboom = isFlying() && swing >= 0.9999F;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFlying() {
|
||||
return isFlying;
|
||||
return isFlying && metadata.getRace().hasWings();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -3,8 +3,6 @@ package com.minelittlepony.model.capabilities;
|
|||
import com.minelittlepony.model.BodyPart;
|
||||
import com.minelittlepony.model.armour.PonyArmor;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
|
||||
public interface IModel {
|
||||
|
||||
/**
|
||||
|
@ -30,11 +28,6 @@ public interface IModel {
|
|||
*/
|
||||
boolean isCrouching();
|
||||
|
||||
/**
|
||||
* Returns true if the given entity can and is flying, or has an elytra.
|
||||
*/
|
||||
boolean isFlying(Entity entity);
|
||||
|
||||
/**
|
||||
* Returns true if the model is flying.
|
||||
*/
|
||||
|
|
|
@ -7,6 +7,7 @@ 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.MathHelper;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
|
||||
import static com.minelittlepony.model.PonyModelConstants.*;
|
||||
|
@ -18,6 +19,8 @@ public class PonyElytra extends ModelBase {
|
|||
private PonyRenderer rightWing = new PonyRenderer(this, 22, 0);
|
||||
private PonyRenderer leftWing = new PonyRenderer(this, 22, 0);
|
||||
|
||||
public boolean isCape;
|
||||
|
||||
public PonyElytra() {
|
||||
leftWing .box(-10, 0, 0, 10, 20, 2, 1);
|
||||
rightWing.flipX().box( 0, 0, 0, 10, 20, 2, 1);
|
||||
|
@ -46,12 +49,12 @@ public class PonyElytra extends ModelBase {
|
|||
super.setRotationAngles(move, swing, ticks, headYaw, headPitch, scale, entity);
|
||||
|
||||
float rotateX = PI / 2;
|
||||
float rotateY = PI / 8;
|
||||
float rotateZ = PI / 12;
|
||||
float rotateY = isCape ? 0 : PI / 8;
|
||||
float rotateZ = isCape ? 0 : PI / 12;
|
||||
|
||||
float rpY = BODY_RP_Y_NOTSNEAK;
|
||||
|
||||
if (entity instanceof EntityLivingBase && ((EntityLivingBase) entity).isElytraFlying()) {
|
||||
if (isCape || entity instanceof EntityLivingBase && ((EntityLivingBase) entity).isElytraFlying()) {
|
||||
float velY = 1;
|
||||
|
||||
if (entity.motionY < 0) {
|
||||
|
@ -59,8 +62,15 @@ public class PonyElytra extends ModelBase {
|
|||
velY = 1 - (float) Math.pow(-motion.y, 1.5);
|
||||
}
|
||||
|
||||
rotateX = velY * PI * (2 / 3F) + (1 - velY) * rotateX;
|
||||
rotateY = velY * (PI / 2) + (1 - velY) * rotateY;
|
||||
|
||||
if (isCape) {
|
||||
rotateX = ((1 - velY) * (-PI * 1.5F) + velY * rotateX) + PI/4;
|
||||
rotateX = MathHelper.clamp(rotateX, PI/2, PI * 0.6F);
|
||||
rotateX += MathHelper.sin(move) / 6;
|
||||
} else {
|
||||
rotateX = velY * PI * (2 / 3F) + (1 - velY) * rotateX;
|
||||
rotateY = velY * (PI / 2) + (1 - velY) * rotateY;
|
||||
}
|
||||
} else if (entity.isSneaking()) {
|
||||
rotateX = PI * 1.175F;
|
||||
rotateY = PI / 2;
|
||||
|
|
|
@ -100,7 +100,7 @@ public class Pony {
|
|||
//noinspection SimplifiableIfStatement
|
||||
if (!getRace(false).hasWings()) return false;
|
||||
|
||||
return player.capabilities.isFlying || !(player.onGround || player.isRiding() || player.isOnLadder() || player.isInWater() || player.isElytraFlying());
|
||||
return player.capabilities.isFlying || !(player.onGround || player.isRiding() || player.isOnLadder() || player.isInWater());
|
||||
}
|
||||
|
||||
public ModelWrapper getModel(boolean ignorePony) {
|
||||
|
|
|
@ -13,6 +13,7 @@ import net.minecraft.client.renderer.entity.RenderLiving;
|
|||
import net.minecraft.client.renderer.entity.RenderManager;
|
||||
import net.minecraft.client.renderer.entity.layers.LayerArrow;
|
||||
import net.minecraft.entity.EntityLiving;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
@ -53,7 +54,7 @@ public abstract class RenderPonyMob<T extends EntityLiving> extends RenderLiving
|
|||
@OverridingMethodsMustInvokeSuper
|
||||
protected void preRenderCallback(T entity, float ticks) {
|
||||
playerModel.getModel().isSneak = entity.isSneaking();
|
||||
playerModel.getModel().isFlying = !entity.onGround;
|
||||
playerModel.getModel().isFlying = !entity.onGround || (entity instanceof EntityLivingBase && ((EntityLivingBase) entity).isElytraFlying());
|
||||
playerModel.getModel().isSleeping = false;
|
||||
|
||||
ResourceLocation loc = getEntityTexture(entity);
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package com.minelittlepony.render.layer;
|
||||
|
||||
import com.minelittlepony.model.BodyPart;
|
||||
import com.minelittlepony.model.capabilities.IModelPegasus;
|
||||
import com.minelittlepony.model.components.PonyElytra;
|
||||
|
||||
import net.minecraft.client.entity.AbstractClientPlayer;
|
||||
|
@ -37,6 +38,9 @@ public class LayerPonyElytra<T extends EntityLivingBase> extends AbstractPonyLay
|
|||
GlStateManager.pushMatrix();
|
||||
GlStateManager.translate(0, 0.25F, 0.125F);
|
||||
getPlayerModel().transform(BodyPart.BODY);
|
||||
|
||||
modelElytra.isCape = getPlayerModel().metadata.getRace().hasWings() && getPlayerModel().isFlying();
|
||||
|
||||
modelElytra.setRotationAngles(move, swing, ticks, yaw, head, scale, entity);
|
||||
modelElytra.render(entity, move, swing, ticks, yaw, head, scale);
|
||||
|
||||
|
|
Loading…
Reference in a new issue