mirror of
https://github.com/MineLittlePony/MineLittlePony.git
synced 2024-11-22 04:27:59 +01:00
- 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:
parent
e67b013424
commit
a2855237f2
15 changed files with 114 additions and 25 deletions
|
@ -15,6 +15,8 @@ import com.minelittlepony.render.model.PonyRenderer;
|
|||
import com.minelittlepony.util.math.MathUtil;
|
||||
import com.minelittlepony.util.render.AbstractBoxRenderer;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.client.model.ModelBase;
|
||||
import net.minecraft.client.model.ModelPlayer;
|
||||
import net.minecraft.client.model.ModelRenderer;
|
||||
|
@ -38,11 +40,12 @@ public abstract class AbstractPonyModel extends ModelPlayer implements IModel, P
|
|||
public boolean isFlying;
|
||||
public boolean isElytraFlying;
|
||||
public boolean isSwimming;
|
||||
public boolean isCrouching;
|
||||
public boolean isRidingInteractive;
|
||||
public boolean headGear;
|
||||
|
||||
/**
|
||||
* Associcated pony data.
|
||||
* Associated pony data.
|
||||
*/
|
||||
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) {
|
||||
isChild = entity.isChild();
|
||||
isSneak = entity.isSneaking();
|
||||
isCrouching = pony.isCrouching(entity);
|
||||
isSleeping = entity.isPlayerSleeping();
|
||||
isFlying = pony.isFlying(entity);
|
||||
isElytraFlying = entity.isElytraFlying();
|
||||
|
@ -267,6 +271,22 @@ public abstract class AbstractPonyModel extends ModelPlayer implements IModel, P
|
|||
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.
|
||||
*/
|
||||
|
@ -743,7 +763,7 @@ public abstract class AbstractPonyModel extends ModelPlayer implements IModel, P
|
|||
|
||||
@Override
|
||||
public boolean isCrouching() {
|
||||
return !rainboom && !isSwimming && isSneak && !isFlying;
|
||||
return isCrouching;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -788,7 +808,7 @@ public abstract class AbstractPonyModel extends ModelPlayer implements IModel, P
|
|||
|
||||
@Override
|
||||
public PonySize getSize() {
|
||||
return isChild ? PonySize.FOAL : metadata.getSize();
|
||||
return isChild ? PonySize.FOAL : getMetadata().getSize();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -927,6 +947,7 @@ public abstract class AbstractPonyModel extends ModelPlayer implements IModel, P
|
|||
if (model instanceof AbstractPonyModel) {
|
||||
AbstractPonyModel pony = (AbstractPonyModel) model;
|
||||
isFlying = pony.isFlying;
|
||||
isCrouching = pony.isCrouching;
|
||||
isElytraFlying = pony.isElytraFlying;
|
||||
isSwimming = pony.isSwimming;
|
||||
isSleeping = pony.isSleeping;
|
||||
|
|
|
@ -2,6 +2,8 @@ package com.minelittlepony.model.capabilities;
|
|||
|
||||
import net.minecraft.client.model.ModelRenderer;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public interface ICapitated {
|
||||
/**
|
||||
* Gets the head of this capitated object.
|
||||
|
@ -9,7 +11,13 @@ public interface ICapitated {
|
|||
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();
|
||||
|
||||
|
|
|
@ -20,6 +20,10 @@ public interface IModel extends ICapitated {
|
|||
*/
|
||||
void transform(BodyPart part);
|
||||
|
||||
void setPitch(float pitch);
|
||||
|
||||
float getPitch();
|
||||
|
||||
/**
|
||||
* Gets the active scaling profile used to lay out this model's parts.
|
||||
*/
|
||||
|
|
|
@ -5,6 +5,8 @@ import com.minelittlepony.pony.data.IPonyData;
|
|||
import com.minelittlepony.pony.data.PonyData;
|
||||
import com.minelittlepony.render.model.PonyRenderer;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.client.model.ModelHumanoidHead;
|
||||
import net.minecraft.client.model.ModelRenderer;
|
||||
import net.minecraft.entity.Entity;
|
||||
|
@ -39,6 +41,12 @@ public class ModelPonyHead extends ModelHumanoidHead implements ICapitated {
|
|||
return skeletonHead;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public ModelRenderer getBody() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasHeadGear() {
|
||||
return false;
|
||||
|
@ -58,5 +66,4 @@ public class ModelPonyHead extends ModelHumanoidHead implements ICapitated {
|
|||
horn.renderPart(scale, entity.getUniqueID());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -15,6 +15,9 @@ import static com.minelittlepony.model.PonyModelConstants.*;
|
|||
* Modified from ModelElytra.
|
||||
*/
|
||||
public class PonyElytra extends ModelBase {
|
||||
|
||||
public boolean isSneaking;
|
||||
|
||||
private PonyRenderer rightWing = 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;
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
rotateX = velY * PI * (2 / 3F) + (1 - velY) * rotateX;
|
||||
rotateY = velY * (PI / 2) + (1 - velY) * rotateY;
|
||||
} else if (entity.isSneaking()) {
|
||||
} else if (isSneaking) {
|
||||
rotateX = PI * 1.175F;
|
||||
rotateY = PI / 2;
|
||||
rotateZ = PI / 4;
|
||||
|
|
|
@ -28,7 +28,7 @@ public abstract class AbstractGear extends ModelBase implements IGear, PonyModel
|
|||
case NECK: return model.neck;
|
||||
case TAIL:
|
||||
case LEGS:
|
||||
case BODY: return model.bipedBody;
|
||||
case BODY: return model.getBody();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -25,6 +25,26 @@ public interface IPony {
|
|||
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.
|
||||
* True if the entity is off the ground.
|
||||
|
@ -35,7 +55,7 @@ public interface IPony {
|
|||
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)
|
||||
* and is not standing on the (river) bed or riding a ladder or any other entity.
|
||||
*/
|
||||
|
|
|
@ -111,6 +111,23 @@ public class Pony extends Touchable<Pony> implements IPony {
|
|||
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
|
||||
public boolean isFlying(EntityLivingBase entity) {
|
||||
return !(entity.onGround
|
||||
|
|
|
@ -11,6 +11,7 @@ import com.google.common.collect.Lists;
|
|||
import com.minelittlepony.ducks.IRenderPony;
|
||||
import com.minelittlepony.model.AbstractPonyModel;
|
||||
import com.minelittlepony.model.BodyPart;
|
||||
import com.minelittlepony.model.capabilities.IModel;
|
||||
import com.minelittlepony.model.gear.ChristmasHat;
|
||||
import com.minelittlepony.model.gear.IGear;
|
||||
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);
|
||||
|
||||
ResourceLocation texture = gear.getTexture(entity);
|
||||
|
|
|
@ -33,7 +33,7 @@ public class LayerPonyCape extends AbstractPonyLayer<AbstractClientPlayer> {
|
|||
|
||||
model.transform(BodyPart.BODY);
|
||||
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 capeY = player.prevChasingPosY + (player.chasingPosY - player.prevChasingPosY) * scale - (player.prevPosY + (player.posY - player.prevPosY) * scale);
|
||||
|
|
|
@ -20,7 +20,8 @@ import javax.annotation.Nonnull;
|
|||
public class LayerPonyElytra<T extends EntityLivingBase> extends AbstractPonyLayer<T> {
|
||||
|
||||
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) {
|
||||
super(rp);
|
||||
|
@ -38,11 +39,17 @@ public class LayerPonyElytra<T extends EntityLivingBase> extends AbstractPonyLay
|
|||
GlStateManager.pushMatrix();
|
||||
preRenderCallback();
|
||||
|
||||
getElytraModel().setRotationAngles(move, swing, ticks, yaw, head, scale, entity);
|
||||
getElytraModel().render(entity, move, swing, ticks, yaw, head, scale);
|
||||
ModelBase elytra = getElytraModel();
|
||||
|
||||
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()) {
|
||||
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();
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package com.minelittlepony.transform;
|
||||
|
||||
import com.minelittlepony.model.AbstractPonyModel;
|
||||
import com.minelittlepony.model.capabilities.IModel;
|
||||
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
|
||||
|
@ -14,5 +14,5 @@ public interface PonyPosture<T extends EntityLivingBase> {
|
|||
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);
|
||||
}
|
||||
|
|
|
@ -1,13 +1,14 @@
|
|||
package com.minelittlepony.transform;
|
||||
|
||||
import com.minelittlepony.model.AbstractPonyModel;
|
||||
import com.minelittlepony.model.capabilities.IModel;
|
||||
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
|
||||
public class PostureElytra implements PonyPosture<EntityLivingBase> {
|
||||
@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.translate(0, entity.isSneaking() ? 0.2F : -1, 0);
|
||||
}
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
package com.minelittlepony.transform;
|
||||
|
||||
import com.minelittlepony.model.AbstractPonyModel;
|
||||
import com.minelittlepony.model.capabilities.IModel;
|
||||
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
|
||||
public class PostureFalling implements PonyPosture<EntityLivingBase> {
|
||||
@Override
|
||||
public void transform(AbstractPonyModel model, EntityLivingBase entity, double motionX, double motionY, double motionZ, float yaw, float ticks) {
|
||||
model.motionPitch = 0;
|
||||
public void transform(IModel model, EntityLivingBase entity, double motionX, double motionY, double motionZ, float yaw, float ticks) {
|
||||
model.setPitch(0);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
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.renderer.GlStateManager;
|
||||
|
@ -13,10 +13,10 @@ public class PostureFlight extends MotionCompositor implements PonyPosture<Abstr
|
|||
}
|
||||
|
||||
@Override
|
||||
public void transform(AbstractPonyModel model, AbstractClientPlayer player, double motionX, double motionY, double motionZ, float yaw, float ticks) {
|
||||
model.motionPitch = (float) calculateIncline(player, motionX, motionY, motionZ);
|
||||
public void transform(IModel model, AbstractClientPlayer player, double motionX, double motionY, double motionZ, float yaw, float ticks) {
|
||||
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);
|
||||
|
||||
|
|
Loading…
Reference in a new issue