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
is duplicated by 3
Comments 11
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 theEntityList
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 thetype
parameter grabs a list of string IDs from the same tab-complete list that/summon
uses. If the input into thetype
parameter is not among that list, the selector will throw an error. Thetype
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 theEntityList
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 thetype
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.
They only have tags listed here: http://minecraft.gamepedia.com/Chunk_format/Entity
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 14w32d