mojira.dev
MC-190768

The player cannot enter swim-mode when they have the blindness status effect applied

The bug

The player will be unable to start swimming if they have the blindness status effect applied.

Steps to Reproduce:

  1. Enter a pool of water, 2 blocks or higher

  2. Apply blindness:

    /effect give @p minecraft:blindness 1
  3. Press and hold ctrl, while moving forward

Observed Behavior:

The player will never enter swim-mode with the effect applied.

Expected Result:

The player would be able to swim, regardless of the effect.

Screenshots/Videos:

Video by @unknown:

[media]

Linked issues

Attachments

Comments 20

[Mod] markderickson

Hi there!

I can confirm for snapshot 20w29a and release 1.16.1.

I can confirm in 20w48a.

Can confirm in 21w03a.

You aren't supposed to be able to sprint with blindness. Swimming is sprinting under water.

Can confirm in 21w11a.

10 more comments

The same piece of code is responsible for being able to start sprinting and swimming, so since MC-16014 was resolved as "Works As Intended", it's more than likely that this ticket (MC-190768) will have an identical, if not, similar resolution/outcome.

Regardless, here's a code analysis of this issue. The following is based on a decompiled version of Minecraft 1.18.1 using MCP-Reborn.

Code Analysis:

net.minecraft.client.player.LocalPlayer.java

public class LocalPlayer extends AbstractClientPlayer {
   ...
   public void aiStep() {
      ...
      boolean flag4 = (float)this.getFoodData().getFoodLevel() > 6.0F || this.getAbilities().mayfly;
      ...
      if (!this.isSprinting() && (!this.isInWater() || this.isUnderWater()) && this.hasEnoughImpulseToStartSprinting() && flag4 && !this.isUsingItem() && !this.hasEffect(MobEffects.BLINDNESS) && this.minecraft.options.keySprint.isDown()) {
         this.setSprinting(true);
      }
      ...

If we look at the above class, we can see that the code specifically checks to see whether or not the player has the blindness effect when attempting to start sprinting or swimming. This is evident through the following line of code:

!this.hasEffect(MobEffects.BLINDNESS)

This basically means that if the player has the blindness effect, you will not be able to start sprinting or swimming.

Can confirm in 1.18.2 and 22w12a.

Can confirm in 1.19.

Can confirm in 1.19.2.

Affects 1.20.5. Requesting ownership of this issue to keep it up to date, due to an inactive owner since 2020.

Funk Master

[Mod] Jingy

(Unassigned)

Confirmed

Player

blindness, effect, swiming

1.15.2, 1.16 Release Candidate 1, 1.16, 1.16.1, 20w29a, ..., 23w14a, 1.20.1, 1.20.5, 1.20.6, 24w21b

Retrieved