mojira.dev
MC-259710

Flaming arrows shot by players do not break powder snow when mob griefing is disabled

How to reproduce:

  1. Run command "/gamerule mobGriefing false"

  2. Place Powder Snow

  3. Obtain a Bow enchanted with Flame

  4. Shoot the Powder Snow with the Bow

Expected result: the snow is broken.

Observed behavior: the snow is not broken, and the arrow passes right through.

I feel that this is unintentional because Player-shot arrows aren't created by mobs, and thus should not be affected by the game rule.

Linked issues

Comments 1

Code analysis (Mojang mappings, 23w05a): PowderSnowBlock#entityInside(...) checks if the intersecting entity is on fire and if mob griefing is enabled or the entity is a player. As arrows are not players, they cannot destroy the block:

...
      if ($$3.isOnFire() && ($$1.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING) || $$3 instanceof Player) && $$3.mayInteract($$1, $$2)) {
          $$1.destroyBlock($$2, false);
      }
...

I imagine something like this could be used instead:

...
        boolean isPlayerOrPlayerFiredArrow = false;
        if ($$3 instanceof Player) {
            isPlayerOrPlayerFiredArrow = true;
        }
        if (!isPlayerOrPlayerFiredArrow && $$3 instanceof Arrow) {
            Arrow arrow = (Arrow)$$3;
            Entity arrowOwner = arrow.getOwner();
            if (arrowOwner != null) {
                if (arrowOwner instanceof Player) {
                    isPlayerOrPlayerFiredArrow = true;
                }
            }
        }
        if ($$3.isOnFire() && ($$1.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING) || isPlayerOrPlayerFiredArrow) && $$3.mayInteract($$1, $$2)) {
            $$1.destroyBlock($$2, false);
        }
...

[Mod] turbo

(Unassigned)

Confirmed

Platform

Low

Block states, Commands

powder_snow

1.19.3, 23w05a, 1.20.2, 1.21.6 Pre-Release 2

Retrieved