It's a bird! it's a plane! As requested, flying ponies will now wear elytra as capes.

This commit is contained in:
Sollace 2018-05-09 17:05:03 +02:00
parent 5b3836c2df
commit 9e81492a49
6 changed files with 25 additions and 24 deletions

View file

@ -17,7 +17,6 @@ import net.minecraft.client.model.ModelPlayer;
import net.minecraft.client.model.ModelRenderer; import net.minecraft.client.model.ModelRenderer;
import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.util.EnumHandSide; import net.minecraft.util.EnumHandSide;
import net.minecraft.util.math.MathHelper; 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) { protected void setLegs(float move, float swing, float ticks, Entity entity) {
if (isFlying(entity)) { if (isFlying()) {
rotateLegsInFlight(move, swing, ticks, entity); rotateLegsInFlight(move, swing, ticks, entity);
} else { } else {
rotateLegsOnGround(move, swing, ticks, entity); 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. * 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) { protected void checkRainboom(Entity entity, float swing) {
rainboom = isFlying(entity) && swing >= 0.9999F; rainboom = isFlying() && swing >= 0.9999F;
}
@Override
public boolean isFlying(Entity entity) {
return (isFlying && metadata.getRace().hasWings()) ||
(entity instanceof EntityLivingBase && ((EntityLivingBase) entity).isElytraFlying());
} }
@Override @Override
public boolean isFlying() { public boolean isFlying() {
return isFlying; return isFlying && metadata.getRace().hasWings();
} }
@Override @Override

View file

@ -3,8 +3,6 @@ package com.minelittlepony.model.capabilities;
import com.minelittlepony.model.BodyPart; import com.minelittlepony.model.BodyPart;
import com.minelittlepony.model.armour.PonyArmor; import com.minelittlepony.model.armour.PonyArmor;
import net.minecraft.entity.Entity;
public interface IModel { public interface IModel {
/** /**
@ -30,11 +28,6 @@ public interface IModel {
*/ */
boolean isCrouching(); 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. * Returns true if the model is flying.
*/ */

View file

@ -7,6 +7,7 @@ import net.minecraft.client.model.ModelBase;
import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.EntityLivingBase;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.Vec3d; import net.minecraft.util.math.Vec3d;
import static com.minelittlepony.model.PonyModelConstants.*; 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 rightWing = new PonyRenderer(this, 22, 0);
private PonyRenderer leftWing = new PonyRenderer(this, 22, 0); private PonyRenderer leftWing = new PonyRenderer(this, 22, 0);
public boolean isCape;
public PonyElytra() { public PonyElytra() {
leftWing .box(-10, 0, 0, 10, 20, 2, 1); leftWing .box(-10, 0, 0, 10, 20, 2, 1);
rightWing.flipX().box( 0, 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); super.setRotationAngles(move, swing, ticks, headYaw, headPitch, scale, entity);
float rotateX = PI / 2; float rotateX = PI / 2;
float rotateY = PI / 8; float rotateY = isCape ? 0 : PI / 8;
float rotateZ = PI / 12; float rotateZ = isCape ? 0 : PI / 12;
float rpY = BODY_RP_Y_NOTSNEAK; float rpY = BODY_RP_Y_NOTSNEAK;
if (entity instanceof EntityLivingBase && ((EntityLivingBase) entity).isElytraFlying()) { if (isCape || entity instanceof EntityLivingBase && ((EntityLivingBase) entity).isElytraFlying()) {
float velY = 1; float velY = 1;
if (entity.motionY < 0) { if (entity.motionY < 0) {
@ -59,8 +62,15 @@ public class PonyElytra extends ModelBase {
velY = 1 - (float) Math.pow(-motion.y, 1.5); velY = 1 - (float) Math.pow(-motion.y, 1.5);
} }
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; rotateX = velY * PI * (2 / 3F) + (1 - velY) * rotateX;
rotateY = velY * (PI / 2) + (1 - velY) * rotateY; rotateY = velY * (PI / 2) + (1 - velY) * rotateY;
}
} else if (entity.isSneaking()) { } else if (entity.isSneaking()) {
rotateX = PI * 1.175F; rotateX = PI * 1.175F;
rotateY = PI / 2; rotateY = PI / 2;

View file

@ -100,7 +100,7 @@ public class Pony {
//noinspection SimplifiableIfStatement //noinspection SimplifiableIfStatement
if (!getRace(false).hasWings()) return false; 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) { public ModelWrapper getModel(boolean ignorePony) {

View file

@ -13,6 +13,7 @@ import net.minecraft.client.renderer.entity.RenderLiving;
import net.minecraft.client.renderer.entity.RenderManager; import net.minecraft.client.renderer.entity.RenderManager;
import net.minecraft.client.renderer.entity.layers.LayerArrow; import net.minecraft.client.renderer.entity.layers.LayerArrow;
import net.minecraft.entity.EntityLiving; import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
@ -53,7 +54,7 @@ public abstract class RenderPonyMob<T extends EntityLiving> extends RenderLiving
@OverridingMethodsMustInvokeSuper @OverridingMethodsMustInvokeSuper
protected void preRenderCallback(T entity, float ticks) { protected void preRenderCallback(T entity, float ticks) {
playerModel.getModel().isSneak = entity.isSneaking(); 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; playerModel.getModel().isSleeping = false;
ResourceLocation loc = getEntityTexture(entity); ResourceLocation loc = getEntityTexture(entity);

View file

@ -1,6 +1,7 @@
package com.minelittlepony.render.layer; package com.minelittlepony.render.layer;
import com.minelittlepony.model.BodyPart; import com.minelittlepony.model.BodyPart;
import com.minelittlepony.model.capabilities.IModelPegasus;
import com.minelittlepony.model.components.PonyElytra; import com.minelittlepony.model.components.PonyElytra;
import net.minecraft.client.entity.AbstractClientPlayer; import net.minecraft.client.entity.AbstractClientPlayer;
@ -37,6 +38,9 @@ public class LayerPonyElytra<T extends EntityLivingBase> extends AbstractPonyLay
GlStateManager.pushMatrix(); GlStateManager.pushMatrix();
GlStateManager.translate(0, 0.25F, 0.125F); GlStateManager.translate(0, 0.25F, 0.125F);
getPlayerModel().transform(BodyPart.BODY); getPlayerModel().transform(BodyPart.BODY);
modelElytra.isCape = getPlayerModel().metadata.getRace().hasWings() && getPlayerModel().isFlying();
modelElytra.setRotationAngles(move, swing, ticks, yaw, head, scale, entity); modelElytra.setRotationAngles(move, swing, ticks, yaw, head, scale, entity);
modelElytra.render(entity, move, swing, ticks, yaw, head, scale); modelElytra.render(entity, move, swing, ticks, yaw, head, scale);