mojira.dev
MC-313067

Snowballs can now knockback a player with shield blocking

As demonstrated in the video, other attacks do not cause knockback when blocked by a shield. Snowballs, however, can now bypass shields and inflict knockback. This is related to a change introduced in 26.4-snapshot-3, which granted projectile items—such as snowballs—the ability to deal knockback even when they inflict zero damage.

To address this, one could simply add a few checks near the KNOCKS_BACK_PLAYERS_EVEN_WITH_ZERO_DAMAGE item flag. In my view, however, MC-3179 should be treated as a bug that needs fixing, rather than as intended behavior. Isn't it rather strange that while any other entity can be knocked back by an attack dealing zero damage, players are the sole exception? Rather than maintaining a new, more complex item flag, it would be better to resolve MC-3179 as a bug—especially since the player community generally expects projectiles like snowballs and eggs to be capable of knocking back players. This is already the standard on many servers, such as MCC Island and Hypixel.

I hope the Mojang team can hold thorough discussions and decide on a course of action.

The relevant source code is here:
net/minecraft/world/entity/player/Player.java

public boolean hurtServer(final ServerLevel level, final DamageSource source, float damage) {
      if (this.isInvulnerableTo(level, source)) {
         return false;
      } else if (this.abilities.invulnerable && !source.is(DamageTypeTags.BYPASSES_INVULNERABILITY)) {
         return false;
      } else {
         this.noActionTime = 0;
         if (this.isDeadOrDying()) {
            return false;
         } else {
            this.removeEntitiesOnShoulder();
            if (source.scalesWithDifficulty()) {
               if (level.getDifficulty() == Difficulty.PEACEFUL) {
                  damage = 0.0F;
               }

               if (level.getDifficulty() == Difficulty.EASY) {
                  damage = Math.min(damage / 2.0F + 1.0F, damage);
               }

               if (level.getDifficulty() == Difficulty.HARD) {
                  damage = damage * 3.0F / 2.0F;
               }
            }

            if (damage == 0.0F) {
               ItemStack item = source.getWeaponItem();
               if (item == null || !item.is(ItemTags.KNOCKS_BACK_PLAYERS_EVEN_WITH_ZERO_DAMAGE)) {
                  return false;
               }
            }

            return super.hurtServer(level, source, damage);
         }
      }
   }

Attachments

Comments 1

Thank you for helping us improve Minecraft! We saved your files:

[media]

Kolleen

(Unassigned)

Unconfirmed

26.4 Snapshot 7

Retrieved