From 882627cd3fddd6236e010ff38c2ed6ab2d5159c5 Mon Sep 17 00:00:00 2001 From: Sollace Date: Fri, 25 Sep 2020 22:59:51 +0200 Subject: [PATCH] Fixed crouching getting stuck when gravity is inverted --- .../unicopia/entity/player/PlayerPhysics.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/main/java/com/minelittlepony/unicopia/entity/player/PlayerPhysics.java b/src/main/java/com/minelittlepony/unicopia/entity/player/PlayerPhysics.java index 3df491a5..2b44334e 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/player/PlayerPhysics.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/player/PlayerPhysics.java @@ -12,6 +12,7 @@ import com.minelittlepony.unicopia.util.NbtSerialisable; import com.minelittlepony.unicopia.util.MutableVector; import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityPose; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.nbt.CompoundTag; import net.minecraft.sound.SoundCategory; @@ -86,6 +87,14 @@ public class PlayerPhysics extends EntityPhysics implements Tickable, Moti public void tick() { PlayerEntity entity = pony.getOwner(); + if (isGravityNegative() && !entity.isSneaking() && entity.isInSneakingPose()) { + float currentHeight = entity.getDimensions(entity.getPose()).height; + float sneakingHeight = entity.getDimensions(EntityPose.STANDING).height; + + entity.setPos(entity.getX(), entity.getY() + currentHeight - sneakingHeight, entity.getZ()); + entity.setPose(EntityPose.STANDING); + } + MutableVector velocity = new MutableVector(entity.getVelocity()); if (isExperienceCritical() && pony.isClient()) {