Elytra flying is different from regular flying

This commit is contained in:
Matthew Messinger 2018-07-29 23:49:45 -04:00
parent 21ea56d134
commit 1369665fd6
3 changed files with 20 additions and 3 deletions

View file

@ -35,6 +35,7 @@ public abstract class AbstractPonyModel extends ModelPlayer implements IModel {
private boolean isSleeping;
private boolean isFlying;
private boolean isElytraFlying;
private boolean isSwimming;
private boolean headGear;
@ -72,7 +73,8 @@ 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 = canFly() && Math.sqrt(entity.motionX * entity.motionX + entity.motionZ * entity.motionZ) > 0.4F;
rainboom = canFly() || isElytraFlying();
rainboom &= Math.sqrt(entity.motionX * entity.motionX + entity.motionZ * entity.motionZ) > 0.4F;
}
public void updateLivingState(EntityLivingBase entity, Pony pony) {
@ -80,6 +82,7 @@ public abstract class AbstractPonyModel extends ModelPlayer implements IModel {
isSneak = entity.isSneaking();
isSleeping = entity.isPlayerSleeping();
isFlying = pony.isPegasusFlying(entity);
isElytraFlying = entity.isElytraFlying();
isSwimming = pony.isSwimming(entity);
headGear = pony.isWearingHeadgear(entity);
}
@ -224,7 +227,7 @@ public abstract class AbstractPonyModel extends ModelPlayer implements IModel {
protected void rotateLegs(float move, float swing, float ticks, Entity entity) {
if (isSwimming()) {
rotateLegsSwimming(move, swing, ticks, entity);
} else if (isFlying()) {
} else if (isGoingFast()) {
rotateLegsInFlight(move, swing, ticks, entity);
} else {
rotateLegsOnGround(move, swing, ticks, entity);
@ -692,6 +695,11 @@ public abstract class AbstractPonyModel extends ModelPlayer implements IModel {
return isFlying && canFly();
}
@Override
public boolean isElytraFlying() {
return isElytraFlying;
}
@Override
public boolean isSleeping() {
return isSleeping;
@ -849,6 +857,8 @@ public abstract class AbstractPonyModel extends ModelPlayer implements IModel {
if (model instanceof AbstractPonyModel) {
AbstractPonyModel pony = (AbstractPonyModel) model;
isFlying = pony.isFlying;
isElytraFlying = pony.isElytraFlying;
isSwimming = pony.isSwimming;
isSleeping = pony.isSleeping;
metadata = pony.metadata;
motionPitch = pony.motionPitch;

View file

@ -39,6 +39,12 @@ public interface IModel extends ICapitated {
*/
boolean isFlying();
/**
* Returns true if the model is elytra flying. Elytra flying is different
* from regular flying in that there are actual "wings" involved.
*/
boolean isElytraFlying();
/**
* Returns true if this model is lying on a bed or bed-like object.
*/

View file

@ -6,11 +6,12 @@ import static com.minelittlepony.model.PonyModelConstants.ROTATE_270;
import net.minecraft.util.math.MathHelper;
public interface IModelPegasus extends IModel {
/**
* Returns true if the wings are spread.
*/
default boolean wingsAreOpen() {
return isSwimming() || isFlying() || isCrouching();
return (isSwimming() || isFlying() || isCrouching()) && !isElytraFlying();
}