We cannot select LightningBolt in a target selector so we cannot detect all mobs around a lightning bolt. Instead we can detect all mobs that have a lightning bolt around them.
Setup:
/scoreboard objectives add Selector dummy
/scoreboard objectives add Initiated dummy
/scoreboard objectives add Marker dummy
/scoreboard objectives add Charged dummy
/scoreboard objectives add Change dummy
/scoreboard objectives add Kill dummy
Clock:
/scoreboard players set <Select Original Mob> Selector 1
/execute @e[score_Selector_min=1,score_Initiated=0] ~ ~ ~ summon Creeper ~ ~ ~ {CustomName:Marker,CustomNameVisible:0,Invulnerable:1,NoAI:1,Silent:1,PersistenceRequired:1}
/scoreboard players set @e[type=Creeper] Marker 1 {CustomName:Marker,CustomNameVisible:0,Invulnerable:1,NoAI:1,Silent:1,PersistenceRequired:1}
/scoreboard players set @e[score_Selector_min=1,score_Initiated=0] Initiated 1
/execute @e[score_Selector_min=1,score_Initiated=1] ~ ~ ~ tp @e[type=Creeper,r=1,c=1,score_Marker_min=1] @e[score_Selector_min=1,score_Initiate=1,r=0,c=1]
/scoreboard players set @e[type=Creeper,score_Marker_min=1] Charged 1 {CustomName:Marker,CustomNameVisible:0,Invulnerable:1,NoAI:1,Silent:1,PersistenceRequired:1,powered:1}
/execute @e[type=Creeper,score_Charged_min=1] ~ ~ ~ scoreboard players set @e[score_Selector_min=1,score_Initiate=1,r=1,c=1] Change 1
/scoreboard players set @e[type=Creeper,score_Marker_min=1] Kill 1
/execute @e[type=Creeper,score_Marker_min=1] ~ ~ ~ execute @e[score_Selector_min=1,score_Initiate=1,r=0] ~ ~ ~ scoreboard players set @e[type=Creeper,score_Marker_min=1] Kill 0
/tp @e[type=Creeper,score_Marker_min=1,score_Kill_min=1] ~ ~-600 ~
/scoreboard players set @e[score_Selector_min=1,score_Initiate=1] Initiate 0
/execute @e[score_Selector_min=1,score_Initiate=0] ~ ~ ~ execute @e[type=Creeper,r=1,c=1,score_Marker_min=1] ~ ~ ~ scoreboard players set @e[score_Selector_min=1,score_Initiate=0,r=0,c=1] Initiate 1
<Run command on entities with Change score of 1>
- Original Mobs Selected
- Creeper summoned on non-Initiated Selected mobs
- Mark the summoned Creeper
- Set the non-Initiated mobs to Initiated
- Tp the Creeper to the corresponding mob
- Mark Charged Creepers
- Mark Mobs that are selected, initiated, and have a charged creeper near them
- Reset kill score for all creepers
- Set kill score of all creepers that have a valid mob near them to 0
- Discard the remaining Creepers
- Reset Initiate score
- Set Initiate Score of all valid mobs that have a valid creeper near them to 1
- Run your command on the mobs marked with Change to swap the mobs.
note.harp
isn't a valid sound name in 1.10. For a harp sound, you should use block.note.harp
:
/playsound block.note.harp block @p ~ ~ ~ 2 1
On this wiki page you should use the names of sounds listed under "Sound events", but be careful of the table inconveniently below it labeled "Values as of 1.8.9", which contains the outdated values.
Best Answer
The thunder sound is
entity.lightning_bolt.thunder
.The impact sound is
entity.lightning_bolt.impact
.Source