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

Wrong attack radius calculation damages/kills entities through blocks and corners

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • 23w33a
    • Minecraft 1.4.3, Snapshot 13w05b, Minecraft 1.5.1, Minecraft 1.5.2, Minecraft 1.6.1, Minecraft 1.6.2, Minecraft 1.7.2, Minecraft 1.7.5, Minecraft 14w11b, Minecraft 1.7.6-pre1, Minecraft 1.7.6-pre2, Minecraft 14w18b, Minecraft 1.8-pre1, Minecraft 1.8-pre2, Minecraft 1.8, Minecraft 1.8.1, Minecraft 1.8.3, Minecraft 1.8.8, Minecraft 15w33b, Minecraft 15w33c, Minecraft 15w47c, Minecraft 15w49a, Minecraft 1.8.9, Minecraft 15w50a, Minecraft 16w02a, Minecraft 16w05b, Minecraft 16w06a, Minecraft 1.9 Pre-Release 2, Minecraft 1.9 Pre-Release 3, Minecraft 1.9 Pre-Release 4, Minecraft 1.9, Minecraft 1.9.1 Pre-Release 1, Minecraft 1.9.1 Pre-Release 3, Minecraft 1.9.2, Minecraft 1.9.4, Minecraft 1.10, Minecraft 1.10.2, Minecraft 16w32a, Minecraft 16w32b, Minecraft 16w33a, Minecraft 16w35a, Minecraft 16w40a, Minecraft 16w41a, Minecraft 16w44a, Minecraft 1.11 Pre-Release 1, Minecraft 1.11.2, Minecraft 17w06a, Minecraft 1.12 Pre-Release 2, Minecraft 1.12 Pre-Release 6, Minecraft 1.12, Minecraft 1.12.1, Minecraft 1.12.2, Minecraft 18w03b, Minecraft 18w07c, Minecraft 18w21b, Minecraft 1.13-pre3, Minecraft 1.13, Minecraft 1.13.1, Minecraft 1.13.2, Minecraft 18w43c, Minecraft 18w47b, Minecraft 18w50a, Minecraft 19w04b, Minecraft 19w05a, Minecraft 19w11b, Minecraft 19w12b, Minecraft 19w13a, Minecraft 19w14a, Minecraft 1.14 Pre-Release 1, Minecraft 1.14 Pre-Release 2, Minecraft 1.14 Pre-Release 4, Minecraft 1.14 Pre-Release 5, Minecraft 1.14, Minecraft 1.14.1, Minecraft 1.14.2 Pre-Release 1, Minecraft 1.14.2 Pre-Release 2, Minecraft 1.14.2, Minecraft 1.14.3, Minecraft 1.14.4 Pre-Release 1, Minecraft 1.14.4 Pre-Release 3, Minecraft 1.14.4 Pre-Release 4, Minecraft 1.14.4 Pre-Release 5, Minecraft 1.14.4 Pre-Release 6, 1.14.4, 19w34a, 19w35a, 19w36a, 19w37a, 19w38b, 19w39a, 19w40a, 19w41a, 19w42a, 19w45b, 19w46b, 1.15 Pre-release 1, 1.15 Pre-Release 2, 1.15 Pre-release 3, 1.15 Pre-release 4, 1.15 Pre-release 5, 1.15 Pre-release 6, 1.15 Pre-release 7, 1.15, 1.15.1, 1.15.1 Pre-release 1, 1.15.2 Pre-Release 1, 1.15.2 Pre-release 2, 1.15.2, 20w06a, 20w07a, 20w08a, 20w09a, 20w10a, 20w11a, 20w13a, 20w13b, 20w15a, 20w17a, 20w18a, 20w19a, 20w20a, 20w20b, 20w21a, 1.16 Pre-release 2, 1.16 Pre-release 3, 1.16 Pre-release 6, 1.16 Pre-release 7, 1.16 Pre-release 8, 1.16 Release Candidate 1, 1.16, 1.16.1, 20w28a, 20w29a, 20w30a, 1.16.2 Pre-release 1, 1.16.2 Pre-release 2, 1.16.2 Pre-release 3, 1.16.2 Release Candidate 1, 1.16.2 Release Candidate 2, 1.16.2, 1.16.3 Release Candidate 1, 1.16.3, 1.16.4 Pre-release 1, 1.16.4 Pre-release 2, 1.16.4 Release Candidate 1, 1.16.4, 20w45a, 20w46a, 20w48a, 20w49a, 20w51a, 21w03a, 1.16.5, 21w05a, 21w05b, 21w06a, 21w07a, 21w08b, 21w10a, 21w11a, 21w13a, 21w14a, 21w20a, 1.17 Pre-release 2, 1.17 Release Candidate 1, 1.17, 1.17.1, 21w39a, 21w40a, 1.18 Pre-release 1, 1.18 Pre-release 5, 1.18, 1.18.1 Pre-release 1, 1.18.1, 22w05a, 22w06a, 1.18.2, 22w12a, 22w14a, 22w17a, 1.19, 1.19.1 Release Candidate 1, 1.19.1 Pre-release 5, 1.19.2, 1.19.3, 1.19.4, 23w13a, 1.20.1, 23w32a
    • Confirmed
    • Entities, Hitboxes
    • Very Important
    • Platform

      The bug

      Mobs can attack you through blocks and corners due to miscalculation of attack radius.

      How to reproduce

      1. Build a completely sealed off house with no windows or doors from opaque blocks like planks or cobblestone or the like, leave some blocks in the inventory for you to place in step 7.
      2. Make a two-block tall one-block wide empty doorway in the wall for you to go through and to seal off with blocks in step 7.
      3. Outside the house, spawn a Ravager.
      4. Switch to survival mode.
      5. The Ravager should start going for you.
      6. Run in the house, let it hit you once through the empty doorway.
      7. Seal off the doorway with two blocks.

      Result: The Ravager is still able to hit the player, from about two blocks away, with a complete wall every possible place in between.
      Expected: The Ravager can't attack the player any more.

      Example

      An example can be seen in this comment.

      Old example

      I just created a villager in MCEdit with the Create Shops filter to have a custom shop. I saved it and launched MC. The villager started to run around normally in his house but then he went to the door where a zombie was knocking at (wooden door on normal difficulty) and the villager blinked red and got damage and after a few hits he died. The zombie killed him through a closed door and the villager did not run away he always came back to the door until he died.

      Additional informations

      From kingsupernova:
      There are a number of bug reports about attack radius that are all very similar. MC-2310, MC-18326, MC-50668, MC-63965, MC-71834, and MC-74907 are all about the attack radius of mobs extending through blocks. (Some mobs are more bugged than others, but it’s the same basic problem).

      There are also a few related issues:

      • MC-1297 is the same as the above, but for players.
      • MC-3059 is the same as the above, but for arrows.

      Code analysis

      Based on 1.11.2 decompiled using MCP 9.35 rc1

      The problem seems to be the method net.minecraft.entity.ai.EntityAIAttackMelee.checkAndPerformAttack(EntityLivingBase, double) and methods overriding it. They all only test if the mob to attack is in a certain radius to the attacker without testing if blocks are between them.

      Possible solutions

      Bounding box check

      The current behavior would be replaced by only allowing mobs to attack other mobs when their bounding boxes intersect.

      Ray casting

      The current behavior would be extended to require a ray cast from the attacker to the mob to attack (excluding liquids and blocks without collision box) to return no colliding blocks. Possible use y + height / 1.5 as attack height or have a method for mobs to define their attack height(s?). The height at which the mob to attack will be attacked could for example be y + height / 2 or with multiple tries depending on the height of the mob, for example

      for (int attackFraction = 0; attackFraction < height / 2; attackFraction++) {
          double attackHeight = y + height * ((attackFraction + 1.0) / (height / 2.0 + 1.0))
      }
      

        1. 2016-05-28_21.13.28.png
          2016-05-28_21.13.28.png
          772 kB
        2. after.png
          after.png
          601 kB
        3. attack_through_a_wall.gif
          attack_through_a_wall.gif
          2.84 MB
        4. before.png
          before.png
          660 kB
        5. ravager-headbutt-through-door.gif
          1.57 MB
        6. ravager-range-bug-slowmo.gif
          ravager-range-bug-slowmo.gif
          905 kB

            gnembon [Mojang] Gnembon
            markderickson [Mod] markderickson
            Votes:
            243 Vote for this issue
            Watchers:
            104 Start watching this issue

              Created:
              Updated:
              Resolved:
              CHK: