diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinClientPlayerEntity.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinClientPlayerEntity.java index fb836c28..41bca931 100644 --- a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinClientPlayerEntity.java +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinClientPlayerEntity.java @@ -35,7 +35,6 @@ import net.minecraft.client.network.ClientPlayerEntity; import net.minecraft.client.world.ClientWorld; import net.minecraft.entity.Entity; -import net.minecraft.entity.player.PlayerAbilities; import net.minecraft.entity.vehicle.BoatEntity; import net.minecraft.network.packet.Packet; import net.minecraft.util.math.MathHelper; @@ -76,6 +75,8 @@ public MixinClientPlayerEntity(ClientWorld world, GameProfile profile) { @Shadow public abstract void setClientPermissionLevel(int clientPermissionLevel); + @Shadow private boolean inSneakingPose; + @WrapWithCondition(method = "tickMovement", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerEntity;jump()V")) private boolean dontJumpBeforeFlying(ClientPlayerEntity instance) { return ProtocolTranslator.getTargetVersion().newerThanOrEqualTo(ProtocolVersion.v1_20_5); @@ -184,9 +185,11 @@ private boolean dontAllowSneakingWhileSwimming(ClientPlayerEntity instance) { 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; + @Inject(method = "tickMovement", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerEntity;getAttributeValue(Lnet/minecraft/registry/entry/RegistryEntry;)D")) + private void removeSneakingConditions(CallbackInfo ci) { // Allows sneaking while flying, inside blocks and vehicles + if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_13_2)) { + this.inSneakingPose = this.isSneaking() && !this.isSleeping(); + } } @Redirect(method = "tickMovement", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerEntity;isTouchingWater()Z"))