mojira.dev
MC-262422

Lightning bolts during thunderstorms can strike players in spectator game mode

During thunderstorm, random lightning strikes can hit players in spectator game mode.

In ServerLevel.java, there are findLightningTargetAround(getBlockRandomPosition(...)). That method calls getEntitiesOfClass(...) that checks for isAlive of nearby entities, but not for game mode of it in case of player (so creative players are also affected by this, even though they can't take damage).

Comments 3

How does this can effect the gameplay? Also, could you give a "Steps to Reproduce" and/or a video for this issue?

Usually lightning strikes at the block denoted by

this.getHeightmapPos(Heightmap.Types.MOTION_BLOCKING, pos)

or, if an entity is found in a 3x3 box around the lightning, it strikes at the location of the entity (or selects a random one if there are multiple).

Spectators, as of right now, count towards the above exception, causing lightning to potentially strike at their location if they are found in the 3x3 AABB around the initial strike position, giving away the spectator position as well as preventing the lightning from properly striking either at its default location based on the highmap or even another entity in the 3x3 AABB.

You can replicate this by causing a thunderstorm via the weather command, flying above the ground level in spectator and waiting for a lightning strike to strike your in-air location.

Can confirm for 1.20 Pre-release 5

molore

(Unassigned)

Community Consensus

Platform

Normal

Entities, Player

1.19.4, 1.20 Pre-release 5

Retrieved