- Fixed Elytra not following the same rules for crouching as the pony body

- Various changes away from using AbstractPonyModel directly
This commit is contained in:
Sollace 2019-03-22 22:09:06 +02:00
parent e67b013424
commit a2855237f2
15 changed files with 114 additions and 25 deletions

View file

@ -15,6 +15,8 @@ import com.minelittlepony.render.model.PonyRenderer;
import com.minelittlepony.util.math.MathUtil; import com.minelittlepony.util.math.MathUtil;
import com.minelittlepony.util.render.AbstractBoxRenderer; import com.minelittlepony.util.render.AbstractBoxRenderer;
import javax.annotation.Nullable;
import net.minecraft.client.model.ModelBase; import net.minecraft.client.model.ModelBase;
import net.minecraft.client.model.ModelPlayer; import net.minecraft.client.model.ModelPlayer;
import net.minecraft.client.model.ModelRenderer; import net.minecraft.client.model.ModelRenderer;
@ -38,11 +40,12 @@ public abstract class AbstractPonyModel extends ModelPlayer implements IModel, P
public boolean isFlying; public boolean isFlying;
public boolean isElytraFlying; public boolean isElytraFlying;
public boolean isSwimming; public boolean isSwimming;
public boolean isCrouching;
public boolean isRidingInteractive; public boolean isRidingInteractive;
public boolean headGear; public boolean headGear;
/** /**
* Associcated pony data. * Associated pony data.
*/ */
public IPonyData metadata = new PonyData(); public IPonyData metadata = new PonyData();
@ -90,6 +93,7 @@ public abstract class AbstractPonyModel extends ModelPlayer implements IModel, P
public void updateLivingState(EntityLivingBase entity, IPony pony) { public void updateLivingState(EntityLivingBase entity, IPony pony) {
isChild = entity.isChild(); isChild = entity.isChild();
isSneak = entity.isSneaking(); isSneak = entity.isSneaking();
isCrouching = pony.isCrouching(entity);
isSleeping = entity.isPlayerSleeping(); isSleeping = entity.isPlayerSleeping();
isFlying = pony.isFlying(entity); isFlying = pony.isFlying(entity);
isElytraFlying = entity.isElytraFlying(); isElytraFlying = entity.isElytraFlying();
@ -267,6 +271,22 @@ public abstract class AbstractPonyModel extends ModelPlayer implements IModel, P
return bipedHead; return bipedHead;
} }
@Nullable
@Override
public ModelRenderer getBody() {
return bipedBody;
}
@Override
public void setPitch(float pitch) {
motionPitch = pitch;
}
@Override
public float getPitch() {
return motionPitch;
}
/** /**
* Sets the head rotation point. * Sets the head rotation point.
*/ */
@ -743,7 +763,7 @@ public abstract class AbstractPonyModel extends ModelPlayer implements IModel, P
@Override @Override
public boolean isCrouching() { public boolean isCrouching() {
return !rainboom && !isSwimming && isSneak && !isFlying; return isCrouching;
} }
@Override @Override
@ -788,7 +808,7 @@ public abstract class AbstractPonyModel extends ModelPlayer implements IModel, P
@Override @Override
public PonySize getSize() { public PonySize getSize() {
return isChild ? PonySize.FOAL : metadata.getSize(); return isChild ? PonySize.FOAL : getMetadata().getSize();
} }
@Override @Override
@ -927,6 +947,7 @@ public abstract class AbstractPonyModel extends ModelPlayer implements IModel, P
if (model instanceof AbstractPonyModel) { if (model instanceof AbstractPonyModel) {
AbstractPonyModel pony = (AbstractPonyModel) model; AbstractPonyModel pony = (AbstractPonyModel) model;
isFlying = pony.isFlying; isFlying = pony.isFlying;
isCrouching = pony.isCrouching;
isElytraFlying = pony.isElytraFlying; isElytraFlying = pony.isElytraFlying;
isSwimming = pony.isSwimming; isSwimming = pony.isSwimming;
isSleeping = pony.isSleeping; isSleeping = pony.isSleeping;

View file

@ -2,6 +2,8 @@ package com.minelittlepony.model.capabilities;
import net.minecraft.client.model.ModelRenderer; import net.minecraft.client.model.ModelRenderer;
import javax.annotation.Nullable;
public interface ICapitated { public interface ICapitated {
/** /**
* Gets the head of this capitated object. * Gets the head of this capitated object.
@ -9,7 +11,13 @@ public interface ICapitated {
ModelRenderer getHead(); ModelRenderer getHead();
/** /**
* Returns true if we're wearing any uconventional headgear (ie. a Pumpkin) * Gets the main body
*/
@Nullable
ModelRenderer getBody();
/**
* Returns true if we're wearing any unconventional headgear (ie. a Pumpkin)
*/ */
boolean hasHeadGear(); boolean hasHeadGear();

View file

@ -20,6 +20,10 @@ public interface IModel extends ICapitated {
*/ */
void transform(BodyPart part); void transform(BodyPart part);
void setPitch(float pitch);
float getPitch();
/** /**
* Gets the active scaling profile used to lay out this model's parts. * Gets the active scaling profile used to lay out this model's parts.
*/ */

View file

@ -5,6 +5,8 @@ import com.minelittlepony.pony.data.IPonyData;
import com.minelittlepony.pony.data.PonyData; import com.minelittlepony.pony.data.PonyData;
import com.minelittlepony.render.model.PonyRenderer; import com.minelittlepony.render.model.PonyRenderer;
import javax.annotation.Nullable;
import net.minecraft.client.model.ModelHumanoidHead; import net.minecraft.client.model.ModelHumanoidHead;
import net.minecraft.client.model.ModelRenderer; import net.minecraft.client.model.ModelRenderer;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
@ -39,6 +41,12 @@ public class ModelPonyHead extends ModelHumanoidHead implements ICapitated {
return skeletonHead; return skeletonHead;
} }
@Nullable
@Override
public ModelRenderer getBody() {
return null;
}
@Override @Override
public boolean hasHeadGear() { public boolean hasHeadGear() {
return false; return false;
@ -58,5 +66,4 @@ public class ModelPonyHead extends ModelHumanoidHead implements ICapitated {
horn.renderPart(scale, entity.getUniqueID()); horn.renderPart(scale, entity.getUniqueID());
} }
} }
} }

View file

@ -15,6 +15,9 @@ import static com.minelittlepony.model.PonyModelConstants.*;
* Modified from ModelElytra. * Modified from ModelElytra.
*/ */
public class PonyElytra extends ModelBase { public class PonyElytra extends ModelBase {
public boolean isSneaking;
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);
@ -55,13 +58,13 @@ public class PonyElytra extends ModelBase {
float velY = 1; float velY = 1;
if (entity.motionY < 0) { if (entity.motionY < 0) {
Vec3d motion = (new Vec3d(entity.motionX, entity.motionY, entity.motionZ)).normalize(); Vec3d motion = new Vec3d(entity.motionX, entity.motionY, entity.motionZ).normalize();
velY = 1 - (float) Math.pow(-motion.y, 1.5); velY = 1 - (float) Math.pow(-motion.y, 1.5);
} }
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 (isSneaking) {
rotateX = PI * 1.175F; rotateX = PI * 1.175F;
rotateY = PI / 2; rotateY = PI / 2;
rotateZ = PI / 4; rotateZ = PI / 4;

View file

@ -28,7 +28,7 @@ public abstract class AbstractGear extends ModelBase implements IGear, PonyModel
case NECK: return model.neck; case NECK: return model.neck;
case TAIL: case TAIL:
case LEGS: case LEGS:
case BODY: return model.bipedBody; case BODY: return model.getBody();
} }
} }

View file

@ -25,6 +25,26 @@ public interface IPony {
return MineLittlePony.getInstance().getManager().getPony(texture); return MineLittlePony.getInstance().getManager().getPony(texture);
} }
/**
* Returns true if this pony has wings and the will to use them.
*/
default boolean canFly() {
return getMetadata().getRace().hasWings();
}
/**
* Checks the required conditions for whether the given entity can perform a sonic rainboom.
*/
boolean isPerformingRainboom(EntityLivingBase entity);
/**
* Unlike sneaking, crouching is a more specific animation parameter that controls whether the player is visible
* nose to the ground, crouching the sand.
*
* You cannot crouch whilst flying or swimming.
*/
boolean isCrouching(EntityLivingBase entity);
/** /**
* Returns true if the provided entity is flying like a pegasus. * Returns true if the provided entity is flying like a pegasus.
* True if the entity is off the ground. * True if the entity is off the ground.
@ -35,7 +55,7 @@ public interface IPony {
boolean isFlying(EntityLivingBase entity); boolean isFlying(EntityLivingBase entity);
/** /**
* Returns true if the provided antity is actively wimming. * Returns true if the provided entity is actively swimming.
* That is, it should be fully submerged (isFullySubmerged returns true) * That is, it should be fully submerged (isFullySubmerged returns true)
* and is not standing on the (river) bed or riding a ladder or any other entity. * and is not standing on the (river) bed or riding a ladder or any other entity.
*/ */

View file

@ -111,6 +111,23 @@ public class Pony extends Touchable<Pony> implements IPony {
return PonyData.parse(bufferedimage); return PonyData.parse(bufferedimage);
} }
@Override
public boolean isPerformingRainboom(EntityLivingBase entity) {
double zMotion = Math.sqrt(entity.motionX * entity.motionX + entity.motionZ * entity.motionZ);
return (isFlying(entity) && canFly()) || entity.isElytraFlying() & zMotion > 0.4F;
}
@Override
public boolean isCrouching(EntityLivingBase entity) {
boolean isSneak = entity.isSneaking();
boolean isFlying = isFlying(entity);
boolean isSwimming = isSwimming(entity);
return !isPerformingRainboom(entity) && !isSwimming && isSneak && !isFlying;
}
@Override @Override
public boolean isFlying(EntityLivingBase entity) { public boolean isFlying(EntityLivingBase entity) {
return !(entity.onGround return !(entity.onGround

View file

@ -11,6 +11,7 @@ import com.google.common.collect.Lists;
import com.minelittlepony.ducks.IRenderPony; import com.minelittlepony.ducks.IRenderPony;
import com.minelittlepony.model.AbstractPonyModel; import com.minelittlepony.model.AbstractPonyModel;
import com.minelittlepony.model.BodyPart; import com.minelittlepony.model.BodyPart;
import com.minelittlepony.model.capabilities.IModel;
import com.minelittlepony.model.gear.ChristmasHat; import com.minelittlepony.model.gear.ChristmasHat;
import com.minelittlepony.model.gear.IGear; import com.minelittlepony.model.gear.IGear;
import com.minelittlepony.model.gear.IStackable; import com.minelittlepony.model.gear.IStackable;
@ -72,7 +73,7 @@ public class LayerGear<T extends EntityLivingBase> extends AbstractPonyLayer<T>
} }
} }
private void renderGear(AbstractPonyModel model, T entity, IGear gear, float move, float swing, float scale, float ticks) { private void renderGear(IModel model, T entity, IGear gear, float move, float swing, float scale, float ticks) {
GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS); GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS);
ResourceLocation texture = gear.getTexture(entity); ResourceLocation texture = gear.getTexture(entity);

View file

@ -33,7 +33,7 @@ public class LayerPonyCape extends AbstractPonyLayer<AbstractClientPlayer> {
model.transform(BodyPart.BODY); model.transform(BodyPart.BODY);
translate(0, 0.24F, 0); translate(0, 0.24F, 0);
model.bipedBody.postRender(scale); model.getBody().postRender(scale);
double capeX = player.prevChasingPosX + (player.chasingPosX - player.prevChasingPosX) * scale - (player.prevPosX + (player.posX - player.prevPosX) * scale); double capeX = player.prevChasingPosX + (player.chasingPosX - player.prevChasingPosX) * scale - (player.prevPosX + (player.posX - player.prevPosX) * scale);
double capeY = player.prevChasingPosY + (player.chasingPosY - player.prevChasingPosY) * scale - (player.prevPosY + (player.posY - player.prevPosY) * scale); double capeY = player.prevChasingPosY + (player.chasingPosY - player.prevChasingPosY) * scale - (player.prevPosY + (player.posY - player.prevPosY) * scale);

View file

@ -20,7 +20,8 @@ import javax.annotation.Nonnull;
public class LayerPonyElytra<T extends EntityLivingBase> extends AbstractPonyLayer<T> { public class LayerPonyElytra<T extends EntityLivingBase> extends AbstractPonyLayer<T> {
private static final ResourceLocation TEXTURE_ELYTRA = new ResourceLocation("textures/entity/elytra.png"); private static final ResourceLocation TEXTURE_ELYTRA = new ResourceLocation("textures/entity/elytra.png");
private PonyElytra modelElytra = new PonyElytra();
private final PonyElytra modelElytra = new PonyElytra();
public LayerPonyElytra(RenderLivingBase<T> rp) { public LayerPonyElytra(RenderLivingBase<T> rp) {
super(rp); super(rp);
@ -38,11 +39,17 @@ public class LayerPonyElytra<T extends EntityLivingBase> extends AbstractPonyLay
GlStateManager.pushMatrix(); GlStateManager.pushMatrix();
preRenderCallback(); preRenderCallback();
getElytraModel().setRotationAngles(move, swing, ticks, yaw, head, scale, entity); ModelBase elytra = getElytraModel();
getElytraModel().render(entity, move, swing, ticks, yaw, head, scale);
if (elytra instanceof PonyElytra) {
((PonyElytra)elytra).isSneaking = getPonyRenderer().getEntityPony(entity).isCrouching(entity);
}
elytra.setRotationAngles(move, swing, ticks, yaw, head, scale, entity);
elytra.render(entity, move, swing, ticks, yaw, head, scale);
if (itemstack.isItemEnchanted()) { if (itemstack.isItemEnchanted()) {
LayerArmorBase.renderEnchantedGlint(getRenderer(), entity, getElytraModel(), move, swing, partialTicks, ticks, yaw, head, scale); LayerArmorBase.renderEnchantedGlint(getRenderer(), entity, elytra, move, swing, partialTicks, ticks, yaw, head, scale);
} }
GlStateManager.popMatrix(); GlStateManager.popMatrix();

View file

@ -1,6 +1,6 @@
package com.minelittlepony.transform; package com.minelittlepony.transform;
import com.minelittlepony.model.AbstractPonyModel; import com.minelittlepony.model.capabilities.IModel;
import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.EntityLivingBase;
@ -14,5 +14,5 @@ public interface PonyPosture<T extends EntityLivingBase> {
return true; return true;
} }
void transform(AbstractPonyModel model, T entity, double motionX, double motionY, double motionZ, float yaw, float ticks); void transform(IModel model, T entity, double motionX, double motionY, double motionZ, float yaw, float ticks);
} }

View file

@ -1,13 +1,14 @@
package com.minelittlepony.transform; package com.minelittlepony.transform;
import com.minelittlepony.model.AbstractPonyModel; import com.minelittlepony.model.AbstractPonyModel;
import com.minelittlepony.model.capabilities.IModel;
import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.EntityLivingBase;
public class PostureElytra implements PonyPosture<EntityLivingBase> { public class PostureElytra implements PonyPosture<EntityLivingBase> {
@Override @Override
public void transform(AbstractPonyModel model, EntityLivingBase entity, double motionX, double motionY, double motionZ, float yaw, float ticks) { public void transform(IModel model, EntityLivingBase entity, double motionX, double motionY, double motionZ, float yaw, float ticks) {
GlStateManager.rotate(90, 1, 0, 0); GlStateManager.rotate(90, 1, 0, 0);
GlStateManager.translate(0, entity.isSneaking() ? 0.2F : -1, 0); GlStateManager.translate(0, entity.isSneaking() ? 0.2F : -1, 0);
} }

View file

@ -1,12 +1,12 @@
package com.minelittlepony.transform; package com.minelittlepony.transform;
import com.minelittlepony.model.AbstractPonyModel; import com.minelittlepony.model.capabilities.IModel;
import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.EntityLivingBase;
public class PostureFalling implements PonyPosture<EntityLivingBase> { public class PostureFalling implements PonyPosture<EntityLivingBase> {
@Override @Override
public void transform(AbstractPonyModel model, EntityLivingBase entity, double motionX, double motionY, double motionZ, float yaw, float ticks) { public void transform(IModel model, EntityLivingBase entity, double motionX, double motionY, double motionZ, float yaw, float ticks) {
model.motionPitch = 0; model.setPitch(0);
} }
} }

View file

@ -1,6 +1,6 @@
package com.minelittlepony.transform; package com.minelittlepony.transform;
import com.minelittlepony.model.AbstractPonyModel; import com.minelittlepony.model.capabilities.IModel;
import net.minecraft.client.entity.AbstractClientPlayer; import net.minecraft.client.entity.AbstractClientPlayer;
import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.GlStateManager;
@ -13,10 +13,10 @@ public class PostureFlight extends MotionCompositor implements PonyPosture<Abstr
} }
@Override @Override
public void transform(AbstractPonyModel model, AbstractClientPlayer player, double motionX, double motionY, double motionZ, float yaw, float ticks) { public void transform(IModel model, AbstractClientPlayer player, double motionX, double motionY, double motionZ, float yaw, float ticks) {
model.motionPitch = (float) calculateIncline(player, motionX, motionY, motionZ); model.setPitch((float) calculateIncline(player, motionX, motionY, motionZ));
GlStateManager.rotate(model.motionPitch, 1, 0, 0); GlStateManager.rotate(model.getPitch(), 1, 0, 0);
float roll = (float)calculateRoll(player, motionX, motionY, motionZ); float roll = (float)calculateRoll(player, motionX, motionY, motionZ);