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

Explosions have directional effects on entities

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • None
    • 1.17.1, 21w42a, 21w43a, 1.18 Pre-release 1, 22w18a, 1.20.2
    • None
    • Confirmed
    • Entities
    • Normal
    • Platform

      Example 1:
      Place a TNT, then place 4 obsidians around it. Drop 4 items at four corners outside and make sure the collision boxes of these items touch its two nearest obsidians. Picture 1 depicts the exact way.
      Then prime the tnt and we can find that only the item at the north-west corner blew up.

      Example 2:
      We make the explosion center of TNT at y=5, then we do two tests.
      First, we place an floating item at y=4.917 and an obisidian at y=5, so that only the bottom part of the item is directly exposed to TNT. After the explosion, the item disappears.
      Second,we an floating item at y=4.833 and an obisidian at y=4, so that only the top part of the item is directly exposed to TNT. In this situation the item will not explode.
      In each test, the item exposes its part of 1/12 height, but the outcome changes.
      Picture 2 and Picture 3 show the position of the item and obsidian, and the red arrow stands for the explosion radial from tnt.

      In these two examples, we find that TNT's influence on entities is directional.

      After reading the source code, I am sure there's an error in the process of getting the exposure of an entity. In picture 4, Xdelta and Zdelta are only proportions, but they are added to the lerped X and Z value. It misses the lerp process, so in X and Z direction, unexpected deviation comes about.
      The picture BUG_FIX shows the exact position of the error and gives a solution which proves to be feasible in carpet-fixes mod.

      In example 1, the bounding box of item has a width of 0.25. The error, the missing lerp, finally causes such effect that the explosion detection point is literally out of its bounding box, and north-east to it, and being in the same block of the explosion. That's why the item at the north-west corner disappears. The explosion consider part of it with its range, which should not happen.

      Moreover, since there's no Ydelta to modify the Y-value, the detection only includes the bottom part of the entity. That accounts for example 2. I am not sure whether it is 'working as intended', but I hate directional features.

      To conclude, the exposure of entities is direction-based, closer to Y minus, and the X and Z deviation is based on its width. When its X or Z is less than 0.5, the detection point is so inaccurate that it come out of the bounding box of the entity, which is far from reasonable.

        1. BUG_FIX.jpg
          BUG_FIX.jpg
          31 kB
        2. MC-232355.mp4
          7.62 MB
        3. P1.png
          P1.png
          55 kB
        4. P2.png
          P2.png
          178 kB
        5. P3.png
          P3.png
          76 kB
        6. Source Code of Getting Exposure.JPG
          Source Code of Getting Exposure.JPG
          94 kB

            Unassigned Unassigned
            DawNemo He Dong
            Votes:
            25 Vote for this issue
            Watchers:
            7 Start watching this issue

              Created:
              Updated:
              CHK: