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

View file

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

View file

@ -3,6 +3,7 @@ package com.minelittlepony.client.model;
import net.minecraft.client.model.ModelPart; import net.minecraft.client.model.ModelPart;
import net.minecraft.entity.LivingEntity; import net.minecraft.entity.LivingEntity;
import com.minelittlepony.client.render.EquineRenderManager;
import com.minelittlepony.model.ICapitated; import com.minelittlepony.model.ICapitated;
import com.minelittlepony.model.ICompartmented; import com.minelittlepony.model.ICompartmented;
import com.minelittlepony.model.IModel; 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 { 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 @Override
default boolean hasHeadGear() { 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.armour.ModelPonyArmour;
import com.minelittlepony.client.model.entity.race.ModelUnicorn; import com.minelittlepony.client.model.entity.race.ModelUnicorn;
import com.minelittlepony.client.render.EquineRenderManager;
import com.minelittlepony.client.model.armour.ArmourWrapper; import com.minelittlepony.client.model.armour.ArmourWrapper;
import com.minelittlepony.model.BodyPart; import com.minelittlepony.model.BodyPart;
import com.minelittlepony.model.armour.IEquestrianArmour; import com.minelittlepony.model.armour.IEquestrianArmour;
@ -46,8 +47,8 @@ public class ModelSeapony<T extends LivingEntity> extends ModelUnicorn<T> {
} }
@Override @Override
public void updateLivingState(T entity, IPony pony) { public void updateLivingState(T entity, IPony pony, EquineRenderManager.Mode mode) {
super.updateLivingState(entity, pony); super.updateLivingState(entity, pony, mode);
// Seaponies can't sneak, silly // Seaponies can't sneak, silly
isSneaking = false; isSneaking = false;
@ -162,8 +163,8 @@ public class ModelSeapony<T extends LivingEntity> extends ModelUnicorn<T> {
} }
@Override @Override
public void updateLivingState(T entity, IPony pony) { public void updateLivingState(T entity, IPony pony, EquineRenderManager.Mode mode) {
super.updateLivingState(entity, pony); super.updateLivingState(entity, pony, mode);
// Seaponies can't sneak, silly // Seaponies can't sneak, silly
isSneaking = false; isSneaking = false;

View file

@ -4,6 +4,7 @@ import net.minecraft.entity.mob.WitchEntity;
import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.MathHelper;
import com.minelittlepony.client.model.entity.race.ModelZebra; import com.minelittlepony.client.model.entity.race.ModelZebra;
import com.minelittlepony.client.render.EquineRenderManager;
import com.minelittlepony.pony.IPony; import com.minelittlepony.pony.IPony;
import com.minelittlepony.pony.meta.Wearable; import com.minelittlepony.pony.meta.Wearable;
@ -15,8 +16,8 @@ public class ModelWitchPony extends ModelZebra<WitchEntity> {
} }
@Override @Override
public void updateLivingState(WitchEntity entity, IPony pony) { public void updateLivingState(WitchEntity entity, IPony pony, EquineRenderManager.Mode mode) {
super.updateLivingState(entity, pony); super.updateLivingState(entity, pony, mode);
if (entity.hasCustomName() && "Filly".equals(entity.getCustomName().getString())) { if (entity.hasCustomName() && "Filly".equals(entity.getCustomName().getString())) {
isChild = true; 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) { public void preRenderCallback(T entity, MatrixStack stack, float ticks) {
updateModel(entity); updateModel(entity, Mode.THIRD_PERSON);
float s = getScaleFactor(); float s = getScaleFactor();
stack.scale(s, s, s); stack.scale(s, s, s);
@ -144,16 +144,16 @@ public class EquineRenderManager<T extends LivingEntity, M extends EntityModel<T
playerModel.apply(pony.getMetadata()); playerModel.apply(pony.getMetadata());
} }
public void updateModel(T entity) { public void updateModel(T entity, Mode mode) {
pony = renderer.getEntityPony(entity); pony = renderer.getEntityPony(entity);
playerModel.apply(pony.getMetadata()); playerModel.apply(pony.getMetadata());
pony.updateForEntity(entity); pony.updateForEntity(entity);
getModel().updateLivingState(entity, pony); getModel().updateLivingState(entity, pony, mode);
} }
public IPony getPony(T entity) { public IPony getPony(T entity) {
updateModel(entity); updateModel(entity, Mode.THIRD_PERSON);
return pony; return pony;
} }
@ -187,4 +187,9 @@ public class EquineRenderManager<T extends LivingEntity, M extends EntityModel<T
return y; 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.model.gear.SaddleBags;
import com.minelittlepony.client.render.DebugBoundingBoxRenderer; import com.minelittlepony.client.render.DebugBoundingBoxRenderer;
import com.minelittlepony.client.render.IPonyRenderContext; import com.minelittlepony.client.render.IPonyRenderContext;
import com.minelittlepony.client.render.EquineRenderManager.Mode;
import com.minelittlepony.client.render.EquineRenderManager; import com.minelittlepony.client.render.EquineRenderManager;
import com.minelittlepony.client.render.entity.feature.LayerDJPon3Head; import com.minelittlepony.client.render.entity.feature.LayerDJPon3Head;
import com.minelittlepony.client.render.entity.feature.LayerEntityOnPonyShoulder; 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) { protected void renderArm(MatrixStack stack, VertexConsumerProvider renderContext, int lightUv, AbstractClientPlayerEntity player, Arm side) {
manager.updateModel(player); manager.updateModel(player, Mode.FIRST_PERSON);
stack.push(); stack.push();
float reflect = side == Arm.LEFT ? 1 : -1; 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) { if (side == Arm.LEFT) {
super.renderLeftArm(stack, renderContext, lightUv, player); super.renderLeftArm(stack, renderContext, lightUv, player);

View file

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