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

Substantial lag due to collisions even with collisionRule set to never

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • None
    • 1.14.4, 19w35a, 19w38b, 19w39a, 19w41a, 19w42a, 19w44a, 19w45a, 19w46a, 19w46b, 1.15 Pre-Release 2, 1.15 Pre-release 3, 1.15 Pre-release 4, 1.15.2, 20w10a, 20w11a, 20w12a, 20w14a, 20w15a, 20w18a, 20w22a, 1.16 Pre-release 2, 1.16 Pre-release 8, 1.16.1, 20w28a, 1.16.2 Pre-release 1, 1.16.5, 1.17.1, 21w40a, 1.18 Release Candidate 4, 1.18, 22w05a, 1.19 Pre-release 1
    • None
    • Confirmed
    • Collision, Performance
    • Normal
    • Platform

      The bug

      Entity collisions severely impact performance even with collisionRule set to never.

      How to reproduce

      1. Open a void world
      2. /gamerule maxEntityCramming 10000
        
      3. /team add noCollision
        
      4. /team modify noCollision collisionRule never
        
      5. /summon cow ~ ~ ~ {NoAI:1,Team:"noCollision"}
        
      6. Run a few times:
        /execute as @e[team=noCollision] at @s run summon cow ~ ~ ~ {NoAI:1,Team:"noCollision"}
        
      7. Open the SHIFT+F3 debug graph for root.tick.level.entities.regular.tick.minecraft:cow and notice that "push" takes most of the time despite the collision rule

      One can repeat the steps with NoAI bats and see that they don't cause lag as bats (effectively) have the proposed fix already implemented.

      Note that this bug affects all living entities within the same subchunk (a 16x16x16 unit of the world) and not only the same block.

      Code analysis (official mappings)

      The method LivingEntity.pushEntities calls the costly Level.getEntities even when it's known it will return an empty list.

      A proposed fix is to shortcut the method when the collision rule is set to never.

      Note that armor stands implement their own collision code but also suffer from this bug.

            Unassigned Unassigned
            Zonteek Zonteek
            Votes:
            22 Vote for this issue
            Watchers:
            10 Start watching this issue

              Created:
              Updated:
              CHK: