mojira.dev
MC-181129

Guardian beam is not rendered if targeted entity has ID 0, as it does not use the OptionalInt metadata type

The bug

The guardian beam is not rendered if the attacked entity has the entity id 0.  Guardians directly write the entity ID in an integer metadata field, and assume 0 means no target (unlike fireworks, which use an OptionalInt (MC-111480) to prevent this).

 

Since entity IDs start at 1 after 19w05a, this is unlikely to cause problems in practice, but it is still weird that one entity uses OptionalInt and the other doesn't.

Related issues

Comments

[Mod] Jingy

Considering this report has not been confirmed since 1.16.4, could you please update the report to include clear steps to reproduce it in the latest version? It would be helpful to know how to get a guardian to attack an entity with an ID of 0.

[Mod] Jingy

Tried again to reproduce this by creating a void world with no entities, summoning a squid first (to make sure it was the first entity), then a guardian, and the beam rendered as expected.

Viradex

@unknown I cannot reproduce it either, using the same method you stated. I even tried to summon a guardian and make it attack me, the player, in the void world, and it rendered the beam.

pokechu22

I don't have any good method of reproducing this. The issue still exists in 1.20.2 as it still used a VarInt instead of an OptVarInt then (see https://pokechu22.github.io/Burger/1.20.2.html#entities:guardian), but entity metadata broke in Burger for 1.21 (see https://pokechu22.github.io/Burger/1.21.html#entities:guardian) due to other internal changes so I can't directly confirm it.

I believe even in 1.15.2 this was not directly reproducible due to entity IDs starting at 1, and entity IDs would need to overflow for that to happen. That used to be a much bigger issue as mob spawning would use up an entity ID for each attempt at spawning an entity, even if it was rejected, so it was possible for it to go through all 4 billion values eventually on a long-running server, but I believe that was changed a while back (I don't remember when) and no longer happens. Otherwise it's mostly an easily avoidable gotcha with the protocol that would come up with e.g. custom servers.

pokechu22

(Unassigned)

Confirmed

Entities, Networking

beam, entity, guardian, targeting

1.15.2, 20w17a, 1.16.4

Retrieved