You cannot perform sweeping attacks while riding entities
The Bug:
You cannot perform sweeping attacks while riding entities.
Steps to Reproduce:
- 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} - Get inside of the minecart and obtain a sword.
- Attempt to damage the husk by using a sweeping attack.
- 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 [Mod] Avoma and [Mod] Neko can be found below.
The following is based on a decompiled version of Minecraft 1.18.1 using MCP-Reborn.
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
is duplicated by1
relates to4
- Unresolved
[Mod] AvomaLennart Post
- 18
- 9
- Confirmed
- Combat
1.11.2 - 1.21.4
1.11.2 1.12 1.13.1 19w02a 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-pre1 1.18 1.18.1 22w03a 22w05a 22w06a 22w07a 1.18.2-rc1 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
Created Issue:
Sweep Attack doesnt work when sitting in a minecart
When sitting/driving in a minecart and then hitting Mobs with a sword, the sweep attack doesn't seem to work.
Environment
Win 10, Java 8
SweepAttack doesnt work when sitting in a minecartSweep attack doesn't work when sitting in a minecart
The Bug
When sitting/driving in a minecart and then hitting Mobs with a sword, the sweep attack doesn't seem to work.
Code Analysis
The following is from the method net.minecraft.entity.EntityPlayer.attackTargetEntityWithCurrentItem(Entity targetEntity) .
In order to sweep attack, the code checks that the player is on the ground. When a player is in a minecart, the boolean onGround is false .
double d0 = (double)(this.distanceWalkedModified - this.prevDistanceWalkedModified); //flag = full weapon cooldown //flag1 = sprint/knockback attack //flag2 = crit ? //flag3 = sweep attack if (flag && !flag2 && !flag1 && this.onGround && d0 < (double)this.getAIMoveSpeed()) { ItemStack itemstack = this.getHeldItem(EnumHand.MAIN_HAND); if (itemstack.getItem() instanceof ItemSword) { flag3 = true; } }
Win 10, Java 8
relates to
The
BugWhen sitting/driving in a minecart and then hitting Mobs with a sword, the sweep attack doesn't seem to work.
Code
AnalysisThe following is from the method net.minecraft.entity.EntityPlayer.attackTargetEntityWithCurrentItem(Entity targetEntity).
In order to sweep attack, the code checks that the player is on the ground. When a player is in a minecart, the boolean onGround is false.
double d0 = (double)(this.distanceWalkedModified - this.prevDistanceWalkedModified); //flag = full weapon cooldown //flag1 = sprint/knockback attack //flag2 = crit ? //flag3 = sweep attack if (flag && !flag2 && !flag1 && this.onGround && d0 < (double)this.getAIMoveSpeed()) { ItemStack itemstack = this.getHeldItem(EnumHand.MAIN_HAND); if (itemstack.getItem() instanceof ItemSword) { flag3 = true; } }The bug
When sitting/driving in a minecart and then hitting Mobs with a sword, the sweep attack doesn't seem to work.
Code analysis
The following is from the method net.minecraft.entity.EntityPlayer.attackTargetEntityWithCurrentItem(Entity targetEntity).
In order to sweep attack, the code checks that the player is on the ground. When a player is in a minecart, the boolean onGround is false.
double d0 = (double)(this.distanceWalkedModified - this.prevDistanceWalkedModified); //flag = full weapon cooldown //flag1 = sprint/knockback attack //flag2 = crit ? //flag3 = sweep attack if (flag && !flag2 && !flag1 && this.onGround && d0 < (double)this.getAIMoveSpeed()) { ItemStack itemstack = this.getHeldItem(EnumHand.MAIN_HAND); if (itemstack.getItem() instanceof ItemSword) { flag3 = true; } }
relates to
The bug
When sitting/driving in a minecart and then hitting Mobs with a sword, the sweep attack doesn't seem to work.
Code analysis
The following is from the method net.minecraft.entity.EntityPlayer.attackTargetEntityWithCurrentItem(Entity targetEntity).
In order to sweep attack, the code checks that the player is on the ground. When a player is in a minecart, the boolean onGround is false.
double d0 = (double)(this.distanceWalkedModified - this.prevDistanceWalkedModified); //flag = full weapon cooldown //flag1 = sprint/knockback attack //flag2 = crit?//flag3 = sweep attack if (flag && !flag2 && !flag1 && this.onGround&& d0 < (double)this.getAIMoveSpeed()) { ItemStack itemstack = this.getHeldItem(EnumHand.MAIN_HAND); if (itemstack.getItem() instanceof ItemSword) { flag3 = true; } }The bug
When sitting/driving in a minecart and then hitting Mobs with a sword, the sweep attack doesn't seem to work.
Code analysis
The following is from the method net.minecraft.entity.EntityPlayer.attackTargetEntityWithCurrentItem(Entity targetEntity).
In order to sweep attack, the code checks that the player is on the ground. When a player is in a minecart, the boolean onGround is false. A way to fix this would be to check with the OR operator if the player is riding.
double d0 = (double)(this.distanceWalkedModified - this.prevDistanceWalkedModified); //flag = full weapon cooldown //flag1 = sprint/knockback attack //flag2 = critical hit //flag3 = sweep attack if (flag && !flag2 && !flag1 && this.onGround || this.isRiding() && d0 < (double)this.getAIMoveSpeed()) { ItemStack itemstack = this.getHeldItem(EnumHand.MAIN_HAND); if (itemstack.getItem() instanceof ItemSword) { flag3 = true; } }
is duplicated by
The bug
When sitting/driving in a minecart and then hitting Mobs with a sword, the sweep attack doesn't seem to work.
Code analysis
The following is from the method net.minecraft.entity.EntityPlayer.attackTargetEntityWithCurrentItem(Entity targetEntity).
In order to sweep attack, the code checks that the player is on the ground. When a player is in a minecart, the boolean onGround is false. A way to fix this would be to check with the OR operator if the player is riding.
double d0 = (double)(this.distanceWalkedModified - this.prevDistanceWalkedModified); //flag = full weapon cooldown //flag1 = sprint/knockback attack //flag2 = critical hit //flag3 = sweep attack if (flag && !flag2 && !flag1 && this.onGround || this.isRiding() && d0 < (double)this.getAIMoveSpeed()) { ItemStack itemstack = this.getHeldItem(EnumHand.MAIN_HAND); if (itemstack.getItem() instanceof ItemSword) { flag3 = true; } }The Bug:
The sweeping attack doesn't work whilst riding minecarts.
Steps to Reproduce:
- Place down a rail and a minecart
- Summon a husk with NoAI:1b.
/summon minecraft:husk ~ ~ ~ {NoAI:1b}
- Get inside of the minecart and obtain a sword.
- Attempt to damage the husk by using a sweeping attack.
- →
Notice how the sweeping attack doesn't work whilst riding minecarts.
Code Analysis:
The following is from the method net.minecraft.entity.EntityPlayer.attackTargetEntityWithCurrentItem(Entity targetEntity).
In order to sweep attack, the code checks that the player is on the ground. When a player is in a minecart, the boolean onGround is false. A way to fix this would be to check with the OR operator if the player is riding.
double d0 = (double)(this.distanceWalkedModified - this.prevDistanceWalkedModified); //flag = full weapon cooldown //flag1 = sprint/knockback attack //flag2 = critical hit //flag3 = sweep attack if (flag && !flag2 && !flag1 && this.onGround || this.isRiding() && d0 < (double)this.getAIMoveSpeed()) { ItemStack itemstack = this.getHeldItem(EnumHand.MAIN_HAND); if (itemstack.getItem() instanceof ItemSword) { flag3 = true; } }
The Bug:
The sweeping attack doesn't work whilst riding minecarts.
Steps to Reproduce:
- Place down a rail and a minecart
- Summon a husk with NoAI:1b.
/summon minecraft:husk ~ ~ ~ {NoAI:1b}
- Get inside of the minecart and obtain a sword.
- Attempt to damage the husk by using a sweeping attack.
- →
Notice how the sweeping attack doesn't work whilst riding minecarts.
Code Analysis:
The following is from the method net.minecraft.entity.EntityPlayer.attackTargetEntityWithCurrentItem(Entity targetEntity).
In order to sweep attack, the code checks that the player is on the ground. When a player is in a minecart, the boolean onGround is false. A way to fix this would be to check with the OR operator if the player is riding.
double d0 = (double)(this.distanceWalkedModified - this.prevDistanceWalkedModified); //flag = full weapon cooldown //flag1 = sprint/knockback attack //flag2 = critical hit //flag3 = sweep attack if (flag && !flag2 && !flag1 && this.onGround || this.isRiding() && d0 < (double)this.getAIMoveSpeed()) { ItemStack itemstack = this.getHeldItem(EnumHand.MAIN_HAND); if (itemstack.getItem() instanceof ItemSword) { flag3 = true; } }
Sweep attack doesn't work when sitting in aminecartThe sweeping attack doesn't work whilst riding minecarts
The Bug:
The sweeping attack doesn't work whilst riding minecarts.
Steps to Reproduce:
- Place down a rail and a minecart
- Summon a husk with NoAI:1b.
/summon minecraft:husk ~ ~ ~ {NoAI:1b}
- Get inside of the minecart and obtain a sword.
- Attempt to damage the husk by using a sweeping attack.
- →
Notice how the sweeping attack doesn't work whilst riding minecarts.
Code Analysis:
The following is from the method net.minecraft.entity.EntityPlayer.attackTargetEntityWithCurrentItem(Entity targetEntity).
In order to sweep attack, the code checks that the player is on the ground. When a player is in a minecart, the boolean onGround is false. A way to fix this would be to check with the OR operator if the player is riding.
double d0 = (double)(this.distanceWalkedModified - this.prevDistanceWalkedModified); //flag = full weapon cooldown //flag1 = sprint/knockback attack //flag2 = critical hit //flag3 = sweep attack if (flag && !flag2 && !flag1 && this.onGround || this.isRiding() && d0 < (double)this.getAIMoveSpeed()) { ItemStack itemstack = this.getHeldItem(EnumHand.MAIN_HAND); if (itemstack.getItem() instanceof ItemSword) { flag3 = true; } }The Bug:
The sweeping attack doesn't work whilst riding minecarts.
Steps to Reproduce:
- Place down a rail and a minecart
- Summon a husk with NoAI:1b.
/summon minecraft:husk ~ ~ ~ {NoAI:1b}
- Get inside of the minecart and obtain a sword.
- Attempt to damage the husk by using a sweeping attack.
- →
Notice how the sweeping attack doesn't work whilst riding minecarts.
Code Analysis:
The following is from the method net.minecraft.entity.EntityPlayer.attackTargetEntityWithCurrentItem(Entity targetEntity).
In order to sweep attack, the code checks that the player is on the ground. When a player is in a minecart, the boolean onGround is false. A way to fix this would be to check with the OR operator if the player is riding.
double d0 = (double)(this.distanceWalkedModified - this.prevDistanceWalkedModified); //flag = full weapon cooldown //flag1 = sprint/knockback attack //flag2 = critical hit //flag3 = sweep attack if (flag && !flag2 && !flag1 && this.onGround || this.isRiding() && d0 < (double)this.getAIMoveSpeed()) { ItemStack itemstack = this.getHeldItem(EnumHand.MAIN_HAND); if (itemstack.getItem() instanceof ItemSword) { flag3 = true; } }
The Bug:
The sweeping attack doesn't work whilst riding minecarts.
Steps to Reproduce:
- Place down a rail and a minecart
- Summon a husk with NoAI:1b.
/summon minecraft:husk ~ ~ ~ {NoAI:1b}
- Get inside of the minecart and obtain a sword.
- Attempt to damage the husk by using a sweeping attack.
- →
Notice how the sweeping attack doesn't work whilst riding minecarts.
Code Analysis:The following is from the method net.minecraft.entity.EntityPlayer.attackTargetEntityWithCurrentItem(Entity targetEntity).
In order to sweep attack, the code checks that the player is on the ground. When a player is in a minecart, the boolean onGround is false. A way to fix this would be to check with the OR operator if the player is riding.
double d0 = (double)(this.distanceWalkedModified - this.prevDistanceWalkedModified); //flag = full weapon cooldown //flag1 = sprint/knockback attack //flag2 = critical hit //flag3 = sweep attack if (flag && !flag2 && !flag1 && this.onGround || this.isRiding() && d0 < (double)this.getAIMoveSpeed()) { ItemStack itemstack = this.getHeldItem(EnumHand.MAIN_HAND); if (itemstack.getItem() instanceof ItemSword) { flag3 = true; } }The Bug:
The sweeping attack doesn't work whilst riding minecarts.
Steps to Reproduce:
- Place down a rail and a minecart
- Summon a husk with NoAI:1b.
/summon minecraft:husk ~ ~ ~ {NoAI:1b}
- Get inside of the minecart and obtain a sword.
- Attempt to damage the husk by using a sweeping attack.
- →
Notice how the sweeping attack doesn't work whilst riding minecarts.
Expected Behavior:
The expected behavior would be that the sweeping attack would work whilst riding minecarts.
Code Analysis:
The following is from the method net.minecraft.entity.EntityPlayer.attackTargetEntityWithCurrentItem(Entity targetEntity).
In order to sweep attack, the code checks that the player is on the ground. When a player is in a minecart, the boolean onGround is false. A way to fix this would be to check with the OR operator if the player is riding.
double d0 = (double)(this.distanceWalkedModified - this.prevDistanceWalkedModified); //flag = full weapon cooldown //flag1 = sprint/knockback attack //flag2 = critical hit //flag3 = sweep attack if (flag && !flag2 && !flag1 && this.onGround || this.isRiding() && d0 < (double)this.getAIMoveSpeed()) { ItemStack itemstack = this.getHeldItem(EnumHand.MAIN_HAND); if (itemstack.getItem() instanceof ItemSword) { flag3 = true; } }
The Bug:
The sweeping attack doesn't work whilst riding minecarts.
Steps to Reproduce:
- Place down a rail and a minecart
- Summon a husk with NoAI:1b.
/summon minecraft:husk ~ ~ ~ {NoAI:1b}
- Get inside of the minecart and obtain a sword.
- Attempt to damage the husk by using a sweeping attack.
- →
Notice how the sweeping attack doesn't work whilst riding minecarts.
Expected Behavior:
The
expected behavior would be that thesweeping attack would work whilst riding minecarts.Code Analysis:
The following is from the method net.minecraft.entity.EntityPlayer.attackTargetEntityWithCurrentItem(Entity targetEntity).
In order to sweep attack, the code checks that the player is on the ground. When a player is in a minecart, the boolean onGround is false. A way to fix this would be to check with the OR operator if the player is riding.
double d0 = (double)(this.distanceWalkedModified - this.prevDistanceWalkedModified); //flag = full weapon cooldown //flag1 = sprint/knockback attack //flag2 = critical hit //flag3 = sweep attack if (flag && !flag2 && !flag1 && this.onGround || this.isRiding() && d0 < (double)this.getAIMoveSpeed()) { ItemStack itemstack = this.getHeldItem(EnumHand.MAIN_HAND); if (itemstack.getItem() instanceof ItemSword) { flag3 = true; } }The Bug:
The sweeping attack doesn't work whilst riding minecarts.
Steps to Reproduce:
- Place down a rail and a minecart
- Summon a husk with NoAI:1b.
/summon minecraft:husk ~ ~ ~ {NoAI:1b}
- Get inside of the minecart and obtain a sword.
- Attempt to damage the husk by using a sweeping attack.
Observed Behavior:
The sweeping attack doesn't work whilst riding minecarts.
Expected Behavior:
The sweeping attack would work whilst riding minecarts.
Code Analysis:
The following is from the method net.minecraft.entity.EntityPlayer.attackTargetEntityWithCurrentItem(Entity targetEntity).
In order to sweep attack, the code checks that the player is on the ground. When a player is in a minecart, the boolean onGround is false. A way to fix this would be to check with the OR operator if the player is riding.
double d0 = (double)(this.distanceWalkedModified - this.prevDistanceWalkedModified); //flag = full weapon cooldown //flag1 = sprint/knockback attack //flag2 = critical hit //flag3 = sweep attack if (flag && !flag2 && !flag1 && this.onGround || this.isRiding() && d0 < (double)this.getAIMoveSpeed()) { ItemStack itemstack = this.getHeldItem(EnumHand.MAIN_HAND); if (itemstack.getItem() instanceof ItemSword) { flag3 = true; } }
The Bug:
The sweeping attack doesn't work whilst riding minecarts.
Steps to Reproduce:
- Place down a rail and a minecart
- Summon a husk with NoAI:1b.
/summon minecraft:husk ~ ~ ~ {NoAI:1b}
- Get inside of the minecart and obtain a sword.
- Attempt to damage the husk by using a sweeping attack.
Observed Behavior:
The sweeping attack doesn't work whilst riding minecarts.
Expected Behavior:
The sweeping attack would work whilst riding minecarts.
Code Analysis:
The following is from the method net.minecraft.entity.EntityPlayer.attackTargetEntityWithCurrentItem(Entity targetEntity).
In order to sweep attack, the code checks that the player is on the ground. When a player is in a minecart, the boolean onGround is false. A way to fix this would be to check with the OR operator if the player is riding.
double d0 = (double)(this.distanceWalkedModified - this.prevDistanceWalkedModified); //flag = full weapon cooldown //flag1 = sprint/knockback attack //flag2 = critical hit //flag3 = sweep attack if (flag && !flag2 && !flag1 && this.onGround || this.isRiding() && d0 < (double)this.getAIMoveSpeed()) { ItemStack itemstack = this.getHeldItem(EnumHand.MAIN_HAND); if (itemstack.getItem() instanceof ItemSword) { flag3 = true; } }The Bug:
The sweeping attack doesn't work whilst riding minecarts.
Steps to Reproduce:
- Place down a rail and a minecart
- Summon a husk with NoAI:1b.
/summon minecraft:husk ~ ~ ~ {NoAI:1b}
- Get inside of the minecart and obtain a sword.
- Attempt to damage the husk by using a sweeping attack.
- Take note as to whether or not the sweeping attack works whilst riding minecarts.
Observed Behavior:
The sweeping attack doesn't work whilst riding minecarts.
Expected Behavior:
The sweeping attack would work whilst riding minecarts.
Code Analysis:
The following is from the method net.minecraft.entity.EntityPlayer.attackTargetEntityWithCurrentItem(Entity targetEntity).
In order to perform a sweeping attack, the code checks that the player is on the ground. When a player is in a minecart, the boolean onGround is false. A way to fix this would be to check with the OR operator if the player is riding.
double d0 = (double)(this.distanceWalkedModified - this.prevDistanceWalkedModified); //flag = full weapon cooldown //flag1 = sprint/knockback attack //flag2 = critical hit //flag3 = sweep attack if (flag && !flag2 && !flag1 && this.onGround || this.isRiding() && d0 < (double)this.getAIMoveSpeed()) { ItemStack itemstack = this.getHeldItem(EnumHand.MAIN_HAND); if (itemstack.getItem() instanceof ItemSword) { flag3 = true; } }
The Bug:
Thesweeping attackdoesn't workwhilst ridingminecarts.Steps to Reproduce:
- Place down a rail and a minecart
- Summon a husk with NoAI:1b.
/summon minecraft:husk ~ ~ ~ {NoAI:1b}
- Get inside of the minecart and obtain a sword.
- Attempt to damage the husk by using a sweeping attack.
- Take note as to whether or not
thesweeping attackworks whilst ridingminecarts.Observed Behavior:
The sweeping attack doesn't work
whilst riding minecarts.Expected Behavior:
The sweeping attack would work
whilst riding minecarts.Code Analysis
:The following is from the method net.minecraft.entity.EntityPlayer.attackTargetEntityWithCurrentItem(Entity targetEntity).
In order to perform a sweeping attack, the code checks that the player is on the ground. When a player is in a minecart, the boolean onGround is false. A way to fix this would be to check with the OR operator if the player is riding.
double d0 = (double)(this.distanceWalkedModified - this.prevDistanceWalkedModified); //flag = full weapon cooldown //flag1 = sprint/knockback attack //flag2 = critical hit //flag3 = sweep attack if (flag && !flag2 && !flag1 && this.onGround || this.isRiding() && d0 < (double)this.getAIMoveSpeed()) { ItemStack itemstack = this.getHeldItem(EnumHand.MAIN_HAND); if (itemstack.getItem() instanceofItemSword) { flag3 =true; } }The Bug:
You cannot perform sweeping attacks whilst riding entities.
Steps to Reproduce:
- Place down a rail and a minecart
- Summon a husk with NoAI:1b.
/summon minecraft:husk ~ ~ ~ {NoAI:1b}
- Get inside of the minecart and obtain a sword.
- Attempt to damage the husk by using a sweeping attack.
- Take note as to whether or not you can perform sweeping attacks whilst riding entities.
Observed Behavior:
The sweeping attack doesn't work.
Expected Behavior:
The sweeping attack would work.
Code Analysis:
The following is based on a decompiled version of Minecraft 1.18.1 using MCP-Reborn.
net.minecraft.world.entity.player.Player.javapublic 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 attackIn 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.
Thesweeping attackdoesn't workwhilst ridingminecartsYou cannot perform sweeping attacks whilst riding entities
The Bug:
You cannot perform sweeping attacks whilst riding entities.
Steps to Reproduce:
- Place down a rail and a minecart
- Summon a husk with NoAI:1b.
/summon minecraft:husk ~ ~ ~ {NoAI:1b}
- Get inside of the minecart and obtain a sword.
- Attempt to damage the husk by using a sweeping attack.
- Take note as to whether or not you can perform sweeping attacks whilst riding entities.
Observed Behavior:
The sweeping attack doesn't work.
Expected Behavior:
The sweeping attack would work.
Code Analysis:
Code analysis by [Mod] Avoma and [Mod] 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.javapublic 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 attackIn 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.
The Bug:
You cannot perform sweeping attacks whil
striding entities.Steps to Reproduce:
- Place down a rail and a minecart
- Summon a husk with NoAI:1b.
/summon minecraft:husk ~ ~ ~ {NoAI:1b}
- Get inside of the minecart and obtain a sword.
- Attempt to damage the husk by using a sweeping attack.
- Take note as to whether or not you can perform sweeping attacks whil
striding entities.Observed Behavior:
The sweeping attack doesn't work.
Expected Behavior:
The sweeping attack would work.
Code Analysis:
Code analysis by [Mod] Avoma and [Mod] 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.javapublic 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 attackIn 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.
The Bug:
You cannot perform sweeping attacks while riding entities.
Steps to Reproduce:
- 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}- Get inside of the minecart and obtain a sword.
- Attempt to damage the husk by using a sweeping attack.
- 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 [Mod] Avoma and [Mod] 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.javapublic 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 attackIn 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.
You cannot perform sweeping attacks whilstriding entitiesYou cannot perform sweeping attacks while riding entities
relates to
relates to
Thank you for your report!
However, we are already tracking this issue, and this report is a Duplicate of MC-111833, which is a report that has not been resolved yet.
If you want, you can upvote the parent ticket, and enable watching to receive any updates about it - if you believe you have any information that may be important for this issue, please leave a comment on the parent. Please also use the search function in the future to prevent duplicate reports.
Quick Links:
📓 Issue Guidelines – 🛠 Community Support – 📧 Customer Support – ✍️ Feedback and Suggestions – 📖 Game Wiki
💬 Mojira Subreddit – 💬 Mojira Discord
Relates to MC-111833

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.
Can confirm in 21w05b.
Can confirm in 21w06a.
Can confirm in 21w08b. Video attached.
Can confirm in 1.16.5.
Can confirm in 21w11a.
Can confirm in 21w17a.
Affects 1.17
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.