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

You cannot perform sweeping attacks while riding entities

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • None
    • Minecraft 1.11.2, Minecraft 1.12, Minecraft 1.13.1, Minecraft 19w02a, Minecraft 19w03a, 1.15.2, 1.16.3, 20w46a, 21w03a, 1.16.5, 21w05b, 21w06a, 21w08b, 21w11a, 21w17a, 1.17, 1.17.1, 21w38a, 21w42a, 21w43a, 1.18 Pre-release 1, 1.18, 1.18.1, 22w03a, 22w05a, 22w06a, 22w07a, 1.18.2 Release Candidate 1, 1.18.2, 22w17a, 22w18a, 1.19, 1.19.2, 22w43a, 1.19.3, 1.19.4, 1.20, 1.20.1, 1.20.4, 23w51b, 1.20.6, 1.21, 1.21.3, 1.21.4
    • None
    • Confirmed
    • Combat

      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 Avoma and Neko 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.

            Unassigned Unassigned
            Avoma [Mod] Avoma
            Votes:
            18 Vote for this issue
            Watchers:
            9 Start watching this issue

              Created:
              Updated:
              CHK: