Fixed arm position changes when sneaking

This commit is contained in:
Sollace 2019-11-30 12:14:52 +02:00
parent 3e01252f62
commit 0130774976
8 changed files with 35 additions and 22 deletions

View file

@ -6,6 +6,7 @@ import net.minecraft.entity.LivingEntity;
import net.minecraft.util.Arm;
import com.minelittlepony.client.pony.PonyData;
import com.minelittlepony.client.render.EquineRenderManager;
import com.minelittlepony.model.ModelAttributes;
import com.minelittlepony.mson.api.model.biped.MsonPlayer;
import com.minelittlepony.pony.IPony;
@ -32,10 +33,10 @@ public abstract class ClientPonyModel<T extends LivingEntity> extends MsonPlayer
protected IPonyData metadata = new PonyData();
@Override
public void updateLivingState(T entity, IPony pony) {
public void updateLivingState(T entity, IPony pony, EquineRenderManager.Mode mode) {
isChild = entity.isBaby();
isSneaking = entity.isInSneakingPose();
attributes.updateLivingState(entity, pony);
attributes.updateLivingState(entity, pony, mode);
}
@Override

View file

@ -5,6 +5,7 @@ import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.entity.LivingEntity;
import net.minecraft.util.Arm;
import com.minelittlepony.client.render.EquineRenderManager;
import com.minelittlepony.model.BodyPart;
import com.minelittlepony.model.IUnicorn;
import com.minelittlepony.model.ModelAttributes;
@ -28,8 +29,8 @@ public interface IPonyMixinModel<T extends LivingEntity, M extends IPonyModel<T>
}
@Override
default void updateLivingState(T entity, IPony pony) {
mixin().updateLivingState(entity, pony);
default void updateLivingState(T entity, IPony pony, EquineRenderManager.Mode mode) {
mixin().updateLivingState(entity, pony, mode);
}
@Override

View file

@ -3,6 +3,7 @@ package com.minelittlepony.client.model;
import net.minecraft.client.model.ModelPart;
import net.minecraft.entity.LivingEntity;
import com.minelittlepony.client.render.EquineRenderManager;
import com.minelittlepony.model.ICapitated;
import com.minelittlepony.model.ICompartmented;
import com.minelittlepony.model.IModel;
@ -12,7 +13,7 @@ import com.minelittlepony.pony.IPony;
public interface IPonyModel<T extends LivingEntity> extends PonyModelConstants, IModel, ICapitated<ModelPart>, ICompartmented<ModelPart>, MsonModel {
void updateLivingState(T entity, IPony pony);
void updateLivingState(T entity, IPony pony, EquineRenderManager.Mode mode);
@Override
default boolean hasHeadGear() {

View file

@ -2,6 +2,7 @@ package com.minelittlepony.client.model.entity;
import com.minelittlepony.client.model.armour.ModelPonyArmour;
import com.minelittlepony.client.model.entity.race.ModelUnicorn;
import com.minelittlepony.client.render.EquineRenderManager;
import com.minelittlepony.client.model.armour.ArmourWrapper;
import com.minelittlepony.model.BodyPart;
import com.minelittlepony.model.armour.IEquestrianArmour;
@ -46,8 +47,8 @@ public class ModelSeapony<T extends LivingEntity> extends ModelUnicorn<T> {
}
@Override
public void updateLivingState(T entity, IPony pony) {
super.updateLivingState(entity, pony);
public void updateLivingState(T entity, IPony pony, EquineRenderManager.Mode mode) {
super.updateLivingState(entity, pony, mode);
// Seaponies can't sneak, silly
isSneaking = false;
@ -162,8 +163,8 @@ public class ModelSeapony<T extends LivingEntity> extends ModelUnicorn<T> {
}
@Override
public void updateLivingState(T entity, IPony pony) {
super.updateLivingState(entity, pony);
public void updateLivingState(T entity, IPony pony, EquineRenderManager.Mode mode) {
super.updateLivingState(entity, pony, mode);
// Seaponies can't sneak, silly
isSneaking = false;

View file

@ -4,6 +4,7 @@ import net.minecraft.entity.mob.WitchEntity;
import net.minecraft.util.math.MathHelper;
import com.minelittlepony.client.model.entity.race.ModelZebra;
import com.minelittlepony.client.render.EquineRenderManager;
import com.minelittlepony.pony.IPony;
import com.minelittlepony.pony.meta.Wearable;
@ -15,8 +16,8 @@ public class ModelWitchPony extends ModelZebra<WitchEntity> {
}
@Override
public void updateLivingState(WitchEntity entity, IPony pony) {
super.updateLivingState(entity, pony);
public void updateLivingState(WitchEntity entity, IPony pony, EquineRenderManager.Mode mode) {
super.updateLivingState(entity, pony, mode);
if (entity.hasCustomName() && "Filly".equals(entity.getCustomName().getString())) {
isChild = true;

View file

@ -61,7 +61,7 @@ public class EquineRenderManager<T extends LivingEntity, M extends EntityModel<T
}
public void preRenderCallback(T entity, MatrixStack stack, float ticks) {
updateModel(entity);
updateModel(entity, Mode.THIRD_PERSON);
float s = getScaleFactor();
stack.scale(s, s, s);
@ -144,16 +144,16 @@ public class EquineRenderManager<T extends LivingEntity, M extends EntityModel<T
playerModel.apply(pony.getMetadata());
}
public void updateModel(T entity) {
public void updateModel(T entity, Mode mode) {
pony = renderer.getEntityPony(entity);
playerModel.apply(pony.getMetadata());
pony.updateForEntity(entity);
getModel().updateLivingState(entity, pony);
getModel().updateLivingState(entity, pony, mode);
}
public IPony getPony(T entity) {
updateModel(entity);
updateModel(entity, Mode.THIRD_PERSON);
return pony;
}
@ -187,4 +187,9 @@ public class EquineRenderManager<T extends LivingEntity, M extends EntityModel<T
return y;
}
public enum Mode {
FIRST_PERSON,
THIRD_PERSON
}
}

View file

@ -6,6 +6,7 @@ import com.minelittlepony.client.model.ModelWrapper;
import com.minelittlepony.client.model.gear.SaddleBags;
import com.minelittlepony.client.render.DebugBoundingBoxRenderer;
import com.minelittlepony.client.render.IPonyRenderContext;
import com.minelittlepony.client.render.EquineRenderManager.Mode;
import com.minelittlepony.client.render.EquineRenderManager;
import com.minelittlepony.client.render.entity.feature.LayerDJPon3Head;
import com.minelittlepony.client.render.entity.feature.LayerEntityOnPonyShoulder;
@ -129,12 +130,12 @@ public class RenderPonyPlayer extends PlayerEntityRenderer implements IPonyRende
}
protected void renderArm(MatrixStack stack, VertexConsumerProvider renderContext, int lightUv, AbstractClientPlayerEntity player, Arm side) {
manager.updateModel(player);
manager.updateModel(player, Mode.FIRST_PERSON);
stack.push();
float reflect = side == Arm.LEFT ? 1 : -1;
stack.translate(reflect * -0.1F, -0.74F, 0);
stack.translate(reflect * 0.1F, -0.54F, 0);
if (side == Arm.LEFT) {
super.renderLeftArm(stack, renderContext, lightUv, player);

View file

@ -1,5 +1,7 @@
package com.minelittlepony.model;
import com.minelittlepony.client.render.EquineRenderManager;
import com.minelittlepony.client.render.EquineRenderManager.Mode;
import com.minelittlepony.pony.IPony;
import com.minelittlepony.util.math.MathUtil;
import net.minecraft.entity.LivingEntity;
@ -96,13 +98,13 @@ public class ModelAttributes<T extends LivingEntity> {
motionLerp = MathUtil.clampLimit(zMotion * 30, 1);
}
public void updateLivingState(T entity, IPony pony) {
isCrouching = pony.isCrouching(entity);
public void updateLivingState(T entity, IPony pony, EquineRenderManager.Mode mode) {
isCrouching = mode == Mode.THIRD_PERSON && pony.isCrouching(entity);
isSleeping = entity.isSleeping();
isFlying = pony.isFlying(entity);
isFlying = mode == Mode.THIRD_PERSON && pony.isFlying(entity);
isGliding = entity.isFallFlying();
isSwimming = pony.isSwimming(entity);
isSwimmingRotated = isSwimming && entity instanceof PlayerEntity;
isSwimming = mode == Mode.THIRD_PERSON && pony.isSwimming(entity);
isSwimmingRotated = mode == Mode.THIRD_PERSON && isSwimming && entity instanceof PlayerEntity;
hasHeadGear = pony.isWearingHeadgear(entity);
isSitting = pony.isRidingInteractive(entity);
interpolatorId = entity.getUuid();