The bug
The player will be unable to start swimming if they have the blindness status effect applied.
Steps to Reproduce:
Enter a pool of water, 2 blocks or higher
Apply blindness:
/effect give @p minecraft:blindness 1
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
relates to 2
Attachments
Comments 20
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.
Hi there!
I can confirm for snapshot 20w29a and release 1.16.1.