I believe that I am trying to accomplish too much with a single command block, but I want to test the limits of repeating command blocks or find ways to entirely do away with them in favor of advancement/achievements and functions. I have been working in Java 1.12.2 and 1.13.
What I have set up is two functions, the first gives the player the items, sets up gameroolz and creates a repeating command block that has the second function running in it, the idea is that after calling the first function everything will be initialized and up and running, that is the sort of simplicity I am going for.
The first function contains the following:
' #give power nine bow"
summon item ~ ~ ~ {Item:{id:"minecraft:bow",Count:1b,tag:{display:{Name:"power9"},ench:[{id:34,lvl:3},{id:48,lvl:9},{id:70,lvl:1}]}}} give @p arrow 64 0
'#setup scoreboards
scoreboard objectives add arrowinGround dummy
scoreboard objectives add holdspnine dummy
'#to setup command block linked to constant loops for tagging method
setblock ~ ~ ~ repeating_command_block 0 replace {Command:"/function mypath:armory/p0wer9/loop",auto:1,powered:1b}
Everything in this first function seems to work as intended. The second function (called by the repeating command block) is only partially getting executed:
' #adding players
scoreboard players add @e[type=arrow] arrowinGround 0 {damage:7d,inGround:0b}
scoreboard players add @e[type=arrow] arrowinGround 1 {damage:7d,inGround:1b}
scoreboard players tag @e[type=arrow] shotArrow {damage:7d,inGround:0b}
scoreboard players tag @e[type=arrow] fallenArrow {damage:7d,inGround:1b}
execute @eshotarrow particle reddust ~ ~1 ~ 0 0 0 1 1 normal
execute @efallenarrow execute @e[r=4,c=2] summon lightning_bolt
scoreboard players set @e[type=arrow] arrowinGround 0 {damage:7d,inGround:0b}
scoreboard players set @e[type=arrow] arrowinGround 1 {damage:7d,inGround:1b}
scoreboard players add @a holdspnine 1 {SelectedItem:{id:"minecraft:bow",tag:{display:{Name:"power9"}}
scoreboard players set @a holdspnine 0
scoreboard players set @a holdspnine 1 {SelectedItem:{id:"minecraft:bow",tag:{display:{Name:"power9"}}
execute @e[type=arrow,score_arrowinGround_max=0] particle mobSpell ~ ~ ~ 0 0 0 1 1 normal
execute @a[score_holdspnine_min=1] execute @e[type=arrow,score_arrowinGround_max=0] particle reddust ~ ~1 ~ 0 0 0 1 1 normal
execute @e [type=arrow,score_arrowinGround_min=1] tp @p[score_holdspnine_min=1,r=12] @e[type=arrow,score_arrowinGround_min=1]
kill @e[type=arrow,score_arrowinGround_min=1]
You will notice that there is some duplication with the objectives set and objectives add lines - I have been tinkering a lot trying to get this to work in-game. There is also some silly stuff going on where I was trying to do things at the arrow at various times in its existence for debugging reasons. This is the 1.12.2 code thus far.
It seems that the scoreboard bit at the beginning works okay, but everything after that seems to fail. Is this because once one line fails the rest of the execution is meant to be stopped inside the function? If so can I have a 'master function in the loop call sub functions? to prevent execution of the 'main' from stopping? I want to get away from command block chains, but I would be open to using the 'ticks' feature in 1.13 - I just want the most performance friendly solution possible.
Are the scoreboard objectives really necessary? Can I just 'tag' the shotArrow arrows as they are shot? I have tried this and it seems that even though the tagging happens and I can find the nbt tag, that I don't seem to be able to use the tag as a selector (@e[tag=shotArrow])
I realize things have changed from 1.12 to 1.13. I am open to solutions from either version and it seems to me that 1.13 'might' have better solutions available but I haven't seen enough sample code to know what direction is best to take to get a fresh start with 1.13. Also I read that 1.13 has some performance optimizations for repeating commands.