Uploaded image for project: 'Minecraft: Java Edition'
  1. Minecraft: Java Edition
  2. MC-248090

You cannot perform critical attacks whilst having the Blindness effect

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Works As Intended
    • None
    • 1.18.1, 22w03a
    • None
    • Confirmed
    • (Unassigned)

      The Bug:

      The blindness effect prevents the player from sprinting and this is an intended mechanic as stated in MC-16014. Since this effect doesn't prevent or alter falling, walking, or jumping, it shouldn't stop the player from being able to perform a critical attack.

      For context, in order to perform a critical attack, certain criteria must be met. The criteria are as follows:

      • The player must be falling.
      • The player must not be on the ground.
      • The player must not be on any climbable blocks.
      • The player must not be in water.
      • The player must not have the blindness effect.
      • The player must not be riding an entity.
      • The player must not be sprinting.

      Steps to Reproduce:

      • Give yourself the blindness effect.
      • /effect give @s minecraft:blindness 999 0 true
      • Summon a husk nearby.
      • /summon minecraft:husk ~ ~ ~ {NoAI:1b}
      • Attempt to perform a critical attack on the husk.
      • Take note as to whether or not you can perform critical attacks whilst having the blindness effect.

      Observed Behavior:

      You cannot perform critical attacks.

      Expected Behavior:

      You would be able to perform critical attacks.

      Code Analysis:

      The following is based on a decompiled version of Minecraft 1.18.1 using MCP-Reborn.

      net.minecraft.world.entity.player.Player.java
      public abstract class Player extends LivingEntity {
         ...
         public void attack(Entity p_36347_) {
            ...
                     boolean flag2 = flag && this.fallDistance > 0.0F && !this.onGround && !this.onClimbable() && !this.isInWater() && !this.hasEffect(MobEffects.BLINDNESS) && !this.isPassenger() && p_36347_ instanceof LivingEntity;
                     flag2 = flag2 && !this.isSprinting();
                     if (flag2) {
                        f *= 1.5F;
                     }
                     ...
      //flag  = Full weapon cooldown
      //flag2 = Critical attack

      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 perform a critical attack. 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 perform a critical attack. The blindness effect doesn't prevent or alter falling, walking, or jumping, thus should not stop the player from being able to perform a critical attack.

        1. MC-248090.mp4
          4.57 MB
        2. MC-248090.png
          MC-248090.png
          448 kB

            Unassigned Unassigned
            Avoma [Mod] Avoma
            Votes:
            2 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved:
              CHK: