INIT:/scoreboard objectives add TC_BlockID dummy
INIT:/scoreboard objectives add TC_Tesla dummy
INIT:/scoreboard objectives add TC_TeslaPart dummy
INIT:/scoreboard objectives add TC_Pickup dummy
INIT:/scoreboard objectives add TC_Destroy dummy
INIT:/scoreboard objectives add TC_Cooldown dummy
INIT:/scoreboard objectives add TC_Safe dummy
INIT:/tellraw @a [{color:"gold",text:"The Tesla Coils "},{color:"dark_aqua",text:"command module by MrGarretto has been installed!"}]
INIT:/tellraw @a [{color:"green",text:"To craft a tesla coil, throw a "},{color:"aqua",text:"beacon, "},{color:"green",text:"and a "},{color:"aqua",text:"hopper "},{color:"green",text:"on the ground together!"}]
/scoreboard players set @e[type=Item] TC_BlockID 1 {Item:{id:"minecraft:beacon"}}
/scoreboard players set @e[type=Item] TC_BlockID 2 {Item:{id:"minecraft:hopper"}}
/execute @e[score_TC_BlockID_min=1,score_TC_BlockID=1] ~ ~ ~ execute @e[r=1,score_TC_BlockID_min=2,score_TC_BlockID=2] ~ ~ ~ summon Item ~ ~ ~ {Item:{id:"spawn_egg",Damage:60,Count:1,tag:{display:{Name:"TeslaCoil"}}}}
/execute @e[score_TC_BlockID_min=1,score_TC_BlockID=1] ~ ~ ~ execute @e[r=1,score_TC_BlockID_min=2,score_TC_BlockID=2] ~ ~ ~ kill @e[score_TC_BlockID_min=1,score_TC_BlockID=2,r=5,c=2]
/scoreboard players set @e[type=Silverfish,name=TeslaCoil] TC_Tesla 1
/execute @e[score_TC_Tesla_min=1] ~ ~ ~ summon ArmorStand ~ ~-1.349 ~ {CustomName:"TCMain",Invisible:1,NoGravity:1,Equipment:[{},{},{},{},{id:beacon,tag:{display:{Name:"TCPickup"}}}]}
/execute @e[score_TC_Tesla_min=1] ~ ~ ~ summon ArmorStand ~ ~0.3 ~ {Invisible:1,NoGravity:1,Equipment:[{},{},{},{},{id:cobblestone_wall,tag:{display:{Name:"TCPickup"}}}]}
/execute @e[score_TC_Tesla_min=1] ~ ~ ~ summon ArmorStand ~ ~-0.3 ~ {Invisible:1,NoGravity:1,Equipment:[{},{},{},{},{id:cobblestone_wall,tag:{display:{Name:"TCPickup"}}}]}
/execute @e[score_TC_Tesla_min=1] ~ ~ ~ summon ArmorStand ~ ~-0.1 ~ {Invisible:1,NoGravity:1,Small:1,Equipment:[{},{},{},{},{id:iron_block,tag:{display:{Name:"TCPickup"}}}]}
/execute @e[score_TC_Tesla_min=1] ~ ~ ~ summon ArmorStand ~ ~0.9 ~ {Invisible:1,NoGravity:1,Equipment:[{},{},{},{},{id:iron_bars,tag:{display:{Name:"TCPickup"}}}]}
/execute @e[score_TC_Tesla_min=1] ~ ~ ~ scoreboard players set @e[type=ArmorStand,r=2,c=5] TC_TeslaPart 1
/scoreboard players set @a TC_Pickup 1 {Inventory:[{tag:{display:{Name:"TCPickup"}}}]}
/give @a[score_TC_Pickup_min=1] spawn_egg 1 60 {display:{Name:"TeslaCoil"}}
/execute @a[score_TC_Pickup_min=1] ~ ~ ~ scoreboard players set @e[type=ArmorStand,score_TC_TeslaPart_min=1,c=1,r=20] TC_Destroy 1
/execute @e[score_TC_Destroy_min=1] ~ ~ ~ kill @e[type=ArmorStand,score_TC_TeslaPart_min=1,c=5]
/clear @a[score_TC_Pickup_min=1] cobblestone_wall 0 1 {display:{Name:"TCPickup"}}
/clear @a[score_TC_Pickup_min=1] beacon 0 1 {display:{Name:"TCPickup"}}
/clear @a[score_TC_Pickup_min=1] iron_block 0 1 {display:{Name:"TCPickup"}}
/clear @a[score_TC_Pickup_min=1] iron_bars 0 1 {display:{Name:"TCPickup"}}
/scoreboard players reset @a[score_TC_Pickup_min=1] TC_Pickup
# Make the Tesla Coil work:
/scoreboard players set @e[type=!Player] TC_Safe 0
/scoreboard players set @e[type=ArmorStand] TC_Safe 1
/scoreboard players set @e[type=Item] TC_Safe 1
/scoreboard players add @e[name=TCMain] TC_Cooldown 0
/scoreboard players add @e[name=TCMain,score_TC_Cooldown=30] TC_Cooldown 1
/execute @e[type=ArmorStand,name=TCMain,score_TC_Cooldown_min=30] ~ ~ ~ execute @e[r=12,score_TC_Safe=0] ~ ~ ~ summon LightningBolt ~ ~ ~
/scoreboard players set @e[name=TCMain,score_TC_Cooldown_min=30] TC_Cooldown 0
/execute @e[type=ArmorStand,name=TCMain,score_TC_Cooldown_min=30] ~ ~ ~ particle smoke ~ ~ ~ 0 0 0 1 40
/kill @e[score_TC_Tesla_min=1]