0

A few weeks ago, I asked about how to summon lightning an x amount of times at an arrow shot from a specific bow (I named it Chaos of Asraelax), only after it hits the ground (because execute at @e[type=arrow] run summon lightning_bolt will summon lightning every tick, and it doesn't even have to be an arrow shot from the player).
Someone answered it, and it kind of worked! Arrows shot from my bow will be tagged as chaos arrow and when they hit the ground, they will summon lightning 5 times. Here's the code for it (credits to mindoverflow, circusbaby23, and JohnPaulInso(Youtube) for contributing to this):

Declare objectives:

/scoreboard objectives add UseBow minecraft.used:bow
/scoreboard objectives add Summon1 dummy
/scoreboard objectives add Timer1 dummy

Command that gives bow:

give @p bow{CustomModelData:103,display:{Name:"[{\"text\":\"Chaos of\",\"color\":\"yellow\"},{\"text\":\" Asraelax\",\"color\":\"yellow\"}]",Lore:["{\"text\":\"An all purpose bow cursed by Asraelax\",\"color\":\"gray\",\"italic\":false}"]},Unbreakable:1,HideFlags:7}

First chain:

[r] execute at @a[scores={UseBow=1..},nbt={SelectedItem:{id:"minecraft:bow",Count:1b,tag:{CustomModelData:103,display:{Name:"[{\"text\":\"Chaos of\",\"color\":\"yellow\"},{\"text\":\" Asraelax\",\"color\":\"yellow\"}]"}}}}] run data merge entity @e[type=arrow,limit=1,sort=nearest,distance=..2] {Tags:["chaosarrow"]}
[c] execute as @a[scores={UseBow=1..}] at @e[type=arrow,tag=chaosarrow,nbt={inGround:1b},limit=1] run summon minecraft:armor_stand ~ ~ ~ {Tags:["chaos"],Invulnerable:1b,Invisible:1b}
[c] execute at @e[tag=chaosarrow,nbt={inGround:1b}] run scoreboard players remove @a UseBow 1
[c] kill @e[tag=chaosarrow,nbt={inGround:1b}]

Second chain:

[r] scoreboard players add @e[tag=chaos] TimerL 1
[c] execute as @e[tag=chaos,scores={TimerL=1}] at @s run summon minecraft:lightning_bolt
[c] execute as @e[tag=chaos,scores={TimerL=1}] at @s run scoreboard players add @s StrikeL 1
[c] execute as @e[tag=chaos,scores={TimerL=5}] at @s run scoreboard players set @s TimerL 0
[c] kill @e[tag=chaos,scores={StrikeL=5}]

As I've mentioned, this works pretty great, basically, it detects when you've used a bow, and tag all arrows near the bow with the tag chaos arrow. When the command detects an arrow with the tags chaos arrow and InGround, it summons an armor stand with tag chaos. Any armor stands with tag chaos will be struck by lightning 5 times, then killed.

Only one small downside. If there is an arrow near you, and you're holding the Chaos of Asraelax, it will ALSO tag the arrow, even though it wasn't shot from my bow, and summons lightning.

When mindoverflow posted this, they regarded that problem, but I just included it in as a feature, like I can summon a bunch of arrows, and then just stand near them and, chaos.

But is there a way to prevent this from happening? There are three answers to this.
Number one, no (say it in comments).
Number two, yes you'll only have to alter some of the above code.
Number three, yes there is a way but it is not compatible with the code above, and it requires an entirely new command setup.

Thanks for reading this through!

2
  • So to clarify the isssue, if an aroww is just on the ground near you it well pick up the tag and strick lightning? Aslo thanks for creditng me :)
    – user280959
    Commented Nov 18, 2021 at 11:38
  • Also, I'd recommend two things here. When checking if the player has a specific item, check for tags. Tags are only obtainable in creative mode so you shouldn't worry about exploits (Like renaming the item). This way you can change everything in your bow later on and still work without code change; Second thing is transform these things in a datapack. Faster running, more effective, easier to control things and are more flexible. You can use VSCode + mcfunction plugin to code in it.
    – BunnyMerz
    Commented Nov 18, 2021 at 17:29

1 Answer 1

1

Your third line will take away the score of players who used a bow only when that arrow hits the ground. The correct thing to do is to take away the score imediatly after the two first commands. Change your third line to:

/scoreboard players remove @a[scores={UseBow=1..}] UseBow 1

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .