Simplify model classes/interfaces by moving all these properties to a separate class

This commit is contained in:
Sollace 2019-06-24 11:25:39 +02:00
parent e6ace54fb4
commit a26e26030e
44 changed files with 452 additions and 635 deletions

View file

@ -6,12 +6,12 @@ import java.util.function.Function;
import com.google.common.collect.Maps;
import com.minelittlepony.client.gui.hdskins.DummyPony;
import com.minelittlepony.client.gui.hdskins.RenderDummyPony;
import com.minelittlepony.client.model.IPonyModel;
import com.minelittlepony.client.model.races.PlayerModels;
import com.minelittlepony.client.render.LevitatingItemRenderer;
import com.minelittlepony.client.render.IPonyRender;
import com.minelittlepony.client.render.entities.MobRenderers;
import com.minelittlepony.client.render.entities.player.RenderPonyPlayer;
import com.minelittlepony.model.IPonyModel;
import javax.annotation.Nullable;

View file

@ -4,7 +4,6 @@ import com.minelittlepony.client.model.armour.ModelPonyArmour;
import com.minelittlepony.client.model.armour.ArmourWrapper;
import com.minelittlepony.client.model.components.PonySnout;
import com.minelittlepony.client.model.components.PonyTail;
import com.minelittlepony.client.pony.PonyData;
import com.minelittlepony.client.transform.PonyTransformation;
import com.minelittlepony.client.util.render.AbstractRenderer;
import com.minelittlepony.client.util.render.PonyRenderer;
@ -12,20 +11,14 @@ import com.minelittlepony.client.util.render.plane.PlaneRenderer;
import com.minelittlepony.model.BodyPart;
import com.minelittlepony.model.IPart;
import com.minelittlepony.model.armour.IEquestrianArmour;
import com.minelittlepony.pony.IPony;
import com.minelittlepony.pony.IPonyData;
import com.minelittlepony.pony.meta.Size;
import com.minelittlepony.util.math.MathUtil;
import net.minecraft.client.model.Cuboid;
import net.minecraft.client.render.entity.model.BipedEntityModel;
import net.minecraft.entity.Entity;
import net.minecraft.entity.LivingEntity;
import net.minecraft.util.AbsoluteHand;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.Vec3d;
import java.util.UUID;
import java.util.function.Consumer;
import static com.mojang.blaze3d.platform.GlStateManager.*;
@ -34,38 +27,11 @@ import static com.mojang.blaze3d.platform.GlStateManager.*;
*/
public abstract class AbstractPonyModel<T extends LivingEntity> extends ClientPonyModel<T> {
public boolean isSleeping;
public boolean isFlying;
public boolean isElytraFlying;
public boolean isSwimming;
public boolean isCrouching;
public boolean isRidingInteractive;
public boolean headGear;
protected PlaneRenderer upperTorso;
protected PlaneRenderer neck;
/**
* Associated pony data.
*/
private IPonyData metadata = new PonyData();
/**
* Vertical pitch whilst flying.
*/
public float motionPitch;
/**
* Flag indicating that this model is performing a rainboom (flight).
*/
protected boolean rainboom;
protected double motionLerp;
public PlaneRenderer upperTorso;
public PlaneRenderer neck;
public IPart tail;
public PonySnout snout;
public UUID interpolatorId;
protected IPart tail;
protected PonySnout snout;
public AbstractPonyModel(boolean arms) {
super(0, arms);
@ -76,67 +42,37 @@ public abstract class AbstractPonyModel<T extends LivingEntity> extends ClientPo
return new ArmourWrapper<>(new ModelPonyArmour<>(), new ModelPonyArmour<>());
}
/**
* Checks flying and speed conditions and sets rainboom to true if we're a species with wings and is going faaast.
*/
private void checkRainboom(T entity, float swing) {
Vec3d motion = entity.getVelocity();
double zMotion = Math.sqrt(motion.x * motion.x + motion.z * motion.z);
rainboom = (isFlying() && canFly()) || isElytraFlying();
rainboom &= zMotion > 0.4F;
motionLerp = MathUtil.clampLimit(zMotion * 30, 1);
}
@Override
public void updateLivingState(T entity, IPony pony) {
isChild = entity.isBaby();
isSneaking = entity.isSneaking();
isCrouching = pony.isCrouching(entity);
isSleeping = entity.isSleeping();
isFlying = pony.isFlying(entity);
isElytraFlying = entity.isFallFlying();
isSwimming = pony.isSwimming(entity);
headGear = pony.isWearingHeadgear(entity);
isRidingInteractive = pony.isRidingInteractive(entity);
interpolatorId = entity.getUuid();
}
/**
* Sets the model's various rotation angles.
*
* @param move Entity motion parameter - i.e. velocity in no specific direction used in bipeds to calculate step amount.
* @param move Entity motion parameter
* i.e. velocity in no specific direction used in bipeds to calculate step amount.
* @param swing Degree to which each 'limb' swings.
* @param ticks Total whole and partial ticks since the entity's existance. Used in animations together with {@code swing} and {@code move}.
* @param ticks Total whole and partial ticks since the entity's existence.
* Used in animations together with {@code swing} and {@code move}.
* @param headYaw Horizontal head motion in radians.
* @param headPitch Vertical head motion in radians.
* @param scale Scaling factor used to render this model. Determined by the return value of {@link RenderLivingBase.prepareScale}. Usually {@code 0.0625F}.
* @param scale Scaling factor used to render this model.
* Determined by the return value of {@link RenderLivingBase.prepareScale}.
* Usually {@code 0.0625F}.
* @param entity The entity we're being called for.
*/
@Override
public void setAngles(T entity, float move, float swing, float ticks, float headYaw, float headPitch, float scale) {
checkRainboom(entity, swing);
attributes.checkRainboom(entity, swing, canFly());
super.setAngles(entity, move, swing, ticks, headYaw, headPitch, scale);
float headRotateAngleY = isSleeping() ? (Math.abs(entity.getUuid().getMostSignificantBits()) % 2.8F) - 1.9F : headYaw / 57.29578F;
float headRotateAngleX = isSleeping() ? 0.1f : headPitch / 57.29578F;
headRotateAngleX = Math.min(headRotateAngleX, (float) (0.5f - Math.toRadians(motionPitch)));
headRotateAngleX = Math.max(headRotateAngleX, (float) (-1.25f - Math.toRadians(motionPitch)));
updateHeadRotation(headRotateAngleX, headRotateAngleY);
updateHeadRotation(headYaw, headPitch);
shakeBody(move, swing, getWobbleAmount(), ticks);
rotateLegs(move, swing, ticks, entity);
if (!isSwimming() && !rainboom) {
if (!attributes.isSwimming && !attributes.isGoingFast) {
holdItem(swing);
}
swingItem(entity);
if (isCrouching()) {
if (attributes.isCrouching) {
ponyCrouch();
} else if (isRiding) {
ponyRide();
@ -145,27 +81,17 @@ public abstract class AbstractPonyModel<T extends LivingEntity> extends ClientPo
rightLeg.rotationPointY = FRONT_LEG_RP_Y_NOTSNEAK;
leftLeg.rotationPointY = FRONT_LEG_RP_Y_NOTSNEAK;
swingArms(ticks);
setHead(0, 0, 0);
animateBreathing(ticks);
head.setRotationPoint(0, 0, 0);
}
if (isSleeping) {
if (attributes.isSleeping) {
ponySleep();
}
animateWears();
snout.setGender(metadata.getGender());
}
@Override
public float getWobbleAmount() {
if (getSwingAmount() <= 0) {
return 0;
}
return MathHelper.sin(MathHelper.sqrt(getSwingAmount()) * PI * 2) * 0.04F;
snout.setGender(getMetadata().getGender());
}
/**
@ -173,7 +99,7 @@ public abstract class AbstractPonyModel<T extends LivingEntity> extends ClientPo
*/
protected void ponyCrouch() {
adjustBody(BODY_ROT_X_SNEAK, BODY_RP_Y_SNEAK, BODY_RP_Z_SNEAK);
setHead(0, 6, -2);
head.setRotationPoint(0, 6, -2);
rightArm.pitch -= LEG_ROT_X_SNEAK_ADJ;
leftArm.pitch -= LEG_ROT_X_SNEAK_ADJ;
@ -189,7 +115,7 @@ public abstract class AbstractPonyModel<T extends LivingEntity> extends ClientPo
rightLeg.pitch = ROTATE_90;
leftLeg.pitch = ROTATE_90;
setHead(1, 2, isSneaking ? -1 : 1);
head.setRotationPoint(1, 2, isSneaking ? -1 : 1);
AbstractRenderer.shiftRotationPoint(rightArm, 0, 2, 6);
AbstractRenderer.shiftRotationPoint(leftArm, 0, 2, 6);
@ -198,14 +124,14 @@ public abstract class AbstractPonyModel<T extends LivingEntity> extends ClientPo
}
protected void ponyRide() {
if (isRidingInteractive) {
if (attributes.isSitting) {
adjustBodyComponents(BODY_ROT_X_RIDING * 2, BODY_RP_Y_RIDING, BODY_RP_Z_RIDING);
adjustNeck(BODY_ROT_X_NOTSNEAK * 2, BODY_RP_Y_NOTSNEAK, BODY_RP_Z_NOTSNEAK - 4);
setHead(0, -2, -5);
head.setRotationPoint(0, -2, -5);
} else {
adjustBodyComponents(BODY_ROT_X_RIDING, BODY_RP_Y_RIDING, BODY_RP_Z_RIDING);
adjustNeck(BODY_ROT_X_NOTSNEAK, BODY_RP_Y_NOTSNEAK, BODY_RP_Z_NOTSNEAK);
setHead(0, 0, 0);
head.setRotationPoint(0, 0, 0);
}
leftLeg.rotationPointZ = 15;
@ -221,7 +147,7 @@ public abstract class AbstractPonyModel<T extends LivingEntity> extends ClientPo
leftArm.roll = -PI * 0.06f;
rightArm.roll = PI * 0.06f;
if (isRidingInteractive) {
if (attributes.isSitting) {
leftLeg.yaw = PI / 15;
leftLeg.pitch = PI / 9;
@ -251,7 +177,7 @@ public abstract class AbstractPonyModel<T extends LivingEntity> extends ClientPo
* @param ticks Total whole and partial ticks since the entity's existance. Used in animations together with {@code swing} and {@code move}.
*/
protected void shakeBody(float move, float swing, float bodySwing, float ticks) {
tail.setRotationAndAngles(isSwimming() || rainboom, interpolatorId, move, swing, bodySwing * 5, ticks);
tail.setRotationAndAngles(attributes.isSwimming || attributes.isGoingFast, attributes.interpolatorId, move, swing, bodySwing * 5, ticks);
upperTorso.yaw = bodySwing;
body.yaw = bodySwing;
@ -264,29 +190,7 @@ public abstract class AbstractPonyModel<T extends LivingEntity> extends ClientPo
leftLegOverlay.copyRotation(leftLeg);
rightLegOverlay.copyRotation(rightLeg);
bodyOverlay.copyRotation(body);
}
@Override
public Cuboid getHead() {
return head;
}
@Override
public void setPitch(float pitch) {
motionPitch = pitch;
}
@Override
public float getPitch() {
return motionPitch;
}
/**
* Sets the head rotation point.
*/
protected void setHead(float posX, float posY, float posZ) {
head.setRotationPoint(posX, posY, posZ);
headwear.setRotationPoint(posX, posY, posZ);
headwear.copyRotation(head);
}
/**
@ -295,9 +199,15 @@ public abstract class AbstractPonyModel<T extends LivingEntity> extends ClientPo
* @param x New rotation X
* @param y New rotation Y
*/
protected void updateHeadRotation(float x, float y) {
headwear.yaw = head.yaw = y;
headwear.pitch = head.pitch = x;
private void updateHeadRotation(float headYaw, float headPitch) {
head.yaw = attributes.isSleeping ? (Math.abs(attributes.interpolatorId.getMostSignificantBits()) % 2.8F) - 1.9F : headYaw / 57.29578F;
headPitch = attributes.isSleeping ? 0.1f : headPitch / 57.29578F;
headPitch = Math.min(headPitch, (float) (0.5f - Math.toRadians(attributes.motionPitch)));
headPitch = Math.max(headPitch, (float) (-1.25f - Math.toRadians(attributes.motionPitch)));
head.pitch = headPitch;
}
/**
@ -308,9 +218,9 @@ public abstract class AbstractPonyModel<T extends LivingEntity> extends ClientPo
*
*/
protected void rotateLegs(float move, float swing, float ticks, T entity) {
if (isSwimming()) {
if (attributes.isSwimming) {
rotateLegsSwimming(move, swing, ticks, entity);
} else if (isGoingFast()) {
} else if (attributes.isGoingFast) {
rotateLegsInFlight(move, swing, ticks, entity);
} else {
rotateLegsOnGround(move, swing, ticks, entity);
@ -319,14 +229,14 @@ public abstract class AbstractPonyModel<T extends LivingEntity> extends ClientPo
float sin = MathHelper.sin(body.yaw) * 5;
float cos = MathHelper.cos(body.yaw) * 5;
float spread = getLegSpread();
float spread = attributes.isGoingFast ? 2 : 1;
rightArm.rotationPointZ = spread + sin;
leftArm.rotationPointZ = spread - sin;
float legRPX = cos - getLegOutset() - 0.001F;
legRPX = metadata.getInterpolator(entity.getUuid()).interpolate("legOffset", legRPX, 3);
legRPX = getMetadata().getInterpolator(attributes.interpolatorId).interpolate("legOffset", legRPX, 3);
rightArm.rotationPointX = -legRPX;
rightLeg.rotationPointX = -legRPX;
@ -342,20 +252,16 @@ public abstract class AbstractPonyModel<T extends LivingEntity> extends ClientPo
}
/**
* Rotates legs in quopy fashion whilst swimming.
*
* @param move Entity motion parameter - i.e. velocity in no specific direction used in bipeds to calculate step amount.
* @param swing Degree to which each 'limb' swings.
* @param ticks Total whole and partial ticks since the entity's existance. Used in animations together with {@code swing} and {@code move}.
* @param entity The entity we're being called for.
* Rotates legs in a quopy fashion whilst swimming.
*
* Takes the same parameters as {@link AbstractPonyModel.setRotationAndAngles}
*/
protected void rotateLegsSwimming(float move, float swing, float ticks, T entity) {
float legLeft = (ROTATE_90 + MathHelper.sin((move / 3) + 2 * PI/3) / 2) * (float)motionLerp;
float legLeft = (ROTATE_90 + MathHelper.sin((move / 3) + 2 * PI/3) / 2) * (float)attributes.motionLerp;
float left = (ROTATE_90 + MathHelper.sin((move / 3) + 2 * PI) / 2) * (float)motionLerp;
float right = (ROTATE_90 + MathHelper.sin(move / 3) / 2) * (float)motionLerp;
float left = (ROTATE_90 + MathHelper.sin((move / 3) + 2 * PI) / 2) * (float)attributes.motionLerp;
float right = (ROTATE_90 + MathHelper.sin(move / 3) / 2) * (float)attributes.motionLerp;
leftArm.pitch = -left;
leftArm.yaw = -left/2;
@ -375,15 +281,12 @@ public abstract class AbstractPonyModel<T extends LivingEntity> extends ClientPo
/**
* Rotates legs in quopy fashion whilst flying.
*
* @param move Entity motion parameter - i.e. velocity in no specific direction used in bipeds to calculate step amount.
* @param swing Degree to which each 'limb' swings.
* @param ticks Total whole and partial ticks since the entity's existance. Used in animations together with {@code swing} and {@code move}.
* @param entity The entity we're being called for.
* Takes the same parameters as {@link AbstractPonyModel.setRotationAndAngles}
*
*/
protected void rotateLegsInFlight(float move, float swing, float ticks, Entity entity) {
float armX = rainboom ? ROTATE_270 : MathHelper.sin(-swing / 2);
float legX = rainboom ? ROTATE_90 : MathHelper.sin(swing / 2);
float armX = attributes.isGoingFast ? ROTATE_270 : MathHelper.sin(-swing / 2);
float legX = attributes.isGoingFast ? ROTATE_90 : MathHelper.sin(swing / 2);
leftArm.pitch = armX;
rightArm.pitch = armX;
@ -404,10 +307,7 @@ public abstract class AbstractPonyModel<T extends LivingEntity> extends ClientPo
/**
* Rotates legs in quopy fashion for walking.
*
* @param move Entity motion parameter - i.e. velocity in no specific direction used in bipeds to calculate step amount.
* @param swing Degree to which each 'limb' swings.
* @param ticks Total whole and partial ticks since the entity's existance. Used in animations together with {@code swing} and {@code move}.
* @param entity The entity we're being called for.
* Takes the same parameters as {@link AbstractPonyModel.setRotationAndAngles}
*
*/
protected void rotateLegsOnGround(float move, float swing, float ticks, T entity) {
@ -433,25 +333,19 @@ public abstract class AbstractPonyModel<T extends LivingEntity> extends ClientPo
}
protected float getLegOutset() {
if (isSleeping()) {
if (attributes.isSleeping) {
return 3.6f;
}
if (isCrouching()) {
if (attributes.isCrouching) {
return 1;
}
return 5;
}
protected float getLegSpread() {
return rainboom ? 2 : 1;
}
/**
* Adjusts legs as if holding an item. Delegates to the correct arm/leg/limb as neccessary.
*
* @param swing
* Adjusts legs as if holding an item. Delegates to the correct arm/leg/limb as necessary.
*/
protected void holdItem(float swing) {
boolean both = leftArmPose == ArmPose.ITEM && rightArmPose == ArmPose.ITEM;
@ -490,7 +384,7 @@ public abstract class AbstractPonyModel<T extends LivingEntity> extends ClientPo
float mult = 1 - swag/2;
arm.pitch = arm.pitch * mult - (PI / 10) * swag;
arm.roll = -reflect * (PI / 15);
if (isCrouching()) {
if (attributes.isCrouching) {
arm.rotationPointX -= reflect * 2;
}
case EMPTY:
@ -504,7 +398,7 @@ public abstract class AbstractPonyModel<T extends LivingEntity> extends ClientPo
}
arm.rotationPointX += reflect;
arm.rotationPointZ += 3;
if (isCrouching()) {
if (attributes.isCrouching) {
arm.rotationPointY += 4;
}
break;
@ -539,14 +433,13 @@ public abstract class AbstractPonyModel<T extends LivingEntity> extends ClientPo
}
}
/**
* Animates arm swinging. Delegates to the correct arm/leg/limb as neccessary.
*
* @param entity The entity we are being called for.
*/
protected void swingItem(T entity) {
if (getSwingAmount() > 0 && !isSleeping()) {
if (getSwingAmount() > 0 && !attributes.isSleeping) {
AbsoluteHand mainSide = getPreferedHand(entity);
swingArm(getArm(mainSide));
@ -572,12 +465,13 @@ public abstract class AbstractPonyModel<T extends LivingEntity> extends ClientPo
}
/**
* Animates the walking animation.
* Animates the arm's breathing animation when holding items.
*
* @param ticks Total whole and partial ticks since the entity's existance. Used in animations together with {@code swing} and {@code move}.
* @param ticks Total whole and partial ticks since the entity's existence.
* Used in animations together with {@code swing} and {@code move}.
*/
protected void swingArms(float ticks) {
if (isSleeping()) {
protected void animateBreathing(float ticks) {
if (attributes.isSleeping) {
return;
}
@ -610,7 +504,7 @@ public abstract class AbstractPonyModel<T extends LivingEntity> extends ClientPo
upperTorso.rotationPointZ = rotationPointZ;
}
protected void adjustNeck(float rotateAngleX, float rotationPointY, float rotationPointZ) {
private void adjustNeck(float rotateAngleX, float rotationPointY, float rotationPointZ) {
neck.setRotationPoint(NECK_ROT_X + rotateAngleX, rotationPointY, rotationPointZ);
}
@ -650,7 +544,6 @@ public abstract class AbstractPonyModel<T extends LivingEntity> extends ClientPo
tail.init(yOffset, stretch);
}
/**
* Creates the main torso and neck.
*/
@ -716,12 +609,12 @@ public abstract class AbstractPonyModel<T extends LivingEntity> extends ClientPo
preInitLegs();
preInitLegwear();
int armLength = getArmLength();
int armWidth = getArmWidth();
int armDepth = getArmDepth();
int armLength = attributes.armLength;
int armWidth = attributes.armWidth;
int armDepth = attributes.armDepth;
float rarmX = getLegRotationX();
float rarmY = getArmRotationY();
float rarmX = attributes.armRotationX;
float rarmY = attributes.armRotationY;
float armX = THIRDP_ARM_CENTRE_X;
float armY = THIRDP_ARM_CENTRE_Y;
@ -748,95 +641,6 @@ public abstract class AbstractPonyModel<T extends LivingEntity> extends ClientPo
rightLegOverlay.addBox(armX - armWidth, armY, armZ, armWidth, armLength, armDepth, stretch + 0.25f);
}
protected int getArmWidth() {
return 4;
}
protected int getArmDepth() {
return 4;
}
protected int getArmLength() {
return 12;
}
protected float getLegRotationX() {
return 3;
}
protected float getArmRotationY() {
return 8;
}
public ArmPose getArmPoseForSide(AbsoluteHand side) {
return side == AbsoluteHand.RIGHT ? rightArmPose : leftArmPose;
}
@Override
public IPonyData getMetadata() {
return metadata;
}
@Override
public void apply(IPonyData meta) {
metadata = meta;
}
@Override
public boolean isCrouching() {
return isCrouching;
}
@Override
public boolean isGoingFast() {
return rainboom;
}
@Override
public boolean hasHeadGear() {
return headGear;
}
@Override
public boolean isFlying() {
return isFlying && canFly();
}
@Override
public boolean isElytraFlying() {
return isElytraFlying;
}
@Override
public boolean isSleeping() {
return isSleeping;
}
@Override
public boolean isRiding() {
return isRiding;
}
@Override
public boolean isSwimming() {
return isSwimming;
}
@Override
public boolean isChild() {
return getSize() == Size.FOAL;
}
@Override
public Size getSize() {
return isChild ? Size.FOAL : getMetadata().getSize();
}
@Override
public float getSwingAmount() {
return handSwingProgress;
}
@Override
public float getRiderYOffset() {
@ -853,11 +657,6 @@ public abstract class AbstractPonyModel<T extends LivingEntity> extends ClientPo
}
}
@Override
public float getModelHeight() {
return 2;
}
/**
* Sets the model's various rotation angles.
*
@ -871,41 +670,27 @@ public abstract class AbstractPonyModel<T extends LivingEntity> extends ClientPo
*/
@Override
public void render(T entity, float move, float swing, float ticks, float headYaw, float headPitch, float scale) {
renderStage(BodyPart.BODY, scale, this::renderBody);
renderStage(BodyPart.NECK, scale, this::renderNeck);
renderStage(BodyPart.HEAD, scale, this::renderHead);
renderStage(BodyPart.LEGS, scale, this::renderLegs);
if (textureHeight == 64) {
renderStage(BodyPart.LEGS, scale, this::renderSleeves);
renderStage(BodyPart.BODY, scale, this::renderVest);
}
renderStage(BodyPart.HEAD, scale, this::renderHelmet);
}
protected void renderStage(BodyPart part, float scale, Consumer<Float> action) {
pushMatrix();
transform(BodyPart.BODY);
renderBody(entity, move, swing, ticks, headYaw, headPitch, scale);
popMatrix();
pushMatrix();
transform(BodyPart.NECK);
renderNeck(scale);
popMatrix();
pushMatrix();
transform(BodyPart.HEAD);
renderHead(entity, move, swing, ticks, headYaw, headPitch, scale);
popMatrix();
pushMatrix();
transform(BodyPart.LEGS);
renderLegs(scale);
popMatrix();
pushMatrix();
transform(BodyPart.HEAD);
renderHelmet(scale);
action.accept(scale);
popMatrix();
}
/**
*
* Called to render the head.
*
* Takes the same parameters as {@link AbstractPonyModel.setRotationAndAngles}
*
*/
protected void renderHead(T entity, float move, float swing, float ticks, float headYaw, float headPitch, float scale) {
protected void renderHead(float scale) {
head.render(scale);
}
@ -918,23 +703,16 @@ public abstract class AbstractPonyModel<T extends LivingEntity> extends ClientPo
neck.render(scale);
}
/**
*
* Called to render the head.
*
* Takes the same parameters as {@link AbstractPonyModel.setRotationAndAngles}
*
*/
protected void renderBody(T entity, float move, float swing, float ticks, float headYaw, float headPitch, float scale) {
protected void renderBody(float scale) {
body.render(scale);
if (textureHeight == 64) {
bodyOverlay.render(scale);
}
upperTorso.render(scale);
body.applyTransform(scale);
tail.renderPart(scale, entity.getUuid());
tail.renderPart(scale, attributes.interpolatorId);
}
protected void renderVest(float scale) {
body.applyTransform(scale);
bodyOverlay.render(scale);
}
protected void renderLegs(float scale) {
@ -946,10 +724,6 @@ public abstract class AbstractPonyModel<T extends LivingEntity> extends ClientPo
rightArm.render(scale);
leftLeg.render(scale);
rightLeg.render(scale);
if (textureHeight == 64) {
renderSleeves(scale);
}
}
protected void renderSleeves(float scale) {
@ -961,36 +735,15 @@ public abstract class AbstractPonyModel<T extends LivingEntity> extends ClientPo
@Override
public void transform(BodyPart part) {
if (isSleeping()) {
if (attributes.isSleeping) {
rotatef(90, 1, 0, 0);
rotatef(180, 0, 1, 0);
}
if (part == BodyPart.HEAD) {
rotatef(motionPitch, 1, 0, 0);
rotatef(attributes.motionPitch, 1, 0, 0);
}
PonyTransformation.forSize(getSize()).transform(this, part);
}
/**
* Copies this model's attributes from some other.
*/
@Override
public void setAttributes(BipedEntityModel<T> model) {
super.setAttributes(model);
if (model instanceof AbstractPonyModel) {
AbstractPonyModel<T> pony = (AbstractPonyModel<T>) model;
isFlying = pony.isFlying;
isCrouching = pony.isCrouching;
isElytraFlying = pony.isElytraFlying;
isSwimming = pony.isSwimming;
isSleeping = pony.isSleeping;
headGear = pony.headGear;
metadata = pony.metadata;
motionPitch = pony.motionPitch;
rainboom = pony.rainboom;
}
}
}

View file

@ -1,19 +1,96 @@
package com.minelittlepony.client.model;
import net.minecraft.client.model.Cuboid;
import net.minecraft.client.render.entity.model.BipedEntityModel;
import net.minecraft.client.render.entity.model.PlayerEntityModel;
import net.minecraft.entity.LivingEntity;
import com.minelittlepony.model.IPonyModel;
import com.minelittlepony.client.pony.PonyData;
import com.minelittlepony.model.ModelAttributes;
import com.minelittlepony.pony.IPony;
import com.minelittlepony.pony.IPonyData;
import com.minelittlepony.pony.meta.Size;
import java.util.Random;
/**
* The raw pony model without any implementations.
* Will act effectively the same as a normal player model without any hints
* of being cute and adorable.
*
* Modders can extend this class to make their own pony models if they wish.
*/
public abstract class ClientPonyModel<T extends LivingEntity> extends PlayerEntityModel<T> implements IPonyModel<T> {
/**
* The model attributes.
*/
protected ModelAttributes<T> attributes = new ModelAttributes<>();
/**
* Associated pony data.
*/
protected IPonyData metadata = new PonyData();
public ClientPonyModel(float float_1, boolean boolean_1) {
super(float_1, boolean_1);
}
@Override
public void updateLivingState(T entity, IPony pony) {
isChild = entity.isBaby();
isSneaking = entity.isSneaking();
attributes.updateLivingState(entity, pony);
}
@Override
public ModelAttributes<?> getAttributes() {
return attributes;
}
@Override
public IPonyData getMetadata() {
return metadata;
}
@Override
public Size getSize() {
return isChild ? Size.FOAL : getMetadata().getSize();
}
@Override
public void apply(IPonyData meta) {
metadata = meta;
}
@Override
public Cuboid getHead() {
return head;
}
@Override
public boolean isRiding() {
return isRiding;
}
@Override
public float getSwingAmount() {
return handSwingProgress;
}
/**
* Copies this model's attributes from some other.
*/
@Override
public void setAttributes(BipedEntityModel<T> model) {
super.setAttributes(model);
if (model instanceof ClientPonyModel) {
attributes = ((ClientPonyModel<T>)model).attributes;
metadata = ((ClientPonyModel<T>)model).metadata;
}
}
@Override
public Cuboid getRandomCuboid(Random rand) {
// grab one at random, but cycle through the list until you find one that's filled.

View file

@ -1,9 +1,12 @@
package com.minelittlepony.model;
package com.minelittlepony.client.model;
import net.minecraft.client.model.Cuboid;
import net.minecraft.entity.LivingEntity;
import net.minecraft.util.AbsoluteHand;
import com.minelittlepony.model.BodyPart;
import com.minelittlepony.model.IUnicorn;
import com.minelittlepony.model.ModelAttributes;
import com.minelittlepony.model.armour.IEquestrianArmour;
import com.minelittlepony.pony.IPonyData;
import com.minelittlepony.pony.meta.Size;
@ -23,13 +26,13 @@ public interface IPonyMixinModel<T extends LivingEntity, M extends IPonyModel<T>
}
@Override
default void setPitch(float pitch) {
mixin().setPitch(pitch);
default IPonyData getMetadata() {
return mixin().getMetadata();
}
@Override
default float getPitch() {
return mixin().getPitch();
default ModelAttributes<?> getAttributes() {
return mixin().getAttributes();
}
@Override
@ -42,56 +45,16 @@ public interface IPonyMixinModel<T extends LivingEntity, M extends IPonyModel<T>
return mixin().createArmour();
}
@Override
default IPonyData getMetadata() {
return mixin().getMetadata();
}
@Override
default void apply(IPonyData meta) {
mixin().apply(meta);
}
@Override
default boolean isCrouching() {
return mixin().isCrouching();
}
@Override
default boolean isFlying() {
return mixin().isFlying();
}
@Override
default boolean isElytraFlying() {
return mixin().isElytraFlying();
}
@Override
default boolean isSleeping() {
return mixin().isSleeping();
}
@Override
default boolean isSwimming() {
return mixin().isSwimming();
}
@Override
default boolean isRiding() {
return mixin().isRiding();
}
@Override
default boolean isGoingFast() {
return mixin().isGoingFast();
}
@Override
default boolean isChild() {
return mixin().isChild();
}
@Override
default float getSwingAmount() {
return mixin().getSwingAmount();
@ -107,11 +70,6 @@ public interface IPonyMixinModel<T extends LivingEntity, M extends IPonyModel<T>
return mixin().getRiderYOffset();
}
@Override
default float getModelHeight() {
return mixin().getModelHeight();
}
@Override
default void setArmAngle(float var1, AbsoluteHand var2) {
mixin().setArmAngle(var1, var2);
@ -122,11 +80,6 @@ public interface IPonyMixinModel<T extends LivingEntity, M extends IPonyModel<T>
return mixin().getHead();
}
@Override
default boolean hasHeadGear() {
return mixin().hasHeadGear();
}
@Override
default Cuboid getBodyPart(BodyPart part) {
return mixin().getBodyPart(part);

View file

@ -1,12 +1,21 @@
package com.minelittlepony.model;
package com.minelittlepony.client.model;
import net.minecraft.client.model.Cuboid;
import net.minecraft.entity.LivingEntity;
import com.minelittlepony.model.ICapitated;
import com.minelittlepony.model.ICompartmented;
import com.minelittlepony.model.IModel;
import com.minelittlepony.model.PonyModelConstants;
import com.minelittlepony.pony.IPony;
public interface IPonyModel<T extends LivingEntity> extends PonyModelConstants, IModel, ICapitated<Cuboid>, ICompartmented<Cuboid> {
default void updateLivingState(T entity, IPony pony) {
}
@Override
default boolean hasHeadGear() {
return getAttributes().hasHeadGear;
}
}

View file

@ -27,7 +27,7 @@ public class ModelPonyArmour<T extends LivingEntity> extends AbstractPonyModel<T
}
@Override
protected void renderBody(T entity, float move, float swing, float ticks, float headYaw, float headPitch, float scale) {
protected void renderBody(float scale) {
chestPiece.render(scale);
}

View file

@ -66,7 +66,7 @@ public class PegasusWings<T extends Model & IPegasus> implements IPart, PonyMode
if (pegasus.wingsAreOpen()) {
flapAngle = pegasus.getWingRotationFactor(ticks);
if (!pegasus.isCrouching() && pegasus.isWearing(Wearable.SADDLE_BAGS)) {
if (!pegasus.getAttributes().isCrouching && pegasus.isWearing(Wearable.SADDLE_BAGS)) {
flapAngle -= 1F;
}
}

View file

@ -34,7 +34,7 @@ public class PonyTail extends PlaneRenderer implements IPart {
roll = rainboom ? 0 : MathHelper.cos(move * 0.8F) * 0.2f * swing;
yaw = bodySwing;
if (theModel.isCrouching() && !rainboom) {
if (theModel.getAttributes().isCrouching && !rainboom) {
rotateSneak();
} else if (theModel.isRiding()) {
rotationPointZ = TAIL_RP_Z_RIDING;

View file

@ -1,10 +1,10 @@
package com.minelittlepony.client.model.components;
import com.minelittlepony.client.model.AbstractPonyModel;
import com.minelittlepony.client.model.IPonyModel;
import com.minelittlepony.client.util.render.PonyRenderer;
import com.minelittlepony.client.util.render.plane.PlaneRenderer;
import com.minelittlepony.model.IPart;
import com.minelittlepony.model.IPonyModel;
import com.mojang.blaze3d.platform.GlStateManager;
import java.util.UUID;
@ -53,7 +53,7 @@ public class SeaponyTail implements IPart {
@Override
public void setRotationAndAngles(boolean rainboom, UUID interpolatorId, float move, float swing, float bodySwing, float ticks) {
float rotation = model.isSleeping() ? 0 : MathHelper.sin(ticks * 0.536f) / 4;
float rotation = model.getAttributes().isSleeping ? 0 : MathHelper.sin(ticks * 0.536f) / 4;
tailBase.pitch = TAIL_ROTX + rotation;
tailTip.pitch = rotation;

View file

@ -20,6 +20,14 @@ public class ModelEnderStallion extends ModelSkeletonPony<EndermanEntity> {
private PonyRenderer leftHorn;
private PonyRenderer rightHorn;
public ModelEnderStallion() {
super();
attributes.armRotationX = 3;
attributes.armRotationY = 14;
attributes.armLength = 30;
attributes.visualHeight = 3;
}
@Override
public void animateModel(EndermanEntity entity, float move, float swing, float ticks) {
rightArmPose = isCarrying ? ArmPose.BLOCK : ArmPose.EMPTY;
@ -44,12 +52,6 @@ public class ModelEnderStallion extends ModelSkeletonPony<EndermanEntity> {
rightHorn.pitch = 0.5F;
}
@Override
public void setVisible(boolean visible) {
super.setVisible(visible);
}
@Override
public void setAngles(EndermanEntity entity, float move, float swing, float ticks, float headYaw, float headPitch, float scale) {
super.setAngles(entity, move, swing, ticks, headYaw, headPitch, scale);
@ -130,26 +132,6 @@ public class ModelEnderStallion extends ModelSkeletonPony<EndermanEntity> {
return isAttacking;
}
@Override
protected float getLegRotationX() {
return 3;
}
@Override
protected float getArmRotationY() {
return 14;
}
@Override
protected int getArmLength() {
return 30;
}
@Override
public float getModelHeight() {
return 3;
}
@Override
public float getWingRotationFactor(float ticks) {
return MathHelper.sin(ticks) + WING_ROT_Z_SNEAK;

View file

@ -4,8 +4,8 @@ import net.minecraft.client.render.entity.model.EntityModel;
import net.minecraft.client.render.entity.model.GuardianEntityModel;
import net.minecraft.entity.mob.GuardianEntity;
import com.minelittlepony.client.model.IPonyMixinModel;
import com.minelittlepony.client.util.render.PonyRenderer;
import com.minelittlepony.model.IPonyMixinModel;
public class ModelGuardianPony extends GuardianEntityModel implements IPonyMixinModel.Caster<GuardianEntity, ModelSeapony<GuardianEntity>, PonyRenderer> {
private final ModelSeapony<GuardianEntity> mixin = new ModelSeapony<>();

View file

@ -44,7 +44,7 @@ public class ModelSeapony<T extends LivingEntity> extends ModelUnicorn<T> {
// Seaponies can't sneak, silly
isSneaking = false;
isCrouching = false;
attributes.isCrouching = false;
}
@Override
@ -99,7 +99,7 @@ public class ModelSeapony<T extends LivingEntity> extends ModelUnicorn<T> {
float flapMotion = MathHelper.cos(ticks / 10) / 5;
if (isSleeping()) {
if (attributes.isSleeping) {
flapMotion /= 2;
}
@ -108,7 +108,7 @@ public class ModelSeapony<T extends LivingEntity> extends ModelUnicorn<T> {
leftFin.yaw = finAngle;
rightFin.yaw = -finAngle;
if (!isSleeping()) {
if (!attributes.isSleeping) {
centerFin.roll = flapMotion;
}
@ -152,12 +152,12 @@ public class ModelSeapony<T extends LivingEntity> extends ModelUnicorn<T> {
}
@Override
protected void renderBody(T entity, float move, float swing, float ticks, float headYaw, float headPitch, float scale) {
protected void renderBody(float scale) {
body.render(scale);
bodyCenter.render(scale);
body.applyTransform(scale);
tail.renderPart(scale, entity.getUuid());
tail.renderPart(scale, attributes.interpolatorId);
GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS);
GlStateManager.enableBlend();
@ -169,7 +169,6 @@ public class ModelSeapony<T extends LivingEntity> extends ModelUnicorn<T> {
GlStateManager.disableBlend();
GL11.glPopAttrib();
}
@Override

View file

@ -15,10 +15,19 @@ public class ModelSkeletonPony<T extends HostileEntity> extends ModelMobPony<T>
public boolean isWithered;
public ModelSkeletonPony() {
super();
attributes.armWidth = 2;
attributes.armDepth = 2;
attributes.armRotationX = 3F;
attributes.armRotationY = 8F;
}
@Override
public void animateModel(T entity, float move, float swing, float ticks) {
isUnicorn = entity.getUuid().getLeastSignificantBits() % 3 != 0;
isWithered = entity instanceof WitherSkeletonEntity;
attributes.visualHeight = isWithered ? 2.5F : 2;
rightArmPose = ArmPose.EMPTY;
leftArmPose = ArmPose.EMPTY;
@ -77,33 +86,8 @@ public class ModelSkeletonPony<T extends HostileEntity> extends ModelMobPony<T>
@Override
protected float getLegOutset() {
if (isSleeping()) return 2.6f;
if (isCrouching()) return 0;
if (attributes.isSleeping) return 2.6f;
if (attributes.isCrouching) return 0;
return 4;
}
@Override
protected int getArmWidth() {
return 2;
}
@Override
protected int getArmDepth() {
return 2;
}
@Override
protected float getLegRotationX() {
return 3;
}
@Override
public float getModelHeight() {
return isWithered ? 2.5F : 2;
}
@Override
protected float getArmRotationY() {
return 8;
}
}

View file

@ -31,11 +31,12 @@ public class ModelVillagerPony<T extends LivingEntity & VillagerDataContainer> e
profession = entity.getVillagerData().getProfession();
special = entity.hasCustomName() && "Derpy".equals(entity.getCustomName().getString());
special2 = special && entity.getUuid().getLeastSignificantBits() % 20 == 0;
attributes.visualHeight = special2 ? 2.3F : 2;
}
@Override
protected void renderBody(T entity, float move, float swing, float ticks, float headYaw, float headPitch, float scale) {
super.renderBody(entity, move, swing, ticks, headYaw, headPitch, scale);
protected void renderBody(float scale) {
super.renderBody(scale);
if (!special && profession != VillagerProfession.NONE && profession != VillagerProfession.NITWIT) {
if (profession == VillagerProfession.BUTCHER) {
@ -46,11 +47,6 @@ public class ModelVillagerPony<T extends LivingEntity & VillagerDataContainer> e
}
}
@Override
public float getModelHeight() {
return special2 ? 2.3F : 2;
}
@Override
public boolean isWearing(Wearable wearable) {
if (wearable == Wearable.SADDLE_BAGS) {

View file

@ -11,6 +11,7 @@ public class ModelWitchPony extends ModelZebra<WitchEntity> {
public ModelWitchPony() {
super(false);
attributes.visualHeight = 2.5F;
}
@Override
@ -48,10 +49,12 @@ public class ModelWitchPony extends ModelZebra<WitchEntity> {
rightArmOverlay.pitch = legDrinkingAngle;
rightArm.yaw = 0.1F;
rightArmOverlay.yaw = 0.1F;
rightArm.z = 0.1f;
rightArmOverlay.z = 0.1f;
rightArm.z = 0.1F;
rightArmOverlay.z = 0.1F;
if (rot > 0) rot = 0;
if (rot > 0) {
rot = 0;
}
head.pitch = -rot / 2;
headwear.pitch = -rot / 2;
@ -59,18 +62,6 @@ public class ModelWitchPony extends ModelZebra<WitchEntity> {
rightArm.z = 0;
rightArmOverlay.z = 0;
}
}
@Override
public boolean isChild() {
return isChild;
}
@Override
public float getModelHeight() {
return 2.5F;
}
@Override

View file

@ -9,7 +9,7 @@ import org.lwjgl.opengl.GL11;
import com.minelittlepony.client.util.render.Color;
import com.minelittlepony.client.util.render.PonyRenderer;
import com.minelittlepony.model.BodyPart;
import com.minelittlepony.model.IPonyModel;
import com.minelittlepony.model.IModel;
import com.minelittlepony.pony.meta.Wearable;
import java.util.Calendar;
@ -48,12 +48,12 @@ public class ChristmasHat extends AbstractGear {
}
@Override
public boolean canRender(IPonyModel<?> model, Entity entity) {
public boolean canRender(IModel model, Entity entity) {
return isChristmasDay() || model.isWearing(Wearable.ANTLERS);
}
@Override
public void setLivingAnimations(IPonyModel<?> model, Entity entity) {
public void setLivingAnimations(IModel model, Entity entity) {
tint = model.getMetadata().getGlowColor();
}

View file

@ -5,7 +5,7 @@ import net.minecraft.util.Identifier;
import com.minelittlepony.client.util.render.PonyRenderer;
import com.minelittlepony.model.BodyPart;
import com.minelittlepony.model.IPonyModel;
import com.minelittlepony.model.IModel;
import com.minelittlepony.model.gear.IStackable;
import com.minelittlepony.pony.meta.Wearable;
@ -34,7 +34,7 @@ public class Muffin extends AbstractGear implements IStackable {
}
@Override
public boolean canRender(IPonyModel<?> model, Entity entity) {
public boolean canRender(IModel model, Entity entity) {
return model.isWearing(Wearable.MUFFIN);
}

View file

@ -2,8 +2,8 @@ package com.minelittlepony.client.model.gear;
import com.minelittlepony.client.util.render.plane.PlaneRenderer;
import com.minelittlepony.model.BodyPart;
import com.minelittlepony.model.IModel;
import com.minelittlepony.model.IPegasus;
import com.minelittlepony.model.IPonyModel;
import com.minelittlepony.pony.meta.Wearable;
import com.mojang.blaze3d.platform.GlStateManager;
@ -25,7 +25,7 @@ public class SaddleBags extends AbstractGear {
float dropAmount = 0;
private IPonyModel<?> model;
private IModel model;
@Override
public void init(float yOffset, float stretch) {
@ -73,7 +73,7 @@ public class SaddleBags extends AbstractGear {
}
@Override
public void setLivingAnimations(IPonyModel<?> model, Entity entity) {
public void setLivingAnimations(IModel model, Entity entity) {
this.model = model;
hangLow = false;
@ -126,7 +126,7 @@ public class SaddleBags extends AbstractGear {
}
@Override
public boolean canRender(IPonyModel<?> model, Entity entity) {
public boolean canRender(IModel model, Entity entity) {
return model.isWearing(Wearable.SADDLE_BAGS);
}

View file

@ -6,7 +6,7 @@ import net.minecraft.util.Identifier;
import com.minelittlepony.client.util.render.PonyRenderer;
import com.minelittlepony.client.util.render.plane.PlaneRenderer;
import com.minelittlepony.model.BodyPart;
import com.minelittlepony.model.IPonyModel;
import com.minelittlepony.model.IModel;
import com.minelittlepony.model.gear.IStackable;
import com.minelittlepony.pony.meta.Wearable;
@ -49,7 +49,7 @@ public class Stetson extends AbstractGear implements IStackable {
}
@Override
public boolean canRender(IPonyModel<?> model, Entity entity) {
public boolean canRender(IModel model, Entity entity) {
return model.isWearing(Wearable.STETSON);
}

View file

@ -5,7 +5,7 @@ import net.minecraft.util.Identifier;
import com.minelittlepony.client.util.render.PonyRenderer;
import com.minelittlepony.model.BodyPart;
import com.minelittlepony.model.IPonyModel;
import com.minelittlepony.model.IModel;
import com.minelittlepony.model.gear.IStackable;
import com.minelittlepony.pony.meta.Wearable;
@ -40,7 +40,7 @@ public class WitchHat extends AbstractGear implements IStackable {
@Override
public boolean canRender(IPonyModel<?> model, Entity entity) {
public boolean canRender(IModel model, Entity entity) {
return model.isWearing(Wearable.HAT);
}

View file

@ -28,16 +28,16 @@ public class ModelAlicorn<T extends LivingEntity> extends ModelUnicorn<T> implem
super.setAngles(entity, move, swing, ticks, headYaw, headPitch, scale);
if (canFly()) {
wings.setRotationAndAngles(rainboom, entity.getUuid(), move, swing, 0, ticks);
wings.setRotationAndAngles(attributes.isGoingFast, attributes.interpolatorId, move, swing, 0, ticks);
}
}
@Override
protected void renderBody(T entity, float move, float swing, float ticks, float headYaw, float headPitch, float scale) {
super.renderBody(entity, move, swing, ticks, headYaw, headPitch, scale);
protected void renderBody(float scale) {
super.renderBody(scale);
if (canFly()) {
wings.renderPart(scale, entity.getUuid());
wings.renderPart(scale, attributes.interpolatorId);
}
}
}

View file

@ -19,7 +19,7 @@ public class ModelChangeling<T extends LivingEntity> extends ModelAlicorn<T> {
@Override
public boolean wingsAreOpen() {
return (isFlying() || isCrouching()) && !isElytraFlying();
return (isFlying() || attributes.isCrouching) && !getAttributes().isGliding;
}
@Override

View file

@ -14,6 +14,12 @@ public class ModelEarthPony<T extends LivingEntity> extends AbstractPonyModel<T>
public ModelEarthPony(boolean smallArms) {
super(smallArms);
this.smallArms = smallArms;
if (smallArms) {
attributes.armWidth = 3;
attributes.armRotationX = 2F;
attributes.armRotationY = 8.5F;
}
}
@Override
@ -28,28 +34,13 @@ public class ModelEarthPony<T extends LivingEntity> extends AbstractPonyModel<T>
@Override
protected float getLegOutset() {
if (smallArms) {
if (isSleeping()) return 2.6f;
if (isCrouching()) return 1;
if (attributes.isSleeping) return 2.6f;
if (attributes.isCrouching) return 1;
return 4;
}
return super.getLegOutset();
}
@Override
protected int getArmWidth() {
return smallArms ? 3 : super.getArmWidth();
}
@Override
protected float getLegRotationX() {
return smallArms ? 2 : super.getLegRotationX();
}
@Override
protected float getArmRotationY() {
return smallArms ? 8.5f : super.getArmRotationY();
}
@Override
protected void initHead(float yOffset, float stretch) {
super.initHead(yOffset, stretch);

View file

@ -26,12 +26,12 @@ public class ModelPegasus<T extends LivingEntity> extends ModelEarthPony<T> impl
@Override
public void setAngles(T entity, float move, float swing, float ticks, float headYaw, float headPitch, float scale) {
super.setAngles(entity, move, swing, ticks, headYaw, headPitch, scale);
wings.setRotationAndAngles(rainboom, entity.getUuid(), move, swing, 0, ticks);
wings.setRotationAndAngles(attributes.isGoingFast, entity.getUuid(), move, swing, 0, ticks);
}
@Override
protected void renderBody(T entity, float move, float swing, float ticks, float headYaw, float headPitch, float scale) {
super.renderBody(entity, move, swing, ticks, headYaw, headPitch, scale);
wings.renderPart(scale, entity.getUuid());
protected void renderBody(float scale) {
super.renderBody(scale);
wings.renderPart(scale, attributes.interpolatorId);
}
}

View file

@ -75,7 +75,7 @@ public class ModelUnicorn<T extends LivingEntity> extends ModelEarthPony<T> impl
AbsoluteHand mainSide = getPreferedHand(entity);
if (canCast() && getArmPoseForSide(mainSide) != ArmPose.EMPTY) {
if (getSwingAmount() > -9990 && !isSleeping()) {
if (getSwingAmount() > -9990 && !attributes.isSleeping) {
swingArm(getUnicornArmForSide(mainSide));
}
} else {
@ -83,9 +83,15 @@ public class ModelUnicorn<T extends LivingEntity> extends ModelEarthPony<T> impl
}
}
public ArmPose getArmPoseForSide(AbsoluteHand side) {
return side == AbsoluteHand.RIGHT ? rightArmPose : leftArmPose;
}
@Override
protected void swingArms(float ticks) {
if (isSleeping()) return;
protected void animateBreathing(float ticks) {
if (attributes.isSleeping) {
return;
}
if (canCast()) {
float cos = MathHelper.cos(ticks * 0.09F) * 0.05F + 0.05F;
@ -101,7 +107,7 @@ public class ModelUnicorn<T extends LivingEntity> extends ModelEarthPony<T> impl
unicornArmLeft.pitch += sin;
}
} else {
super.swingArms(ticks);
super.animateBreathing(ticks);
}
}
@ -123,12 +129,12 @@ public class ModelUnicorn<T extends LivingEntity> extends ModelEarthPony<T> impl
}
@Override
protected void renderHead(T entity, float move, float swing, float ticks, float headYaw, float headPitch, float scale) {
super.renderHead(entity, move, swing, ticks, headYaw, headPitch, scale);
protected void renderHead(float scale) {
super.renderHead(scale);
if (canCast()) {
head.applyTransform(scale);
horn.renderPart(scale, entity.getUuid());
horn.renderPart(scale, attributes.interpolatorId);
if (isCasting()) {
horn.renderMagic(getMagicColor(), scale);
}
@ -141,12 +147,12 @@ public class ModelUnicorn<T extends LivingEntity> extends ModelEarthPony<T> impl
unicornArmLeft = new PonyRenderer(this, 40, 32).size(64, 64);
unicornArmRight = new PonyRenderer(this, 40, 32).size(64, 64);
int armLength = getArmLength();
int armWidth = getArmWidth();
int armDepth = getArmDepth();
int armLength = attributes.armLength;
int armWidth = attributes.armWidth;
int armDepth = attributes.armDepth;
float rarmX = getLegRotationX();
float rarmY = getArmRotationY();
float rarmX = attributes.armRotationX;
float rarmY = attributes.armRotationY;
float armX = THIRDP_ARM_CENTRE_X;
float armY = THIRDP_ARM_CENTRE_Y;

View file

@ -1,8 +1,8 @@
package com.minelittlepony.client.render;
import com.minelittlepony.client.model.IPonyModel;
import com.minelittlepony.client.model.ModelWrapper;
import com.minelittlepony.model.BodyPart;
import com.minelittlepony.model.IPonyModel;
import com.minelittlepony.model.PonyModelConstants;
import com.minelittlepony.pony.IPony;
import com.minelittlepony.util.math.MathUtil;

View file

@ -1,9 +1,9 @@
package com.minelittlepony.client.render;
import com.minelittlepony.client.PonyRenderManager;
import com.minelittlepony.client.model.IPonyModel;
import com.minelittlepony.client.model.ModelWrapper;
import com.minelittlepony.client.transform.PonyPosture;
import com.minelittlepony.model.IPonyModel;
import com.minelittlepony.pony.IPony;
import com.minelittlepony.settings.PonySettings;
import com.minelittlepony.util.math.MathUtil;
@ -20,8 +20,6 @@ public class RenderPony<T extends LivingEntity, M extends EntityModel<T> & IPony
public ModelWrapper<T, M> playerModel;
private M ponyModel;
private IPony pony;
private final IPonyRender<T, M> renderer;
@ -52,7 +50,7 @@ public class RenderPony<T extends LivingEntity, M extends EntityModel<T> & IPony
public void preRenderCallback(T entity, float ticks) {
updateModel(entity);
ponyModel.updateLivingState(entity, pony);
getModel().updateLivingState(entity, pony);
float s = getScaleFactor();
GlStateManager.scalef(s, s, s);
@ -94,12 +92,12 @@ public class RenderPony<T extends LivingEntity, M extends EntityModel<T> & IPony
@SuppressWarnings("unchecked")
public void applyPostureTransform(T player, float yaw, float ticks) {
((PonyPosture<T>)getPosture(player)).apply(player, ponyModel, yaw, ticks, 1);
((PonyPosture<T>)getPosture(player)).apply(player, getModel(), yaw, ticks, 1);
}
@SuppressWarnings("unchecked")
public void applyPostureRiding(T player, float yaw, float ticks) {
((PonyPosture<T>)getPosture(player)).apply(player, ponyModel, yaw, ticks, -1);
((PonyPosture<T>)getPosture(player)).apply(player, getModel(), yaw, ticks, -1);
}
@Nonnull
@ -112,11 +110,11 @@ public class RenderPony<T extends LivingEntity, M extends EntityModel<T> & IPony
return PonyPosture.DEFAULT;
}
if (getModel().isSwimming()) {
if (getModel().getAttributes().isSwimming) {
return PonyPosture.SWIMMING;
}
if (getModel().isGoingFast()) {
if (getModel().getAttributes().isGoingFast) {
return PonyPosture.FLIGHT;
}
@ -129,9 +127,8 @@ public class RenderPony<T extends LivingEntity, M extends EntityModel<T> & IPony
public M setPonyModel(ModelWrapper<T, M> model) {
playerModel = model;
ponyModel = playerModel.getBody();
return ponyModel;
return getModel();
}
public void updateModel(T entity) {
@ -154,11 +151,11 @@ public class RenderPony<T extends LivingEntity, M extends EntityModel<T> & IPony
public double getNamePlateYOffset(T entity, double initial) {
// We start by negating the height calculation done by mohjong.
// We start by negating the height calculation done by mahjong.
float y = -(entity.getHeight() + 0.5F - (entity.isSneaking() ? 0.25F : 0));
// Then we add our own offsets.
y += ponyModel.getModelHeight() * getScaleFactor() + 0.25F;
y += getModel().getAttributes().visualHeight * getScaleFactor() + 0.25F;
if (entity.isSneaking()) {
y -= 0.25F;

View file

@ -2,6 +2,7 @@ package com.minelittlepony.client.render.entities;
import com.minelittlepony.MineLittlePony;
import com.minelittlepony.client.model.ClientPonyModel;
import com.minelittlepony.client.model.IPonyModel;
import com.minelittlepony.client.model.ModelWrapper;
import com.minelittlepony.client.render.DebugBoundingBoxRenderer;
import com.minelittlepony.client.render.IPonyRender;
@ -14,7 +15,6 @@ import com.minelittlepony.client.render.layer.LayerPonyCustomHead;
import com.minelittlepony.client.render.layer.LayerPonyElytra;
import com.minelittlepony.client.util.render.PonyRenderer;
import com.minelittlepony.hdskins.HDSkins;
import com.minelittlepony.model.IPonyModel;
import com.minelittlepony.model.IUnicorn;
import com.minelittlepony.pony.IPony;
import com.mojang.blaze3d.platform.GlStateManager;

View file

@ -1,7 +1,7 @@
package com.minelittlepony.client.render.layer;
import com.minelittlepony.client.model.IPonyModel;
import com.minelittlepony.client.render.IPonyRender;
import com.minelittlepony.model.IPonyModel;
import net.minecraft.client.render.entity.feature.FeatureRenderer;
import net.minecraft.client.render.entity.feature.FeatureRendererContext;

View file

@ -3,10 +3,10 @@ package com.minelittlepony.client.render.layer;
import net.minecraft.client.network.AbstractClientPlayerEntity;
import net.minecraft.client.render.entity.model.EntityModel;
import com.minelittlepony.client.model.IPonyModel;
import com.minelittlepony.client.model.components.ModelDeadMau5Ears;
import com.minelittlepony.client.render.IPonyRender;
import com.minelittlepony.model.BodyPart;
import com.minelittlepony.model.IPonyModel;
import com.mojang.blaze3d.platform.GlStateManager;
public class LayerDJPon3Head<T extends AbstractClientPlayerEntity, M extends EntityModel<T> & IPonyModel<T>> extends AbstractPonyLayer<T, M> {

View file

@ -5,8 +5,8 @@ import net.minecraft.client.render.entity.model.EntityModel;
import net.minecraft.entity.LivingEntity;
import net.minecraft.util.Identifier;
import com.minelittlepony.client.model.IPonyModel;
import com.minelittlepony.client.render.IPonyRender;
import com.minelittlepony.model.IPonyModel;
import com.mojang.blaze3d.platform.GLX;
import static com.mojang.blaze3d.platform.GlStateManager.*;

View file

@ -7,6 +7,7 @@ import net.minecraft.util.Identifier;
import org.lwjgl.opengl.GL11;
import com.google.common.collect.Lists;
import com.minelittlepony.client.model.IPonyModel;
import com.minelittlepony.client.model.gear.ChristmasHat;
import com.minelittlepony.client.model.gear.Muffin;
import com.minelittlepony.client.model.gear.SaddleBags;
@ -14,7 +15,6 @@ import com.minelittlepony.client.model.gear.Stetson;
import com.minelittlepony.client.model.gear.WitchHat;
import com.minelittlepony.client.render.IPonyRender;
import com.minelittlepony.model.BodyPart;
import com.minelittlepony.model.IPonyModel;
import com.minelittlepony.model.gear.IGear;
import com.minelittlepony.model.gear.IStackable;
import com.mojang.blaze3d.platform.GlStateManager;
@ -83,7 +83,7 @@ public class LayerGear<T extends LivingEntity, M extends EntityModel<T> & IPonyM
getContext().bindTexture(texture);
gear.setLivingAnimations(model, entity);
gear.setRotationAndAngles(model.isGoingFast(), entity.getUuid(), move, swing, model.getWobbleAmount(), ticks);
gear.setRotationAndAngles(model.getAttributes().isGoingFast, entity.getUuid(), move, swing, model.getWobbleAmount(), ticks);
gear.renderPart(scale, entity.getUuid());
GL11.glPopAttrib();

View file

@ -1,8 +1,8 @@
package com.minelittlepony.client.render.layer;
import com.minelittlepony.client.model.IPonyModel;
import com.minelittlepony.client.render.IPonyRender;
import com.minelittlepony.model.BodyPart;
import com.minelittlepony.model.IPonyModel;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.render.entity.model.EntityModel;

View file

@ -1,9 +1,9 @@
package com.minelittlepony.client.render.layer;
import com.minelittlepony.client.PonyRenderManager;
import com.minelittlepony.client.model.IPonyModel;
import com.minelittlepony.client.render.IPonyRender;
import com.minelittlepony.client.util.render.PonyRenderer;
import com.minelittlepony.model.IPonyModel;
import com.minelittlepony.model.IUnicorn;
import com.mojang.blaze3d.platform.GlStateManager;

View file

@ -1,11 +1,11 @@
package com.minelittlepony.client.render.layer;
import com.minelittlepony.client.ForgeProxy;
import com.minelittlepony.client.model.IPonyModel;
import com.minelittlepony.client.model.ModelWrapper;
import com.minelittlepony.client.model.armour.DefaultArmourTextureResolver;
import com.minelittlepony.client.render.IPonyRender;
import com.minelittlepony.client.util.render.Color;
import com.minelittlepony.model.IPonyModel;
import com.minelittlepony.model.armour.ArmourLayer;
import com.minelittlepony.model.armour.IArmour;
import com.minelittlepony.model.armour.IArmourTextureResolver;

View file

@ -1,10 +1,10 @@
package com.minelittlepony.client.render.layer;
import com.minelittlepony.client.model.AbstractPonyModel;
import com.minelittlepony.client.model.IPonyModel;
import com.minelittlepony.client.render.IPonyRender;
import com.minelittlepony.client.render.tileentities.skull.PonySkullRenderer;
import com.minelittlepony.model.BodyPart;
import com.minelittlepony.model.IPonyModel;
import com.mojang.authlib.GameProfile;
import net.minecraft.block.AbstractSkullBlock;

View file

@ -1,9 +1,9 @@
package com.minelittlepony.client.render.layer;
import com.minelittlepony.client.model.IPonyModel;
import com.minelittlepony.client.model.components.PonyElytra;
import com.minelittlepony.client.render.IPonyRender;
import com.minelittlepony.model.BodyPart;
import com.minelittlepony.model.IPonyModel;
import com.mojang.blaze3d.platform.GlStateManager;
import net.minecraft.client.network.AbstractClientPlayerEntity;

View file

@ -15,16 +15,16 @@ public enum PonyTransformation {
NORMAL(Size.NORMAL, 0, 3F, 0.75F) {
@Override
public void transform(IModel model, BodyPart part) {
if (model.isCrouching()) translate(0, -0.2F, 0);
if (model.isSleeping()) translate(0, -0.61F, 0.1F);
if (model.getAttributes().isCrouching) translate(0, -0.2F, 0);
if (model.getAttributes().isSleeping) translate(0, -0.61F, 0.1F);
if (model.isRiding()) translate(0, -0.2F, -0.2F);
switch (part) {
case NECK:
if (model.isCrouching()) translate(-0.03F, 0.03F, 0.1F);
if (model.getAttributes().isCrouching) translate(-0.03F, 0.03F, 0.1F);
break;
case HEAD:
if (model.isCrouching()) translate(0, 0.1F, 0);
if (model.getAttributes().isCrouching) translate(0, 0.1F, 0);
break;
case BACK:
translateVec(riderOffset);
@ -36,19 +36,19 @@ public enum PonyTransformation {
LANKY(Size.LANKY, 0, 2.6F, 0.75F) {
@Override
public void transform(IModel model, BodyPart part) {
if (model.isCrouching()) translate(0, -0.15F, 0);
if (model.isSleeping()) translate(0, -0.6F, 0.15F);
if (model.getAttributes().isCrouching) translate(0, -0.15F, 0);
if (model.getAttributes().isSleeping) translate(0, -0.6F, 0.15F);
if (model.isRiding()) translate(0, 0, -0.2F);
switch (part) {
case NECK:
translate(0, -0.15F, -0.07F);
if (model.isCrouching()) translate(-0.03F, 0.16F, 0.07F);
if (model.getAttributes().isCrouching) translate(-0.03F, 0.16F, 0.07F);
break;
case HEAD:
translate(0, -0.17F, -0.04F);
if (model.isSleeping()) translate(0, 0, -0.1F);
if (model.isCrouching()) translate(0, 0.15F, 0);
if (model.getAttributes().isSleeping) translate(0, 0, -0.1F);
if (model.getAttributes().isCrouching) translate(0, 0.15F, 0);
break;
case BODY:
translate(0, -0.2F, -0.04F);
@ -70,19 +70,19 @@ public enum PonyTransformation {
BULKY(Size.BULKY, 0, 2.3F, 0.75F) {
@Override
public void transform(IModel model, BodyPart part) {
if (model.isCrouching()) translate(0, -0.15F, 0);
if (model.isSleeping()) translate(0, -0.6F, 0.25F);
if (model.getAttributes().isCrouching) translate(0, -0.15F, 0);
if (model.getAttributes().isSleeping) translate(0, -0.6F, 0.25F);
if (model.isRiding()) translate(0, 0, -0.2F);
switch (part) {
case NECK:
translate(0, -0.15F, -0.07F);
if (model.isCrouching()) translate(-0.03F, 0.16F, 0.07F);
if (model.getAttributes().isCrouching) translate(-0.03F, 0.16F, 0.07F);
break;
case HEAD:
translate(0, -0.17F, -0.04F);
if (model.isSleeping()) translate(0, 0, -0.1F);
if (model.isCrouching()) translate(0, 0.15F, 0);
if (model.getAttributes().isSleeping) translate(0, 0, -0.1F);
if (model.getAttributes().isCrouching) translate(0, 0.15F, 0);
break;
case BODY:
translate(0, -0.2F, -0.04F);
@ -104,8 +104,8 @@ public enum PonyTransformation {
FOAL(Size.FOAL, 0, 3.8F, 0.75F) {
@Override
public void transform(IModel model, BodyPart part) {
if (model.isCrouching()) translate(0, -0.3F, 0);
if (model.isSleeping()) translate(0, -0.65F, -0.3F);
if (model.getAttributes().isCrouching) translate(0, -0.3F, 0);
if (model.getAttributes().isSleeping) translate(0, -0.65F, -0.3F);
if (model.isRiding()) translate(0, -0.6F, -0.2F);
translate(0, 0.2F, 0);
@ -114,7 +114,7 @@ public enum PonyTransformation {
case NECK:
translate(0, 0, 0.04F);
scale(1.3F, 1.3F, 1.3F);
if (model.isCrouching()) translate(0, -0.01F, 0.15F);
if (model.getAttributes().isCrouching) translate(0, -0.01F, 0.15F);
break;
case HEAD:
scale(1.3F, 1.3F, 1.3F);
@ -133,19 +133,19 @@ public enum PonyTransformation {
TALL(Size.TALL, 0, 2.2F, 0.75F) {
@Override
public void transform(IModel model, BodyPart part) {
if (model.isCrouching()) translate(0, -0.15F, 0);
if (model.isSleeping()) translate(0, -0.5F, 0.35F);
if (model.getAttributes().isCrouching) translate(0, -0.15F, 0);
if (model.getAttributes().isSleeping) translate(0, -0.5F, 0.35F);
if (model.isRiding()) translate(0, 0.1F, -0.2F);
switch (part) {
case NECK:
translate(0, -0.09F, 0);
scale(1, 1.1F, 1);
if (model.isCrouching()) translate(-0.02F, -0.02F, 0.1F);
if (model.getAttributes().isCrouching) translate(-0.02F, -0.02F, 0.1F);
break;
case HEAD:
translate(0.01F, -0.15F, 0);
if (model.isCrouching()) translate(0, 0.04F, 0);
if (model.getAttributes().isCrouching) translate(0, 0.04F, 0);
break;
case BODY:
case TAIL:
@ -154,7 +154,7 @@ public enum PonyTransformation {
case LEGS:
translate(0, -0.27F, 0.03F);
scale(1, 1.18F, 1);
if (model.isGoingFast()) translate(0, 0.05F, 0);
if (model.getAttributes().isGoingFast) translate(0, 0.05F, 0);
break;
case BACK:
riderOffset = new Vec3d(0, 2.2F, 0.75F);
@ -166,19 +166,19 @@ public enum PonyTransformation {
YEARLING(Size.YEARLING, 0, 3.8F, 0.75F) {
@Override
public void transform(IModel model, BodyPart part) {
if (model.isCrouching()) translate(0, -0.15F, 0);
if (model.isSleeping()) translate(0, -0.4F, -0.3F);
if (model.getAttributes().isCrouching) translate(0, -0.15F, 0);
if (model.getAttributes().isSleeping) translate(0, -0.4F, -0.3F);
if (model.isRiding()) translate(0, -0.4F, -0.2F);
switch (part) {
case NECK:
translate(0, -0.09F, -0.01F);
scale(1, 1.1F, 1);
if (model.isCrouching()) translate(-0.02F, -0.02F, 0.1F);
if (model.getAttributes().isCrouching) translate(-0.02F, -0.02F, 0.1F);
break;
case HEAD:
translate(0, -0.15F, 0.01F);
if (model.isCrouching()) translate(0, 0.04F, 0);
if (model.getAttributes().isCrouching) translate(0, 0.04F, 0);
scale(1.15F, 1.15F, 1.15F);
break;
case BODY:
@ -188,7 +188,7 @@ public enum PonyTransformation {
case LEGS:
translate(0, -0.265F, 0.03F);
scale(1, 1.18F, 1);
if (model.isGoingFast()) translate(0, 0.05F, 0);
if (model.getAttributes().isGoingFast) translate(0, 0.05F, 0);
break;
case BACK:
translateVec(riderOffset);

View file

@ -7,6 +7,6 @@ import com.minelittlepony.model.IModel;
public class PostureFalling implements PonyPosture<LivingEntity> {
@Override
public void transform(IModel model, LivingEntity entity, double motionX, double motionY, double motionZ, float yaw, float ticks) {
model.setPitch(0);
model.getAttributes().motionPitch = 0;
}
}

View file

@ -15,9 +15,9 @@ public class PostureFlight extends MotionCompositor implements PonyPosture<Playe
@Override
public void transform(IModel model, PlayerEntity player, double motionX, double motionY, double motionZ, float yaw, float ticks) {
model.setPitch((float) calculateIncline(player, motionX, motionY, motionZ));
model.getAttributes().motionPitch = (float) calculateIncline(player, motionX, motionY, motionZ);
GlStateManager.rotatef(model.getPitch(), 1, 0, 0);
GlStateManager.rotatef(model.getAttributes().motionPitch, 1, 0, 0);
float roll = (float)calculateRoll(player, motionX, motionY, motionZ);

View file

@ -1,8 +1,8 @@
package com.minelittlepony.model;
import net.minecraft.client.render.entity.model.ModelWithArms;
import net.minecraft.util.math.MathHelper;
import com.minelittlepony.model.BodyPart;
import com.minelittlepony.model.armour.IEquestrianArmour;
import com.minelittlepony.pony.IPonyData;
import com.minelittlepony.pony.meta.Size;
@ -22,10 +22,6 @@ public interface IModel extends ModelWithArms {
*/
void transform(BodyPart part);
void setPitch(float pitch);
float getPitch();
/**
* Gets the active scaling profile used to lay out this model's parts.
*/
@ -36,6 +32,11 @@ public interface IModel extends ModelWithArms {
*/
IEquestrianArmour<?> createArmour();
/**
* Gets the transitive properties of this model.
*/
ModelAttributes<?> getAttributes();
/**
* Gets the skin metadata associated with this model.
*/
@ -46,42 +47,18 @@ public interface IModel extends ModelWithArms {
*/
void apply(IPonyData meta);
/**
* Returns true if this model is on the ground and crouching.
*/
boolean isCrouching();
/**
* Returns true if the model is flying.
*/
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.
*/
boolean isSleeping();
/**
* Returns true if this model is wimming underwater.
*/
boolean isSwimming();
default boolean isFlying() {
return getAttributes().isFlying && canFly();
}
/**
* Returns true if this model is riding a boat, horse, or other animals.
*/
boolean isRiding();
/**
* Returns true if we're flying really fast.
*/
boolean isGoingFast();
/**
* Returns true if this model is being applied to a race that has wings.
*/
@ -92,7 +69,9 @@ public interface IModel extends ModelWithArms {
/**
* Returns true if the current model is a child or a child-like foal.
*/
boolean isChild();
default boolean isChild() {
return getSize() == Size.FOAL;
}
/**
* Gets the current leg swing amount.
@ -100,20 +79,22 @@ public interface IModel extends ModelWithArms {
float getSwingAmount();
/**
* Gets the step woddle used for various hair bits and animations.
* Gets the step wobble used for various hair bits and animations.
*/
float getWobbleAmount();
default float getWobbleAmount() {
if (getSwingAmount() <= 0) {
return 0;
}
return MathHelper.sin(MathHelper.sqrt(getSwingAmount()) * PonyModelConstants.PI * 2) * 0.04F;
}
/**
* Gets the y-offset applied to entities riding this one.
*/
float getRiderYOffset();
/**
* Gets the actual, visible height of this model when rendered.
*/
float getModelHeight();
/**
* Tests if this model is wearing the given piece of gear.
*/

View file

@ -11,7 +11,7 @@ public interface IPegasus extends IModel {
* Returns true if the wings are spread.
*/
default boolean wingsAreOpen() {
return (isSwimming() || isFlying() || isCrouching()) && !isElytraFlying();
return (getAttributes().isSwimming || isFlying() || getAttributes().isCrouching) && !getAttributes().isGliding;
}
/**
@ -20,7 +20,7 @@ public interface IPegasus extends IModel {
* @param ticks Partial render ticks
*/
default float getWingRotationFactor(float ticks) {
if (isSwimming()) {
if (getAttributes().isSwimming) {
return (MathHelper.sin(ticks * 0.136f) / 2) + ROTATE_270;
}
if (isFlying()) {

View file

@ -0,0 +1,98 @@
package com.minelittlepony.model;
import com.minelittlepony.pony.IPony;
import com.minelittlepony.util.math.MathUtil;
import net.minecraft.entity.LivingEntity;
import net.minecraft.util.math.Vec3d;
import java.util.UUID;
public class ModelAttributes<T extends LivingEntity> {
/**
* True if the model is sleeping in a bed.
*/
public boolean isSleeping;
/**
* True if the model is flying like a pegasus.
*/
public boolean isFlying;
/**
* True if the model is elytra flying. Elytra flying is different
* from regular flying in that there are actual "wings" involved.
*/
public boolean isGliding;
/**
* True if the model is swimming under water.
*/
public boolean isSwimming;
/**
* True if the pony is crouching.
*/
public boolean isCrouching;
/**
* True if the model is sitting as in boats.
*/
public boolean isSitting;
/**
* Flag indicating that this model is performing a rainboom (flight).
*/
public boolean isGoingFast;
/**
* True if the model is wearing any unconventional headgear (ie. a Pumpkin)
*/
public boolean hasHeadGear;
/**
* Vertical pitch whilst flying.
*/
public float motionPitch;
/**
* Lerp amount controlling leg swing whilst performing a rainboom.
*/
public double motionLerp;
/**
* Unique id of the interpolator used for this model.
* Usually the UUID of the entity being rendered.
*/
public UUID interpolatorId;
public int armWidth = 4;
public int armDepth = 4;
public int armLength = 12;
public float armRotationX = 3F;
public float armRotationY = 8F;
/**
* The actual, visible height of this model when rendered.
* Used when drawing nameplates.
*/
public float visualHeight = 2F;
/**
* Checks flying and speed conditions and sets rainboom to true if we're a species with wings and is going faaast.
*/
public void checkRainboom(T entity, float swing, boolean hasWings) {
Vec3d motion = entity.getVelocity();
double zMotion = Math.sqrt(motion.x * motion.x + motion.z * motion.z);
isGoingFast = (isFlying && hasWings) || isGliding;
isGoingFast &= zMotion > 0.4F;
motionLerp = MathUtil.clampLimit(zMotion * 30, 1);
}
public void updateLivingState(T entity, IPony pony) {
isCrouching = pony.isCrouching(entity);
isSleeping = entity.isSleeping();
isFlying = pony.isFlying(entity);
isGliding = entity.isFallFlying();
isSwimming = pony.isSwimming(entity);
hasHeadGear = pony.isWearingHeadgear(entity);
isSitting = pony.isRidingInteractive(entity);
interpolatorId = entity.getUuid();
}
}

View file

@ -4,8 +4,8 @@ import net.minecraft.entity.Entity;
import net.minecraft.util.Identifier;
import com.minelittlepony.model.BodyPart;
import com.minelittlepony.model.IModel;
import com.minelittlepony.model.IPart;
import com.minelittlepony.model.IPonyModel;
import javax.annotation.Nullable;
@ -19,7 +19,7 @@ public interface IGear extends IPart {
*
* @return True to render this wearable
*/
boolean canRender(IPonyModel<?> model, Entity entity);
boolean canRender(IModel model, Entity entity);
/**
* Gets the body location that this wearable appears on.
@ -36,7 +36,7 @@ public interface IGear extends IPart {
/**
* Orients this wearable.
*/
default void setLivingAnimations(IPonyModel<?> model, Entity entity) {
default void setLivingAnimations(IModel model, Entity entity) {
}