Use the entity's height to inform a correct position for the nameplate

This commit is contained in:
Sollace 2021-03-11 16:18:12 +02:00
parent 54451d142b
commit 75f6d6d154
7 changed files with 8 additions and 5 deletions

View file

@ -21,7 +21,6 @@ public class EnderStallionModel extends SkeleponyModel<EndermanEntity> {
public EnderStallionModel() {
super();
attributes.visualHeight = 3;
}
@Override

View file

@ -32,7 +32,6 @@ public class SkeleponyModel<T extends HostileEntity> extends AlicornModel<T> imp
public void animateModel(T entity, float move, float swing, float ticks) {
isUnicorn = entity.getUuid().getLeastSignificantBits() % 3 != 0;
isWithered = entity instanceof WitherSkeletonEntity;
attributes.visualHeight = isWithered ? 2.5F : 2;
rightArmPose = ArmPose.EMPTY;
leftArmPose = ArmPose.EMPTY;

View file

@ -68,7 +68,7 @@ public class VillagerPonyModel<T extends LivingEntity & VillagerDataContainer> e
VillagerProfession profession = entity.getVillagerData().getProfession();
attributes.visualHeight = PonyTextures.isCrownPony(entity) ? 2.3F : 2;
attributes.visualHeight += PonyTextures.isCrownPony(entity) ? 0.3F : -0.1F;
apron.visible = !special && profession == VillagerProfession.BUTCHER;
trinket.visible = !special && !apron.visible && profession != VillagerProfession.NONE && profession != VillagerProfession.NITWIT;
}

View file

@ -12,7 +12,6 @@ public class WitchPonyModel extends ZebraModel<WitchEntity> {
public WitchPonyModel() {
super(false);
attributes.visualHeight = 2.5F;
}
@Override
@ -22,6 +21,7 @@ public class WitchPonyModel extends ZebraModel<WitchEntity> {
if (entity.hasCustomName() && "Filly".equals(entity.getCustomName().getString())) {
child = true;
}
attributes.visualHeight += 0.5F;
leftArmPose = ArmPose.EMPTY;
rightArmPose = entity.getMainHandStack().isEmpty() ? ArmPose.EMPTY : ArmPose.ITEM;
}

View file

@ -176,7 +176,7 @@ public class EquineRenderManager<T extends LivingEntity, M extends EntityModel<T
public double getNamePlateYOffset(T entity) {
// We start by negating the height calculation done by mahjong.
float y = -(entity.getHeight() + 0.5F - (entity.isInSneakingPose() ? 0.25F : 0));
float y = -(entity.getHeight() + 0.5F);
// Then we add our own offsets.
y += getModel().getAttributes().visualHeight * getScaleFactor() + 0.25F;

View file

@ -99,6 +99,10 @@ public class PlayerPonyRenderer extends PlayerEntityRenderer implements IPonyRen
}
}
protected boolean hasLabel(AbstractClientPlayerEntity entity) {
return true;
}
@Override
protected void setupTransforms(AbstractClientPlayerEntity entity, MatrixStack stack, float ageInTicks, float rotationYaw, float partialTicks) {
manager.preRenderCallback(entity, stack, partialTicks);

View file

@ -118,6 +118,7 @@ public class ModelAttributes<T extends LivingEntity> {
}
public void updateLivingState(T entity, IPony pony, EquineRenderManager.Mode mode) {
visualHeight = entity.getHeight() + 0.125F;
isSitting = pony.isSitting(entity);
isCrouching = !isSitting && mode == Mode.THIRD_PERSON && pony.isCrouching(entity);
isSleeping = entity.isSleeping();