mojira.dev
MC-113136

Players can perform critical attacks while sinking in lava

The bug

While swimming in lava you deal always critical hits unless you sprint or touch the ground.

https://youtu.be/zNScfQcK-bw

Code analysis

Based on 1.11.2 decompiled using MCP 9.35 rc1

The method net.minecraft.entity.player.EntityPlayer.attackTargetEntityWithCurrentItem(Entity) only tests if the player is in water and because lava does not reset the fall distance you can always deal critical hits.

Additional code analysis by @unknown can be found in this comment.

Attachments

Comments 14

Can confirm for MC 1.12.1.

Confirmed for 1.13.1.

Can confirm in 21w03a.

Can confirm in 21w05b.

Can confirm in 21w06a.

4 more comments

I can also confirm this behavior in 1.18.1.

Here's a code analysis of this issue that includes a bit more detail. (I'm aware that a code analysis has already been done above, but I'd just like to provide some additional information if that's okay and to make it crystal clear as to why this problem is occurring). The following is based on a decompiled version of Minecraft 1.18.1 using MCP-Reborn.

Code Analysis:

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

In order to perform a critical attack, certain criteria must be met as shown in the above class. 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.

If we look at the above code, we can see that no checks are carried out to see whether or not the player is in lava, and since lava doesn't reset your fall distance, you are constantly able to perform critical attacks when moving downwards and inside of this liquid.

Can confirm in 22w16b.

Can confirm in 1.18.2 and 1.19 Pre-release 4.

Can confirm in 1.19.

Can confirm in 1.19.2.

TwinShards

(Unassigned)

Confirmed

Combat

critical-hit, lava, swim

Minecraft 1.11.2, Minecraft 17w06a, Minecraft 17w16a, Minecraft 17w16b, Minecraft 17w17a, ..., 1.19 Pre-release 4, 1.19, 1.19.2, 1.21.1, 1.21.4

Retrieved