The direction a pony's head faces when lying in a bed is now determined by which way you're looking when you climb in

This commit is contained in:
Sollace 2023-09-26 17:57:18 +01:00
parent f99309cd55
commit dcb8631eb9
No known key found for this signature in database
GPG key ID: E52FACE7B5C773DB
9 changed files with 32 additions and 25 deletions

View file

@ -20,6 +20,11 @@ public class ModelAttributes {
* True if the model is sleeping in a bed. * True if the model is sleeping in a bed.
*/ */
public boolean isSleeping; public boolean isSleeping;
/**
* True if the model is lying down comfortably
*/
public boolean isLyingDown;
/** /**
* True if the model is flying like a pegasus. * True if the model is flying like a pegasus.
*/ */
@ -145,9 +150,10 @@ public class ModelAttributes {
public void updateLivingState(LivingEntity entity, Pony pony, Mode mode) { public void updateLivingState(LivingEntity entity, Pony pony, Mode mode) {
visualHeight = entity.getHeight() + 0.125F; visualHeight = entity.getHeight() + 0.125F;
isSitting = PonyPosture.isSitting(entity); isSitting = PonyPosture.isSitting(entity);
isCrouching = !isSitting && mode == Mode.THIRD_PERSON && PonyPosture.isCrouching(pony, entity); isSleeping = entity.isAlive() && entity.isSleeping();;
isSleeping = entity.isAlive() && entity.isSleeping(); isLyingDown = isSleeping;
isFlying = mode == Mode.THIRD_PERSON && PonyPosture.isFlying(entity); isCrouching = !isLyingDown && !isSitting && mode == Mode.THIRD_PERSON && PonyPosture.isCrouching(pony, entity);
isFlying = !isLyingDown && mode == Mode.THIRD_PERSON && PonyPosture.isFlying(entity);
isGliding = entity.isFallFlying(); isGliding = entity.isFallFlying();
isSwimming = mode == Mode.THIRD_PERSON && PonyPosture.isSwimming(entity); isSwimming = mode == Mode.THIRD_PERSON && PonyPosture.isSwimming(entity);
isSwimmingRotated = isSwimming; isSwimmingRotated = isSwimming;

View file

@ -50,7 +50,6 @@ public class PonyManagerImpl implements PonyManager, SimpleSynchronousResourceRe
@Override @Override
public Pony getPony(PlayerEntity player) { public Pony getPony(PlayerEntity player) {
clearCache();
return getPony(getSkin(player), player instanceof ForcedPony ? null : player.getGameProfile() == null ? player.getUuid() : player.getGameProfile().getId()); return getPony(getSkin(player), player instanceof ForcedPony ? null : player.getGameProfile() == null ? player.getUuid() : player.getGameProfile().getId());
} }

View file

@ -119,11 +119,10 @@ public abstract class AbstractPonyModel<T extends LivingEntity> extends ClientPo
} }
protected void setModelAngles(T entity, float limbAngle, float limbSpeed, float animationProgress, float headYaw, float headPitch) { protected void setModelAngles(T entity, float limbAngle, float limbSpeed, float animationProgress, float headYaw, float headPitch) {
float pitch = attributes.motionPitch * MathHelper.RADIANS_PER_DEGREE;
float pitch = (float)Math.toRadians(attributes.motionPitch);
head.setAngles( head.setAngles(
MathHelper.clamp(attributes.isSleeping ? 0.1f : headPitch / 57.29578F, -1.25f - pitch, 0.5f - pitch), MathHelper.clamp(attributes.isSleeping ? 0.1f : headPitch / 57.29578F, -1.25f - pitch, 0.5f - pitch),
attributes.isSleeping ? (Math.abs(entity.getUuid().getMostSignificantBits()) % 2.8F) - 1.9F : headYaw / 57.29578F, attributes.isSleeping ? (Math.signum(MathHelper.wrapDegrees(headYaw)) * 1.3F) : headYaw * MathHelper.RADIANS_PER_DEGREE,
0 0
); );
@ -149,7 +148,7 @@ public abstract class AbstractPonyModel<T extends LivingEntity> extends ClientPo
} else { } else {
adjustBody(0, ORIGIN); adjustBody(0, ORIGIN);
if (!attributes.isSleeping) { if (!attributes.isLyingDown) {
animateBreathing(animationProgress); animateBreathing(animationProgress);
} }
@ -159,7 +158,7 @@ public abstract class AbstractPonyModel<T extends LivingEntity> extends ClientPo
} }
} }
if (attributes.isSleeping) { if (attributes.isLyingDown) {
ponySleep(); ponySleep();
} }
@ -197,7 +196,6 @@ public abstract class AbstractPonyModel<T extends LivingEntity> extends ClientPo
leftLeg.pitch = MathUtil.Angles._90_DEG; leftLeg.pitch = MathUtil.Angles._90_DEG;
HEAD_SLEEPING.set(head); HEAD_SLEEPING.set(head);
head.pivotZ = sneaking ? -1 : 1;
FONT_LEGS_SLEEPING.add(rightArm); FONT_LEGS_SLEEPING.add(rightArm);
FONT_LEGS_SLEEPING.add(leftArm); FONT_LEGS_SLEEPING.add(leftArm);
@ -341,7 +339,7 @@ public abstract class AbstractPonyModel<T extends LivingEntity> extends ClientPo
} }
protected float getLegOutset() { protected float getLegOutset() {
if (attributes.isSleeping) { if (attributes.isLyingDown) {
return 3.6f; return 3.6f;
} }
@ -491,7 +489,7 @@ public abstract class AbstractPonyModel<T extends LivingEntity> extends ClientPo
* @param entity The entity we are being called for. * @param entity The entity we are being called for.
*/ */
protected void swingItem(T entity) { protected void swingItem(T entity) {
if (getSwingAmount() > 0 && !attributes.isSleeping) { if (getSwingAmount() > 0 && !attributes.isLyingDown) {
Arm mainSide = getPreferredArm(entity); Arm mainSide = getPreferredArm(entity);
swingArm(getArm(mainSide)); swingArm(getArm(mainSide));
@ -624,6 +622,10 @@ public abstract class AbstractPonyModel<T extends LivingEntity> extends ClientPo
stack.multiply(RotationAxis.POSITIVE_Y.rotationDegrees(180)); stack.multiply(RotationAxis.POSITIVE_Y.rotationDegrees(180));
} }
if (attributes.isLyingDown && !attributes.isSleeping) {
stack.translate(0, 1.35F, 0);
}
if (attributes.isHorsey) { if (attributes.isHorsey) {
if (part == BodyPart.BODY) { if (part == BodyPart.BODY) {
stack.scale(1.5F, 1, 1.5F); stack.scale(1.5F, 1, 1.5F);

View file

@ -17,7 +17,7 @@ public interface ArmorModelRegistry {
if (id.getNamespace().equals("minecraft")) { if (id.getNamespace().equals("minecraft")) {
return Optional.empty(); return Optional.empty();
} }
return REGISTRY.computeIfAbsent(id.withPath(p -> "models/armor/" + layer.name().toLowerCase(Locale.ROOT) + "_" + p + ".json"), i -> { return REGISTRY.computeIfAbsent(id.withPath(p -> "armor/" + layer.name().toLowerCase(Locale.ROOT) + "_" + p + ".json"), i -> {
return Optional.of(Mson.getInstance().registerModel(i, PonyArmourModel::new)); return Optional.of(Mson.getInstance().registerModel(i, PonyArmourModel::new));
}).filter(key -> key.getModelData().isPresent()); }).filter(key -> key.getModelData().isPresent());
} }

View file

@ -78,7 +78,7 @@ public class SkeleponyModel<T extends HostileEntity> extends AlicornModel<T> {
@Override @Override
protected float getLegOutset() { protected float getLegOutset() {
if (attributes.isSleeping) return 2.6f; if (attributes.isLyingDown) return 2.6f;
if (attributes.isCrouching) return 0; if (attributes.isCrouching) return 0;
return 4; return 4;
} }

View file

@ -65,7 +65,7 @@ public class SeaponyModel<T extends LivingEntity> extends UnicornModel<T> {
float flapMotion = MathHelper.cos(ticks / 10) / 5; float flapMotion = MathHelper.cos(ticks / 10) / 5;
if (attributes.isSleeping) { if (attributes.isLyingDown) {
flapMotion /= 2; flapMotion /= 2;
} }

View file

@ -23,7 +23,7 @@ public class SeaponyTail implements SubModel, MsonModel {
@Override @Override
public void setPartAngles(ModelAttributes attributes, float limbAngle, float limbSpeed, float bodySwing, float animationProgress) { public void setPartAngles(ModelAttributes attributes, float limbAngle, float limbSpeed, float bodySwing, float animationProgress) {
float rotation = attributes.isSleeping ? 0 : MathHelper.sin(animationProgress * 0.536f) / 4; float rotation = attributes.isLyingDown ? 0 : MathHelper.sin(animationProgress * 0.536f) / 4;
tailBase.pitch = MathHelper.HALF_PI + rotation; tailBase.pitch = MathHelper.HALF_PI + rotation;
tailTip.pitch = rotation; tailTip.pitch = rotation;

View file

@ -29,7 +29,7 @@ public interface PonyPosture {
return ELYTRA; return ELYTRA;
} }
if (attributes.isSleeping) { if (attributes.isLyingDown) {
return STANDING; return STANDING;
} }

View file

@ -20,7 +20,7 @@ public enum PonyTransformation {
public void transform(PonyModel<?> model, BodyPart part, MatrixStack stack) { public void transform(PonyModel<?> model, BodyPart part, MatrixStack stack) {
if (model.getAttributes().isSwimming) stack.translate(0, -0.3F, 0); if (model.getAttributes().isSwimming) stack.translate(0, -0.3F, 0);
if (model.getAttributes().isCrouching) stack.translate(0, -0.2F, 0); if (model.getAttributes().isCrouching) stack.translate(0, -0.2F, 0);
if (model.getAttributes().isSleeping) stack.translate(0, -0.61F, 0.1F); if (model.getAttributes().isLyingDown) stack.translate(0, -0.61F, 0.1F);
if (model.getAttributes().isSitting) stack.translate(0, -0.2F, -0.2F); if (model.getAttributes().isSitting) stack.translate(0, -0.2F, -0.2F);
switch (part) { switch (part) {
@ -42,7 +42,7 @@ public enum PonyTransformation {
public void transform(PonyModel<?> model, BodyPart part, MatrixStack stack) { public void transform(PonyModel<?> model, BodyPart part, MatrixStack stack) {
if (model.getAttributes().isSwimming) stack.translate(0, -0.2F, 0); if (model.getAttributes().isSwimming) stack.translate(0, -0.2F, 0);
if (model.getAttributes().isCrouching) stack.translate(0, -0.15F, 0); if (model.getAttributes().isCrouching) stack.translate(0, -0.15F, 0);
if (model.getAttributes().isSleeping) stack.translate(0, -0.6F, 0.15F); if (model.getAttributes().isLyingDown) stack.translate(0, -0.6F, 0.15F);
if (model.getAttributes().isSitting) stack.translate(0, 0, -0.2F); if (model.getAttributes().isSitting) stack.translate(0, 0, -0.2F);
switch (part) { switch (part) {
@ -53,7 +53,7 @@ public enum PonyTransformation {
break; break;
case HEAD: case HEAD:
stack.translate(0, -0.14F, -0.04F); stack.translate(0, -0.14F, -0.04F);
if (model.getAttributes().isSleeping) stack.translate(0, 0, -0.1F); if (model.getAttributes().isLyingDown) stack.translate(0, 0, -0.1F);
if (model.getAttributes().isCrouching) stack.translate(0, 0.15F, 0); if (model.getAttributes().isCrouching) stack.translate(0, 0.15F, 0);
break; break;
case BODY: case BODY:
@ -77,7 +77,7 @@ public enum PonyTransformation {
@Override @Override
public void transform(PonyModel<?> model, BodyPart part, MatrixStack stack) { public void transform(PonyModel<?> model, BodyPart part, MatrixStack stack) {
if (model.getAttributes().isCrouching) stack.translate(0, -0.15F, 0); if (model.getAttributes().isCrouching) stack.translate(0, -0.15F, 0);
if (model.getAttributes().isSleeping) stack.translate(0, -0.6F, 0.25F); if (model.getAttributes().isLyingDown) stack.translate(0, -0.6F, 0.25F);
if (model.getAttributes().isSitting) stack.translate(0, 0, -0.2F); if (model.getAttributes().isSitting) stack.translate(0, 0, -0.2F);
switch (part) { switch (part) {
@ -88,7 +88,7 @@ public enum PonyTransformation {
break; break;
case HEAD: case HEAD:
stack.translate(0, -0.14F, -0.06F); stack.translate(0, -0.14F, -0.06F);
if (model.getAttributes().isSleeping) stack.translate(0, 0, -0.1F); if (model.getAttributes().isLyingDown) stack.translate(0, 0, -0.1F);
if (model.getAttributes().isCrouching) stack.translate(0, 0.15F, 0); if (model.getAttributes().isCrouching) stack.translate(0, 0.15F, 0);
break; break;
case BODY: case BODY:
@ -113,7 +113,7 @@ public enum PonyTransformation {
public void transform(PonyModel<?> model, BodyPart part, MatrixStack stack) { public void transform(PonyModel<?> model, BodyPart part, MatrixStack stack) {
if (model.getAttributes().isSwimming) stack.translate(0, -0.9F, 0); if (model.getAttributes().isSwimming) stack.translate(0, -0.9F, 0);
if (model.getAttributes().isCrouching) stack.translate(0, -0.2F, 0); if (model.getAttributes().isCrouching) stack.translate(0, -0.2F, 0);
if (model.getAttributes().isSleeping) stack.translate(0, -0.8F, -0.3F); if (model.getAttributes().isLyingDown) stack.translate(0, -0.8F, -0.3F);
if (model.getAttributes().isSitting) stack.translate(0, -0.6F, -0.2F); if (model.getAttributes().isSitting) stack.translate(0, -0.6F, -0.2F);
stack.translate(0, 0.2F, 0); stack.translate(0, 0.2F, 0);
@ -142,7 +142,7 @@ public enum PonyTransformation {
@Override @Override
public void transform(PonyModel<?> model, BodyPart part, MatrixStack stack) { public void transform(PonyModel<?> model, BodyPart part, MatrixStack stack) {
if (model.getAttributes().isCrouching) stack.translate(0, -0.15F, 0); if (model.getAttributes().isCrouching) stack.translate(0, -0.15F, 0);
if (model.getAttributes().isSleeping) stack.translate(0, -0.5F, 0.35F); if (model.getAttributes().isLyingDown) stack.translate(0, -0.5F, 0.35F);
if (model.getAttributes().isSitting) stack.translate(0, 0.1F, -0.2F); if (model.getAttributes().isSitting) stack.translate(0, 0.1F, -0.2F);
switch (part) { switch (part) {
@ -175,7 +175,7 @@ public enum PonyTransformation {
public void transform(PonyModel<?> model, BodyPart part, MatrixStack stack) { public void transform(PonyModel<?> model, BodyPart part, MatrixStack stack) {
if (model.getAttributes().isSwimming) stack.translate(0, -0.6F, 0); if (model.getAttributes().isSwimming) stack.translate(0, -0.6F, 0);
if (model.getAttributes().isCrouching) stack.translate(0, -0.15F, 0); if (model.getAttributes().isCrouching) stack.translate(0, -0.15F, 0);
if (model.getAttributes().isSleeping) stack.translate(0, -0.45F, -0.3F); if (model.getAttributes().isLyingDown) stack.translate(0, -0.45F, -0.3F);
if (model.getAttributes().isSitting) stack.translate(0, -0.4F, -0.2F); if (model.getAttributes().isSitting) stack.translate(0, -0.4F, -0.2F);
switch (part) { switch (part) {