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

Riding entities are updated twice in the same tick when ridden entity is marked as dead (summoned via command blocks)



    • Icon: Bug Bug
    • Resolution: Unresolved
    • None
    • Minecraft 1.8.2-pre4, Minecraft 15w46a, Minecraft 1.10.2, Minecraft 16w32b, Minecraft 16w38a, Minecraft 16w39b, Minecraft 16w39c, Minecraft 16w40a, Minecraft 16w41a, Minecraft 16w42a, Minecraft 16w43a, Minecraft 16w44a, Minecraft 1.11 Pre-Release 1, Minecraft 1.11, Minecraft 16w50a, Minecraft 1.11.1, Minecraft 1.11.2, Minecraft 17w06a, Minecraft 17w13b, Minecraft 17w15a, Minecraft 17w16b, Minecraft 17w17a, Minecraft 17w18b, Minecraft 1.12 Pre-Release 2, Minecraft 1.12.1, Minecraft 1.12.2, 1.16.2 Pre-release 1, 1.16.2 Pre-release 2, 1.16.2 Release Candidate 1, 1.16.2
    • Confirmed
    • Entities


      The bug

      Riding entities are updated twice in the same tick when the ridden entity is marked as dead.

      How to reproduce

      1. Add a scoreboard objective
        /scoreboard objectives add tickCounter dummy
      2. Have the objective be displayed on the sidebar
        /scoreboard objectives setdisplay sidebar tickCounter
      3. Place a repeating command with the following command and activate it
        /execute @e[type=falling_block,limit=1] ~ ~ ~ /scoreboard players add ticks tickCounter 1
      4. Place a command block with the following command and activate it
        /summon falling_block ~ ~1 ~ {Time:587,Passengers:[{id:"falling_block",Time:587,Passengers:[{id:"falling_block",Time:587,Passengers:[{id:"falling_block",Time:587}]}]}]}

        → You will see that the score stops at 12, which means the top most falling block was 11 ticks alive while it should have been 13 ticks (600 - 587)

      5. Reset the ticks score
        /scoreboard players reset ticks tickCounter
      6. Summon a single falling block via a command block
        /summon falling_block ~ ~ ~ {Time:587,NoGravity:1b}

        → You will see that the score correctly stops at 13

      Code analysis

      Based on 1.11.2 decompiled using MCP 9.35 rc1

      The method net.minecraft.world.World.updateEntities() updates all entities if they are not riding an entity or the ridden entity is dead. The method net.minecraft.world.World.updateEntityWithOptionalForce(Entity, boolean) then updates the the passengers of an entity.
      The problem is that if an entity is dead it still has its passengers set which are then updated. However, when a passenger is updated (Entity.updateRidden()) and notices that the ridden entity is dead it dismounts itself. This means when the method World.updateEntities() tests in the same tick if the initial passenger entity is riding an entity, the entity is not skipped and therefor updated a second time.




            Unassigned Unassigned
            marcono1234 [Mod] Marcono1234
            9 Vote for this issue
            9 Start watching this issue