mojira.dev
MC-76858

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

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.

Attachments

Comments 11

I can't reproduce this. Even if I am at y=130 (example) and when executing the command no commandblocks will break. [1.8.2-pre4]

So the whole stack removed itself after spawning a structure or did the command block tower stayed the whole time?

Do the falling sand entities need to have those properties to cause the glitch? If not, could you provide a command to replicate this, without all the extra data.

executing the command cause that only the last 2 command blocks + redstone block get removed (for me), after spawning the grass layer all command blocks stay in there place.

@unknown: Well when they "get" removed you are also experiencing this bug. Maybe you turned doTileDrops off
@unknown: The problem is, creating such a command is pretty intense, but I will see what I can do... well happens with every kind of falling block

1 more comments

This report does not duplicate MC-35127

[Mod] redstonehelper

Reopened.

Cannot reproduce using reproduction steps in 20w07a. Also note that they might be faulty because the falling block tower is summoned not high enough in the air and summoning entities using command blocks happens at a different point of time than summoning in chat and therefore the correct tickCounter value for command blocks is 13 while for the chat it appears to be 14.

However, the code analysis still seems to be correct, so I would leave the report open for now.

reproduced via command blocks

Still works as described in 23w03a, although the 4th command should be updated to

/execute as @e[type=falling_block,limit=1] run scoreboard players add ticks tickCounter 1

As for whether this is really a bug and, if so, how important it is, I'm not really sure. I couldn't think of a meaningful scenario that would be affected by this.

marcono1234

(Unassigned)

Confirmed

Entities

entity, passengers, riding, riding-entities, stack, tick

Minecraft 1.8.2-pre4, Minecraft 15w46a, Minecraft 1.10.2, Minecraft 16w32b, Minecraft 16w38a, ..., 1.16.2 Pre-release 1, 1.16.2 Pre-release 2, 1.16.2 Release Candidate 1, 1.16.2, 1.21

Retrieved