mojira.dev
MC-64623

Lightning bolts cannot be targeted by selectors

The bug

Lightning bolts (lightning_bolt) cannot be targeted by selectors.
However their id can be used as type argument value (explanation in this comment).

How to reproduce

Have two command blocks, one constantly spawning lightning bolts, the other running for example

/execute as @e[type=lightning_bolt] run say Found

Linked issues

Comments 11

Confirmed for 14w32d

A Lightning Bolt is not an existing entity.
In fact the moment it is "spawned" it will vanish again. (Can you call it spawning if it never existed to begin with?)
All you see is the "lightning bolt particle"

A Lighting Bolt won't be saved when you exit the game. It also has no nbt tags.
So I pretty much guess this is working as intended.

Is this still a concern in the current Minecraft version? If so, please update the affected versions in order to best aid Mojang ensuring bugs are still valid in the latest releases/pre-releases. If this has been done, we can reopen the issue.

Keep in mind that the "Resolved"-Status on this ticket just means "Answered", and that we are waiting for further information on whether this issue still exists or not. We will reopen it as soon as the requested information has been delivered.

Lightning bolts aren't entities. They are just, nothing. It's not an entity, it's just,a random texture that cannot do anything.

Lightning bolts are entities; quoting myself:

Target selectors obtain entities from the list of "spawned entities". Lightning bolts do not go in that list; instead, they go into a list of "weather effects". They are not deleted instantly; they exist for a fair amount of time.

Even further, lightning bolt entities do not have a savegame ID associated with them. "LightningBolt" is simply a special clause for the /summon command. Normally /summon will use your provided input to automatically create an entity from the EntityList class mapping, but if the input is "LightningBolt", then it manually creates a lightning bolt entity. In the same process, it also ignores your dataTag input.

The type parameter will throw an error for invalid savegame entity IDs, but you'll notice it does not do that for "LightningBolt" (i.e. type=LightningBolt). This is because the type parameter grabs a list of string IDs from the same tab-complete list that /summon uses. If the input into the type parameter is not among that list, the selector will throw an error. The type parameter specifically appends "Player" to that list, which is why "Player" does not show up in /summon's tab-complete.

Among that list is "LightningBolt", which is not actually a valid savegame entity ID; the tab-complete list will forcibly append it for use with /summon. Valid savegame IDs are those that appear within the EntityList class mapping, which is what the tab-complete function will grab from before forcibly appending the list with "LightningBolt". It is essentially only appended for usability with /summon.

As such, you can safely use type=LightningBolt without throwing an error only because the parameter thinks it's an appropriate ID, even though lightning bolts are *not* target-able in the first place. Even if they were added to that list but remained non-savegame entities, "LightningBolt" is still not associated with them because that ID is still a special use-case with /summon.

As a side-note: fishing bobbers are not savegame entities, hence they have no ID associated with them. Fishing bobbers, unlike lightning bolts, are added to the list of spawned entities, which is why they can be targeted by selectors while lightning bolts cannot be.


tl;dr: Lightning bolts are not targeted by selectors because they are not included in the list of possible targets to begin with, nor is the ID "LightningBolt" associated with them in any way other than as a means of creation via /summon and /summon's tab-complete list (which is re-used to verify input for the type parameter). It is simply impossible to target lightning bolts.


To be able to target lightning bolts, they'd either need to be included in the "spawned entities" list or we'd need a selector capable of targeting those within the "weather effects" list. But even so, the lightning bolt entity class sets its NBT-related functions to private, so commands are unable to check or change their data (which is why /summon ignores dataTag input). That would also need to be changed if lightning bolts were to become targetable.

1 more comments

I've confirmed this for 1.13 by putting execute as @e[type=minecraft:lightning_bolt] run say foo in a repeating, always on command block, then running summon minecraft:lightning_bolt. Any other entity would result in that entity saying "foo" in chat, but the lightning bolt doesn't.

However, I'm pretty sure this is WAI.

Confirmed for 1.13.1.

Confirmed in 1.15-pre2

Mike B

slicedlime

Confirmed

Commands

lightning_bolt, selector

Minecraft 14w31a, Minecraft 14w32d, Minecraft 1.10.2, Minecraft 16w43a, Minecraft 1.11.2, ..., 1.14.4, 19w46b, 1.15 Pre-Release 2, 1.15.2, 20w06a

1.16 Pre-release 1

Retrieved