mirror of
https://github.com/MineLittlePony/MineLittlePony.git
synced 2025-02-13 16:24:23 +01:00
Handle positioning clothing separately to simplify downstream code
This commit is contained in:
parent
e8a5e6ce13
commit
aecc80669c
12 changed files with 47 additions and 59 deletions
|
@ -1,8 +1,7 @@
|
||||||
package com.minelittlepony.client.model;
|
package com.minelittlepony.client.model;
|
||||||
|
|
||||||
import com.minelittlepony.client.model.armour.PonyArmourModel;
|
import com.minelittlepony.client.model.armour.PonyArmourModel;
|
||||||
import com.minelittlepony.api.model.BodyPart;
|
import com.minelittlepony.api.model.*;
|
||||||
import com.minelittlepony.api.model.ModelAttributes;
|
|
||||||
import com.minelittlepony.api.model.armour.IArmour;
|
import com.minelittlepony.api.model.armour.IArmour;
|
||||||
import com.minelittlepony.api.model.fabric.PonyModelPrepareCallback;
|
import com.minelittlepony.api.model.fabric.PonyModelPrepareCallback;
|
||||||
import com.minelittlepony.api.pony.meta.Sizes;
|
import com.minelittlepony.api.pony.meta.Sizes;
|
||||||
|
@ -24,10 +23,10 @@ import net.minecraft.util.math.MathHelper;
|
||||||
*/
|
*/
|
||||||
public abstract class AbstractPonyModel<T extends LivingEntity> extends ClientPonyModel<T> {
|
public abstract class AbstractPonyModel<T extends LivingEntity> extends ClientPonyModel<T> {
|
||||||
|
|
||||||
protected ModelPart upperTorso;
|
protected final ModelPart upperTorso;
|
||||||
protected ModelPart upperTorsoOverlay;
|
protected final ModelPart upperTorsoOverlay;
|
||||||
|
|
||||||
protected ModelPart neck;
|
protected final ModelPart neck;
|
||||||
|
|
||||||
public AbstractPonyModel(ModelPart tree) {
|
public AbstractPonyModel(ModelPart tree) {
|
||||||
super(tree);
|
super(tree);
|
||||||
|
@ -58,11 +57,25 @@ public abstract class AbstractPonyModel<T extends LivingEntity> extends ClientPo
|
||||||
* @param entity The entity we're being called for.
|
* @param entity The entity we're being called for.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void setAngles(T entity, float move, float swing, float ticks, float headYaw, float headPitch) {
|
public final void setAngles(T entity, float move, float swing, float ticks, float headYaw, float headPitch) {
|
||||||
attributes.checkRainboom(entity, swing, canFly(), ticks);
|
attributes.checkRainboom(entity, swing, canFly(), ticks);
|
||||||
PonyModelPrepareCallback.EVENT.invoker().onPonyModelPrepared(entity, this, ModelAttributes.Mode.OTHER);
|
PonyModelPrepareCallback.EVENT.invoker().onPonyModelPrepared(entity, this, ModelAttributes.Mode.OTHER);
|
||||||
super.setAngles(entity, move, swing, ticks, headYaw, headPitch);
|
super.setAngles(entity, move, swing, ticks, headYaw, headPitch);
|
||||||
|
|
||||||
|
head.pivotY = head.getDefaultTransform().pivotY;
|
||||||
|
|
||||||
|
setModelAngles(entity, move, swing, ticks, headYaw, headPitch);
|
||||||
|
|
||||||
|
leftSleeve.copyTransform(leftArm);
|
||||||
|
rightSleeve.copyTransform(rightArm);
|
||||||
|
leftPants.copyTransform(leftLeg);
|
||||||
|
rightPants.copyTransform(rightLeg);
|
||||||
|
jacket.copyTransform(body);
|
||||||
|
hat.copyTransform(head);
|
||||||
|
upperTorsoOverlay.copyTransform(upperTorso);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void setModelAngles(T entity, float move, float swing, float ticks, float headYaw, float headPitch) {
|
||||||
rotateHead(headYaw, headPitch);
|
rotateHead(headYaw, headPitch);
|
||||||
shakeBody(move, swing, getWobbleAmount(), ticks);
|
shakeBody(move, swing, getWobbleAmount(), ticks);
|
||||||
rotateLegs(move, swing, ticks, entity);
|
rotateLegs(move, swing, ticks, entity);
|
||||||
|
@ -88,22 +101,12 @@ public abstract class AbstractPonyModel<T extends LivingEntity> extends ClientPo
|
||||||
|
|
||||||
if (attributes.isSwimmingRotated) {
|
if (attributes.isSwimmingRotated) {
|
||||||
head.setPivot(0, HEAD_RP_Y_SWIM, HEAD_RP_Z_SWIM);
|
head.setPivot(0, HEAD_RP_Y_SWIM, HEAD_RP_Z_SWIM);
|
||||||
} else {
|
|
||||||
head.setPivot(0, 0, 0);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (attributes.isSleeping) {
|
if (attributes.isSleeping) {
|
||||||
ponySleep();
|
ponySleep();
|
||||||
}
|
}
|
||||||
|
|
||||||
leftSleeve.copyTransform(leftArm);
|
|
||||||
rightSleeve.copyTransform(rightArm);
|
|
||||||
leftPants.copyTransform(leftLeg);
|
|
||||||
rightPants.copyTransform(rightLeg);
|
|
||||||
jacket.copyTransform(body);
|
|
||||||
hat.copyTransform(head);
|
|
||||||
upperTorsoOverlay.copyTransform(upperTorso);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setHeadRotation(float animationProgress, float yaw, float pitch) {
|
public void setHeadRotation(float animationProgress, float yaw, float pitch) {
|
||||||
|
|
|
@ -37,8 +37,8 @@ public class EnderStallionModel extends SkeleponyModel<EndermanEntity> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setAngles(EndermanEntity entity, float move, float swing, float ticks, float headYaw, float headPitch) {
|
public void setModelAngles(EndermanEntity entity, float move, float swing, float ticks, float headYaw, float headPitch) {
|
||||||
super.setAngles(entity, move, swing, ticks, headYaw, headPitch);
|
super.setModelAngles(entity, move, swing, ticks, headYaw, headPitch);
|
||||||
|
|
||||||
if (isAttacking) {
|
if (isAttacking) {
|
||||||
head.pivotY -= 5;
|
head.pivotY -= 5;
|
||||||
|
|
|
@ -14,8 +14,8 @@ public class IllagerPonyModel<T extends IllagerEntity> extends AlicornModel<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setAngles(T illager, float move, float swing, float ticks, float headYaw, float headPitch) {
|
public void setModelAngles(T illager, float move, float swing, float ticks, float headYaw, float headPitch) {
|
||||||
super.setAngles(illager, move, swing, ticks, headYaw, headPitch);
|
super.setModelAngles(illager, move, swing, ticks, headYaw, headPitch);
|
||||||
|
|
||||||
IllagerEntity.State pose = illager.getState();
|
IllagerEntity.State pose = illager.getState();
|
||||||
|
|
||||||
|
|
|
@ -44,8 +44,8 @@ public class PiglinPonyModel extends ZomponyModel<HostileEntity> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setAngles(HostileEntity entity, float move, float swing, float ticks, float headYaw, float headPitch) {
|
public void setModelAngles(HostileEntity entity, float move, float swing, float ticks, float headYaw, float headPitch) {
|
||||||
super.setAngles(entity, move, swing, ticks, headYaw, headPitch);
|
super.setModelAngles(entity, move, swing, ticks, headYaw, headPitch);
|
||||||
|
|
||||||
float progress = ticks * 0.1F + move * 0.5F;
|
float progress = ticks * 0.1F + move * 0.5F;
|
||||||
float range = 0.08F + swing * 0.4F;
|
float range = 0.08F + swing * 0.4F;
|
||||||
|
|
|
@ -22,8 +22,6 @@ public class PonyArmourStandModel extends ArmorStandEntityModel {
|
||||||
leftArm.visible = true;
|
leftArm.visible = true;
|
||||||
rightArm.visible = true;
|
rightArm.visible = true;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (entity.getLeftLegRotation().equals(DEFAULT_LEFT_LEG_ROTATION)) {
|
if (entity.getLeftLegRotation().equals(DEFAULT_LEFT_LEG_ROTATION)) {
|
||||||
PartUtil.copyAngles(leftArm, leftLeg);
|
PartUtil.copyAngles(leftArm, leftLeg);
|
||||||
leftLeg.pitch *= -1;
|
leftLeg.pitch *= -1;
|
||||||
|
|
|
@ -82,11 +82,11 @@ public class SpikeModel<T extends LivingEntity> extends BipedEntityModel<T> {
|
||||||
tail2.yaw = tail.yaw / 2;
|
tail2.yaw = tail.yaw / 2;
|
||||||
tail3.yaw = tail2.yaw / 2;
|
tail3.yaw = tail2.yaw / 2;
|
||||||
|
|
||||||
for (var part : this.getHeadParts()) {
|
for (var part : getHeadParts()) {
|
||||||
part.pivotY += 7;
|
part.pivotY += 7;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (var part : this.getBodyParts()) {
|
for (var part : getBodyParts()) {
|
||||||
part.pivotY += 7;
|
part.pivotY += 7;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -80,23 +80,16 @@ public class VillagerPonyModel<T extends LivingEntity & VillagerDataContainer> e
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setAngles(T entity, float move, float swing, float ticks, float headYaw, float headPitch) {
|
public void setModelAngles(T entity, float move, float swing, float ticks, float headYaw, float headPitch) {
|
||||||
super.setAngles(entity, move, swing, ticks, headYaw, headPitch);
|
super.setModelAngles(entity, move, swing, ticks, headYaw, headPitch);
|
||||||
|
|
||||||
boolean isHeadRolling = entity instanceof MerchantEntity
|
boolean isHeadRolling = entity instanceof MerchantEntity && ((MerchantEntity)entity).getHeadRollingTimeLeft() > 0;
|
||||||
&& ((MerchantEntity)entity).getHeadRollingTimeLeft() > 0;
|
|
||||||
|
|
||||||
if (isHeadRolling) {
|
if (isHeadRolling) {
|
||||||
float roll = 0.3F * MathHelper.sin(0.45F * ticks);
|
head.roll = 0.3F * MathHelper.sin(0.45F * ticks);
|
||||||
|
head.pitch = 0.4F;
|
||||||
this.head.roll = roll;
|
|
||||||
this.hat.roll = roll;
|
|
||||||
|
|
||||||
this.head.pitch = 0.4F;
|
|
||||||
this.hat.pitch = 0.4F;
|
|
||||||
} else {
|
} else {
|
||||||
this.head.roll = 0.0F;
|
head.roll = 0;
|
||||||
this.hat.roll = 0.0F;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,8 +28,8 @@ public class WitchPonyModel extends EarthPonyModel<WitchEntity> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setAngles(WitchEntity entity, float move, float swing, float ticks, float headYaw, float headPitch) {
|
public void setModelAngles(WitchEntity entity, float move, float swing, float ticks, float headYaw, float headPitch) {
|
||||||
super.setAngles(entity, move, swing, ticks, headYaw, headPitch);
|
super.setModelAngles(entity, move, swing, ticks, headYaw, headPitch);
|
||||||
|
|
||||||
if (entity.isDrinking()) {
|
if (entity.isDrinking()) {
|
||||||
float noseRot = MathHelper.sin(entity.age);
|
float noseRot = MathHelper.sin(entity.age);
|
||||||
|
@ -39,7 +39,6 @@ public class WitchPonyModel extends EarthPonyModel<WitchEntity> {
|
||||||
snout.rotate(0, 0, 0);
|
snout.rotate(0, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (rightArmPose != ArmPose.EMPTY) {
|
if (rightArmPose != ArmPose.EMPTY) {
|
||||||
float rot = (float)(Math.tan(ticks / 7) + Math.sin(ticks / 3));
|
float rot = (float)(Math.tan(ticks / 7) + Math.sin(ticks / 3));
|
||||||
if (rot > 1) rot = 1;
|
if (rot > 1) rot = 1;
|
||||||
|
@ -48,21 +47,16 @@ public class WitchPonyModel extends EarthPonyModel<WitchEntity> {
|
||||||
float legDrinkingAngle = -1 * PI/3 + rot;
|
float legDrinkingAngle = -1 * PI/3 + rot;
|
||||||
|
|
||||||
rightArm.pitch = legDrinkingAngle;
|
rightArm.pitch = legDrinkingAngle;
|
||||||
rightSleeve.pitch = legDrinkingAngle;
|
|
||||||
rightArm.yaw = 0.1F;
|
rightArm.yaw = 0.1F;
|
||||||
rightSleeve.yaw = 0.1F;
|
|
||||||
rightArm.pivotX = 0.1F;
|
rightArm.pivotX = 0.1F;
|
||||||
rightSleeve.pivotX = 0.1F;
|
|
||||||
|
|
||||||
if (rot > 0) {
|
if (rot > 0) {
|
||||||
rot = 0;
|
rot = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
head.pitch = -rot / 2;
|
head.pitch = -rot / 2;
|
||||||
hat.pitch = -rot / 2;
|
|
||||||
} else {
|
} else {
|
||||||
rightArm.pivotX = 0;
|
rightArm.pivotX = 0;
|
||||||
rightSleeve.pivotX = 0;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -29,8 +29,8 @@ public class AlicornModel<T extends LivingEntity> extends UnicornModel<T> implem
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setAngles(T entity, float move, float swing, float ticks, float headYaw, float headPitch) {
|
public void setModelAngles(T entity, float move, float swing, float ticks, float headYaw, float headPitch) {
|
||||||
super.setAngles(entity, move, swing, ticks, headYaw, headPitch);
|
super.setModelAngles(entity, move, swing, ticks, headYaw, headPitch);
|
||||||
|
|
||||||
if (canFly()) {
|
if (canFly()) {
|
||||||
getWings().setRotationAndAngles(attributes.isGoingFast, attributes.interpolatorId, move, swing, 0, ticks);
|
getWings().setRotationAndAngles(attributes.isGoingFast, attributes.interpolatorId, move, swing, 0, ticks);
|
||||||
|
|
|
@ -33,8 +33,8 @@ public class EarthPonyModel<T extends LivingEntity> extends AbstractPonyModel<T>
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setAngles(T entity, float move, float swing, float ticks, float headYaw, float headPitch) {
|
public void setModelAngles(T entity, float move, float swing, float ticks, float headYaw, float headPitch) {
|
||||||
super.setAngles(entity, move, swing, ticks, headYaw, headPitch);
|
super.setModelAngles(entity, move, swing, ticks, headYaw, headPitch);
|
||||||
snout.setGender(getMetadata().getGender());
|
snout.setGender(getMetadata().getGender());
|
||||||
cape.pivotY = sneaking ? 2 : riding ? -4 : 0;
|
cape.pivotY = sneaking ? 2 : riding ? -4 : 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,8 +29,8 @@ public class PegasusModel<T extends LivingEntity> extends EarthPonyModel<T> impl
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setAngles(T entity, float move, float swing, float ticks, float headYaw, float headPitch) {
|
public void setModelAngles(T entity, float move, float swing, float ticks, float headYaw, float headPitch) {
|
||||||
super.setAngles(entity, move, swing, ticks, headYaw, headPitch);
|
super.setModelAngles(entity, move, swing, ticks, headYaw, headPitch);
|
||||||
getWings().setRotationAndAngles(attributes.isGoingFast, entity.getUuid(), move, swing, 0, ticks);
|
getWings().setRotationAndAngles(attributes.isGoingFast, entity.getUuid(), move, swing, 0, ticks);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@ import net.minecraft.util.math.MathHelper;
|
||||||
|
|
||||||
public class SeaponyModel<T extends LivingEntity> extends UnicornModel<T> {
|
public class SeaponyModel<T extends LivingEntity> extends UnicornModel<T> {
|
||||||
|
|
||||||
private final ModelPart bodyCenter;
|
private final ModelPart abdomin;
|
||||||
|
|
||||||
private final ModelPart leftFin;
|
private final ModelPart leftFin;
|
||||||
private final ModelPart centerFin;
|
private final ModelPart centerFin;
|
||||||
|
@ -24,7 +24,7 @@ public class SeaponyModel<T extends LivingEntity> extends UnicornModel<T> {
|
||||||
|
|
||||||
public SeaponyModel(ModelPart tree, boolean smallArms) {
|
public SeaponyModel(ModelPart tree, boolean smallArms) {
|
||||||
super(tree, smallArms);
|
super(tree, smallArms);
|
||||||
bodyCenter = tree.getChild("abdomin");
|
abdomin = tree.getChild("abdomin");
|
||||||
leftFin = tree.getChild("left_fin");
|
leftFin = tree.getChild("left_fin");
|
||||||
rightFin = tree.getChild("right_fin");
|
rightFin = tree.getChild("right_fin");
|
||||||
centerFin = tree.getChild("center_fin");
|
centerFin = tree.getChild("center_fin");
|
||||||
|
@ -61,8 +61,8 @@ public class SeaponyModel<T extends LivingEntity> extends UnicornModel<T> {
|
||||||
protected void ponySit() {}
|
protected void ponySit() {}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setAngles(T entity, float move, float swing, float ticks, float headYaw, float headPitch) {
|
public void setModelAngles(T entity, float move, float swing, float ticks, float headYaw, float headPitch) {
|
||||||
super.setAngles(entity, move, swing, ticks, headYaw, headPitch);
|
super.setModelAngles(entity, move, swing, ticks, headYaw, headPitch);
|
||||||
|
|
||||||
float flapMotion = MathHelper.cos(ticks / 10) / 5;
|
float flapMotion = MathHelper.cos(ticks / 10) / 5;
|
||||||
|
|
||||||
|
@ -113,7 +113,7 @@ public class SeaponyModel<T extends LivingEntity> extends UnicornModel<T> {
|
||||||
@Override
|
@Override
|
||||||
protected void renderBody(MatrixStack stack, VertexConsumer vertices, int overlayUv, int lightUv, float red, float green, float blue, float alpha) {
|
protected void renderBody(MatrixStack stack, VertexConsumer vertices, int overlayUv, int lightUv, float red, float green, float blue, float alpha) {
|
||||||
body.render(stack, vertices, overlayUv, lightUv, red, green, blue, alpha);
|
body.render(stack, vertices, overlayUv, lightUv, red, green, blue, alpha);
|
||||||
bodyCenter.render(stack, vertices, overlayUv, lightUv, red, green, blue, alpha);
|
abdomin.render(stack, vertices, overlayUv, lightUv, red, green, blue, alpha);
|
||||||
body.rotate(stack);
|
body.rotate(stack);
|
||||||
|
|
||||||
tail.renderPart(stack, vertices, overlayUv, lightUv, red, green, blue, alpha, attributes.interpolatorId);
|
tail.renderPart(stack, vertices, overlayUv, lightUv, red, green, blue, alpha, attributes.interpolatorId);
|
||||||
|
@ -142,7 +142,7 @@ public class SeaponyModel<T extends LivingEntity> extends UnicornModel<T> {
|
||||||
leftPants.visible = false;
|
leftPants.visible = false;
|
||||||
rightPants.visible = false;
|
rightPants.visible = false;
|
||||||
|
|
||||||
bodyCenter.visible = visible;
|
abdomin.visible = visible;
|
||||||
|
|
||||||
leftFin.visible = visible;
|
leftFin.visible = visible;
|
||||||
centerFin.visible = visible;
|
centerFin.visible = visible;
|
||||||
|
|
Loading…
Reference in a new issue