diff --git a/src/main/java/com/minelittlepony/model/AbstractPonyModel.java b/src/main/java/com/minelittlepony/model/AbstractPonyModel.java index c7b96fdd..f3120449 100644 --- a/src/main/java/com/minelittlepony/model/AbstractPonyModel.java +++ b/src/main/java/com/minelittlepony/model/AbstractPonyModel.java @@ -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 diff --git a/src/main/java/com/minelittlepony/model/capabilities/IModel.java b/src/main/java/com/minelittlepony/model/capabilities/IModel.java index acc4e84c..f5af1ccb 100644 --- a/src/main/java/com/minelittlepony/model/capabilities/IModel.java +++ b/src/main/java/com/minelittlepony/model/capabilities/IModel.java @@ -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. */ diff --git a/src/main/java/com/minelittlepony/model/components/PonyElytra.java b/src/main/java/com/minelittlepony/model/components/PonyElytra.java index 518fc2fe..562fd819 100644 --- a/src/main/java/com/minelittlepony/model/components/PonyElytra.java +++ b/src/main/java/com/minelittlepony/model/components/PonyElytra.java @@ -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; diff --git a/src/main/java/com/minelittlepony/pony/data/Pony.java b/src/main/java/com/minelittlepony/pony/data/Pony.java index 270e3d1e..7d17eb5f 100644 --- a/src/main/java/com/minelittlepony/pony/data/Pony.java +++ b/src/main/java/com/minelittlepony/pony/data/Pony.java @@ -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) { diff --git a/src/main/java/com/minelittlepony/render/RenderPonyMob.java b/src/main/java/com/minelittlepony/render/RenderPonyMob.java index 9223fac5..39a00a67 100644 --- a/src/main/java/com/minelittlepony/render/RenderPonyMob.java +++ b/src/main/java/com/minelittlepony/render/RenderPonyMob.java @@ -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 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); diff --git a/src/main/java/com/minelittlepony/render/layer/LayerPonyElytra.java b/src/main/java/com/minelittlepony/render/layer/LayerPonyElytra.java index 0c3c9ec8..ecbd705b 100644 --- a/src/main/java/com/minelittlepony/render/layer/LayerPonyElytra.java +++ b/src/main/java/com/minelittlepony/render/layer/LayerPonyElytra.java @@ -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 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);