Fixed various bugs with sneaking placement

This commit is contained in:
Sollace 2019-07-15 09:37:43 +02:00
parent c42dcfb14f
commit b1f7cda8cc
7 changed files with 7 additions and 13 deletions

View file

@ -40,13 +40,7 @@ public abstract class ClientPonyModel<T extends LivingEntity> extends PlayerEnti
@Override @Override
public void updateLivingState(T entity, IPony pony) { public void updateLivingState(T entity, IPony pony) {
isChild = entity.isBaby(); isChild = entity.isBaby();
/*This was a bug, but I'm calling it a feature isSneaking = entity.isInSneakingPose();
* isSneaking = entity.isInSneakingPose()
*If a pony is able to get into a 1.5 tall gap whilst sneaking and releases the sneak key,
*they will stop crouching. Vanilla behaviour would have them continue to crouch, but that
*would look weird, especially with winged pegasi and bat ponies.
*/
isSneaking = entity.isSneaking();
attributes.updateLivingState(entity, pony); attributes.updateLivingState(entity, pony);
} }

View file

@ -165,7 +165,7 @@ public class Pony implements IPony {
@Override @Override
public boolean isCrouching(LivingEntity entity) { public boolean isCrouching(LivingEntity entity) {
boolean isSneak = entity.isSneaking(); boolean isSneak = entity.isInSneakingPose();
boolean isFlying = isFlying(entity); boolean isFlying = isFlying(entity);
boolean isSwimming = isSwimming(entity); boolean isSwimming = isSwimming(entity);

View file

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

View file

@ -54,7 +54,7 @@ public abstract class RenderPonyMob<T extends MobEntity, M extends EntityModel<T
@Override @Override
public void render(T entity, double xPosition, double yPosition, double zPosition, float yaw, float ticks) { public void render(T entity, double xPosition, double yPosition, double zPosition, float yaw, float ticks) {
if (entity.isSneaking()) { if (entity.isInSneakingPose()) {
yPosition -= 0.125D; yPosition -= 0.125D;
} }

View file

@ -69,7 +69,7 @@ public class RenderPonyPlayer extends PlayerEntityRenderer implements IPonyRende
float x = player.getWidth() / 2; float x = player.getWidth() / 2;
float y = 0; float y = 0;
if (player.isSneaking()) { if (player.isInSneakingPose()) {
// Sneaking makes the player 1/15th shorter. // Sneaking makes the player 1/15th shorter.
// This should be compatible with height-changing mods. // This should be compatible with height-changing mods.
y += player.getHeight() / 15; y += player.getHeight() / 15;

View file

@ -56,7 +56,7 @@ public class LayerHeldPonyItem<T extends LivingEntity, M extends EntityModel<T>
pushMatrix(); pushMatrix();
renderArm(hand); renderArm(hand);
if (entity.isSneaking()) { if (getMainModel().getAttributes().isCrouching) {
translatef(0, 0.2F, 0); translatef(0, 0.2F, 0);
} }

View file

@ -9,6 +9,6 @@ public class PostureElytra implements PonyPosture<LivingEntity> {
@Override @Override
public void transform(IModel model, LivingEntity entity, double motionX, double motionY, double motionZ, float yaw, float ticks) { public void transform(IModel model, LivingEntity entity, double motionX, double motionY, double motionZ, float yaw, float ticks) {
GlStateManager.rotatef(90, 1, 0, 0); GlStateManager.rotatef(90, 1, 0, 0);
GlStateManager.translatef(0, entity.isSneaking() ? 0.2F : -1, 0); GlStateManager.translatef(0, model.getAttributes().isCrouching ? 0.2F : -1, 0);
} }
} }