mirror of
https://github.com/MineLittlePony/MineLittlePony.git
synced 2025-02-13 08:14:23 +01:00
Slightly refactor pony sitting
This commit is contained in:
parent
4dc7500611
commit
b71e95b8de
7 changed files with 40 additions and 17 deletions
|
@ -81,7 +81,7 @@ public abstract class AbstractPonyModel<T extends LivingEntity> extends ClientPo
|
|||
if (attributes.isCrouching) {
|
||||
ponyCrouch();
|
||||
} else if (riding) {
|
||||
ponyRide();
|
||||
ponySit();
|
||||
} else {
|
||||
adjustBody(BODY_ROT_X_NOTSNEAK, BODY_RP_Y_NOTSNEAK, BODY_RP_Z_NOTSNEAK);
|
||||
|
||||
|
@ -135,8 +135,8 @@ public abstract class AbstractPonyModel<T extends LivingEntity> extends ClientPo
|
|||
((MsonPart)leftLeg).shift(0, 2, -8);
|
||||
}
|
||||
|
||||
protected void ponyRide() {
|
||||
if (attributes.isSitting) {
|
||||
protected void ponySit() {
|
||||
if (attributes.isRidingInteractive) {
|
||||
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);
|
||||
head.setPivot(0, -2, -5);
|
||||
|
@ -159,7 +159,7 @@ public abstract class AbstractPonyModel<T extends LivingEntity> extends ClientPo
|
|||
leftArm.roll = -PI * 0.06f;
|
||||
rightArm.roll = PI * 0.06f;
|
||||
|
||||
if (attributes.isSitting) {
|
||||
if (attributes.isRidingInteractive) {
|
||||
leftLeg.yaw = PI / 15;
|
||||
leftLeg.pitch = PI / 9;
|
||||
|
||||
|
|
|
@ -35,8 +35,9 @@ public abstract class ClientPonyModel<T extends LivingEntity> extends MsonPlayer
|
|||
@Override
|
||||
public void updateLivingState(T entity, IPony pony, EquineRenderManager.Mode mode) {
|
||||
child = entity.isBaby();
|
||||
isSneaking = entity.isInSneakingPose();
|
||||
attributes.updateLivingState(entity, pony, mode);
|
||||
isSneaking = attributes.isCrouching;
|
||||
riding = attributes.isSitting;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -58,7 +58,7 @@ public class SeaponyModel<T extends LivingEntity> extends UnicornModel<T> {
|
|||
protected void ponySleep() {}
|
||||
|
||||
@Override
|
||||
protected void ponyRide() {}
|
||||
protected void ponySit() {}
|
||||
|
||||
@Override
|
||||
public void setAngles(T entity, float move, float swing, float ticks, float headYaw, float headPitch) {
|
||||
|
|
|
@ -155,11 +155,21 @@ public class Pony implements IPony {
|
|||
return metadata;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSitting(LivingEntity entity) {
|
||||
return entity.hasVehicle()/*
|
||||
|| (entity instanceof PlayerEntity
|
||||
&& entity.getVelocity().x == 0 && entity.getVelocity().z == 0
|
||||
&& !entity.isInsideWaterOrBubbleColumn() && entity.onGround && isCrouching(entity))*/;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRidingInteractive(LivingEntity entity) {
|
||||
if (entity.hasVehicle() && entity.getVehicle() instanceof LivingEntity) {
|
||||
|
||||
if (isSitting(entity) && entity.getVehicle() instanceof LivingEntity) {
|
||||
return PonyRenderDispatcher.getInstance().getPonyRenderer((LivingEntity) entity.getVehicle()) != null;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -56,7 +56,12 @@ public abstract class PonyRenderer<T extends MobEntity, M extends EntityModel<T>
|
|||
|
||||
@Override
|
||||
public void render(T entity, float entityYaw, float tickDelta, MatrixStack stack, VertexConsumerProvider renderContext, int lightUv) {
|
||||
if (entity.isInSneakingPose()) {
|
||||
manager.preRenderCallback(entity, stack, tickDelta);
|
||||
if (getModel() instanceof PlayerEntityModel) {
|
||||
((PlayerEntityModel<?>)getModel()).setVisible(true);
|
||||
}
|
||||
|
||||
if (getModel().getAttributes().isSitting) {
|
||||
stack.translate(0, 0.125D, 0);
|
||||
}
|
||||
|
||||
|
@ -79,12 +84,7 @@ public abstract class PonyRenderer<T extends MobEntity, M extends EntityModel<T>
|
|||
}
|
||||
|
||||
@Override
|
||||
public void scale(T entity, MatrixStack stack, float ticks) {
|
||||
manager.preRenderCallback(entity, stack, ticks);
|
||||
if (this.getModel() instanceof PlayerEntityModel) {
|
||||
((PlayerEntityModel<?>)getModel()).setVisible(true);
|
||||
}
|
||||
|
||||
public void scale(T entity, MatrixStack stack, float tickDelta) {
|
||||
// shadowRadius
|
||||
shadowSize = manager.getShadowScale();
|
||||
|
||||
|
|
|
@ -40,6 +40,11 @@ public class ModelAttributes<T extends LivingEntity> {
|
|||
* True if the pony is crouching.
|
||||
*/
|
||||
public boolean isCrouching;
|
||||
/**
|
||||
* True if the pony is sitting.
|
||||
*/
|
||||
public boolean isSitting;
|
||||
|
||||
/**
|
||||
* True if the entity is left-handed.
|
||||
*/
|
||||
|
@ -47,7 +52,7 @@ public class ModelAttributes<T extends LivingEntity> {
|
|||
/**
|
||||
* True if the model is sitting as in boats.
|
||||
*/
|
||||
public boolean isSitting;
|
||||
public boolean isRidingInteractive;
|
||||
/**
|
||||
* Flag indicating that this model is performing a rainboom (flight).
|
||||
*/
|
||||
|
@ -92,14 +97,15 @@ public class ModelAttributes<T extends LivingEntity> {
|
|||
}
|
||||
|
||||
public void updateLivingState(T entity, IPony pony, EquineRenderManager.Mode mode) {
|
||||
isCrouching = mode == Mode.THIRD_PERSON && pony.isCrouching(entity);
|
||||
isSitting = pony.isSitting(entity);
|
||||
isCrouching = !isSitting && mode == Mode.THIRD_PERSON && pony.isCrouching(entity);
|
||||
isSleeping = entity.isSleeping();
|
||||
isFlying = mode == Mode.THIRD_PERSON && pony.isFlying(entity);
|
||||
isGliding = entity.isFallFlying();
|
||||
isSwimming = mode == Mode.THIRD_PERSON && pony.isSwimming(entity);
|
||||
isSwimmingRotated = mode == Mode.THIRD_PERSON && isSwimming && (entity instanceof PlayerEntity || entity instanceof IRotatedSwimmer);
|
||||
isRidingInteractive = pony.isRidingInteractive(entity);
|
||||
hasHeadGear = pony.isWearingHeadgear(entity);
|
||||
isSitting = pony.isRidingInteractive(entity);
|
||||
interpolatorId = entity.getUuid();
|
||||
isLeftHanded = entity.getMainArm() == Arm.LEFT;
|
||||
}
|
||||
|
|
|
@ -85,6 +85,12 @@ public interface IPony {
|
|||
*/
|
||||
Race getRace(boolean ignorePony);
|
||||
|
||||
/**
|
||||
* Returns true if an entity is sitting as when riding a vehicle or
|
||||
* a customized habitually actuated indoors rester (CHAIR)
|
||||
*/
|
||||
boolean isSitting(LivingEntity entity);
|
||||
|
||||
/**
|
||||
* Returns true if an entity is riding a pony or other sentient life-form.
|
||||
*
|
||||
|
|
Loading…
Reference in a new issue