mojira.dev
MC-111833

You cannot perform sweeping attacks while riding entities

The Bug:

You cannot perform sweeping attacks while riding entities.

Steps to Reproduce:

  1. Place down a rail and a minecart and summon a husk that has its "NoAI" NBT tag set to "1b" by using the command provided below.

    /summon minecraft:husk ~ ~ ~ {NoAI:1b}
  2. Get inside of the minecart and obtain a sword.

  3. Attempt to damage the husk by using a sweeping attack.

  4. Take note as to whether or not you can perform sweeping attacks while riding entities.

Observed Behavior:

The sweeping attack doesn't work.

Expected Behavior:

The sweeping attack would work.

Code Analysis:

Code analysis by @unknown and @unknown can be found below.

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_) {
      ...
               double d0 = (double)(this.walkDist - this.walkDistO);
               if (flag && !flag2 && !flag1 && this.onGround && d0 < (double)this.getSpeed()) {
                  ItemStack itemstack = this.getItemInHand(InteractionHand.MAIN_HAND);
                  if (itemstack.getItem() instanceof SwordItem) {
                     flag3 = true;
                  }
               }
               ...
//flag  = Full weapon cooldown
//flag1 = Sprint/Knockback attack
//flag2 = Critical attack
//flag3 = Sweeping attack

In order to perform a sweeping attack, a check is carried out to ensure that the player is on the ground. If the player isn't on the ground, no sweeping attack can be executed. This is evident through the following line of code:

if (flag && !flag2 && !flag1 && this.onGround && d0 < (double)this.getSpeed()) {

When the player is riding an entity, the value of their onGround boolean is set to false, and because of this, a sweeping attack cannot be performed.

Linked issues

Attachments

Comments 14

Confirmed for Minecraft 1.12

Still an issue in 1.16

confirmed for 1.16.4 pre-release 1

We actually are damaging these mobs with critical attack

Can confirm in 21w03a.

4 more comments

Can confirm in 21w11a.

Can confirm in 21w17a.

Can confirm in 1.17.1.

Further investigating regarding this issue has brought to light the fact that this can be seen when riding any entity and not just minecarts. Since I'm the reporter of this ticket, I've made the appropriate changes to reflect this. 🙂

Lennart Post

Avoma

(Unassigned)

Confirmed

Combat

Minecraft 1.11.2, Minecraft 1.12, Minecraft 1.13.1, Minecraft 19w02a, Minecraft 19w03a, ..., 1.21.4, 25w08a, 1.21.5, 1.21.6, 1.21.7

Retrieved