Minecraft - execute command testing logic (lightning Sword)
Ok, so I made a command block contraption in Minecraft 1.10, recently I updated to 1.12, and even though there are no records of change affecting my command block contraption (from what I've found) the machine appears to be broken. The goal is for a multiplayer server, with one item, that when someone uses it, whatever entity they hit, player or mob, is struck by lightning. I used various /execute commands, to achieve this, as well as some scoreboard objectives, and tags. The commands are as follows:
/scoreboard objectives add UseSword stat.useItem.minecraft.golden_sword
/scoreboard objectives add Damaged stat.damageTaken
After those two scoreboard objectives are added, there is one repeat command block followed by 7 chain unconditional command blocks, always active. The commands go as follows in order to repeat from the end of chain;
/scoreboard players tag @e[type=!player,tag=!Hurt] add Hurt {HurtTime:10s}
The goal here is to tag any entity that is not a player, and has taken damage, so that they can be identified.
/scoreboard players tag @a add isholding_lighting_sword {SelectedItem:{id:"minecraft:golden_sword",tag:{display:{Name:"Lighting Sword",Lore:["A sword that strikes your","foe with electricity!"]}}}}
Here I am tagging any player that is holding the sword:
/execute @a[tag=isholding_lighting_sword] ~ ~ ~ /execute @p[r=1,c=1,score_UseSword_min=1] ~ ~ ~ /execute @e[tag=Hurt,r=5] ~ ~ ~ /summon LightningBolt
This is how I strike lightning at only the entity which was hit. Its a checkcase. I learned about this from research on this very topic.
/execute @a[tag=isholding_lighting_sword] ~ ~ ~ /execute @p[r=1,c=1,score_UseSword_min=1] ~ ~ ~ /execute @e[r=5,tag=!isholding_lighting_sword,score_Damaged_min=1] ~ ~ ~ /summon LightningBolt
Same as before only for players.
Then cleanup.
/scoreboard players set @a Damaged 0
/scoreboard players set @a UseSword 0
/scoreboard players tag @a remove isholding_lighting_sword
/scoreboard players tag @e remove Hurt
Any help is much appreciated, as again this used to work in Minecraft 1.10, and is broken in Minecraft 1.12.....
Ok, so it turns out, my logic works fine, unfortunately sometime between 1.10 and 1.12 nested execute command support was removed. pity. If anyone has a different way of doing this, please let me know. In the mean time, I'm going to try and figure out how to do this without nested execute commands...