Set sneaking pose while flying in <= 1.13.2

1.14+ introduced a check to prevent sneaking while flying, therefore the check in MixinPlayerEntity#onUpdatePose was wrong all the time and the movement code needed fixing.
This commit is contained in:
FlorianMichael 2024-08-09 06:36:29 +02:00
parent 3435928fb7
commit 57cd295c7f
No known key found for this signature in database
GPG Key ID: C2FB87E71C425126
3 changed files with 8 additions and 2 deletions

View File

@ -14,5 +14,5 @@ yarn_version=1.21.1+build.1
loader_version=0.15.11 loader_version=0.15.11
fabric_api_version=0.102.0+1.21.1 fabric_api_version=0.102.0+1.21.1
# empty for minecraft version above # Set to empty to use the Minecraft version above
supported_versions=>=1.21 <=1.21.1 supported_versions=>=1.21 <=1.21.1

View File

@ -35,6 +35,7 @@ import net.minecraft.client.network.ClientPlayNetworkHandler;
import net.minecraft.client.network.ClientPlayerEntity; import net.minecraft.client.network.ClientPlayerEntity;
import net.minecraft.client.world.ClientWorld; import net.minecraft.client.world.ClientWorld;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
import net.minecraft.entity.player.PlayerAbilities;
import net.minecraft.entity.vehicle.BoatEntity; import net.minecraft.entity.vehicle.BoatEntity;
import net.minecraft.network.packet.Packet; import net.minecraft.network.packet.Packet;
import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.MathHelper;
@ -183,6 +184,11 @@ public abstract class MixinClientPlayerEntity extends AbstractClientPlayerEntity
return ProtocolTranslator.getTargetVersion().newerThan(ProtocolVersion.v1_14_1) && instance.isSwimming(); return ProtocolTranslator.getTargetVersion().newerThan(ProtocolVersion.v1_14_1) && instance.isSwimming();
} }
@Redirect(method = "tickMovement", at = @At(value = "FIELD", target = "Lnet/minecraft/entity/player/PlayerAbilities;flying:Z", ordinal = 0))
private boolean allowSneakingWhileFlying(PlayerAbilities instance) {
return ProtocolTranslator.getTargetVersion().newerThan(ProtocolVersion.v1_13_2) && instance.flying;
}
@Redirect(method = "tickMovement", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerEntity;isTouchingWater()Z")) @Redirect(method = "tickMovement", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerEntity;isTouchingWater()Z"))
private boolean disableWaterRelatedMovement(ClientPlayerEntity self) { private boolean disableWaterRelatedMovement(ClientPlayerEntity self) {
return ProtocolTranslator.getTargetVersion().newerThan(ProtocolVersion.v1_12_2) && self.isTouchingWater(); return ProtocolTranslator.getTargetVersion().newerThan(ProtocolVersion.v1_12_2) && self.isTouchingWater();

View File

@ -147,7 +147,7 @@ public abstract class MixinPlayerEntity extends LivingEntity {
pose = EntityPose.SWIMMING; pose = EntityPose.SWIMMING;
} else if (this.isUsingRiptide()) { } else if (this.isUsingRiptide()) {
pose = EntityPose.SPIN_ATTACK; pose = EntityPose.SPIN_ATTACK;
} else if (this.isSneaking() && !this.abilities.flying) { } else if (this.isSneaking()) {
pose = EntityPose.CROUCHING; pose = EntityPose.CROUCHING;
} else { } else {
pose = EntityPose.STANDING; pose = EntityPose.STANDING;