Snowballs are a lot of fun aren't they? Well, this is simpler, since your requirements are that a particular sort of snowball will have an arc of lightning bolts across its trajectory, but the principal is the same.
For this, I used a series of 4 commands and 1 setup command. (well, and also /gamerule commandBlockOutput false
) It works by setting a lightning
score for snowball entities holding customly named snowballs, and then summoning a lightningbolt at each of those snowballs. And it's actually a neat little set of commands.
First, we need our scoreboard. You can set one up using /scoreboard objectives add lightning dummy
. From here, we want to be able to perform commands on players holding customly named snowballs:
scoreboard players set @a lightning 1 {SelectedItem:{id:minecraft:snowball,tag:{display:{Name:"KABOOM"}}}}
Unfortunately there's no really clean way to invert this sort of command to reset this score, and resetting it for all items would also cause the last snowball in a stack to stop working, so I just reset it for players holding snowballs. As long as the commands execute at the same time, you shouldn't run into any problems, unless you're trying to build a PvP game around this, then you may want to reset this score for everyone just to be safe:
scoreboard players set @a lightning 0 {SelectedItem:{id:minecraft:snowball}}
From here, we can set the score of the snowball entities near these players using execute
:
execute @a[score_lightning_min=1] ~ ~ ~ scoreboard players add @e[type=Snowball,r=10] lightning 0
Now you have a marked snowball. Just what we need! The final step to this equation is to slap a score_lightning_min=0
in the original "make lightning at every snowball entity" command, hook all 4 command blocks up to a clock of some sort (I recommend a /fill
clock, but it's not entirely necessary as long as all of your commands are on the same line of redstone) and we should be set:
execute @e[type=Snowball,score_lightning_min=0] ~ ~ ~ summon LightningBolt ~ ~ ~
The results: Wholly satisfying:
Assuming you have the "sentry gun" shooting arrows, you would use the command:
/summon Arrow x y z {damage:1,Motion:[x.0,y.0,z.0]}
You would have to plug into the first set of coordinates where you want the arrows to be shooting from, and the direction the arrows are shooting in the second. TIP: The higher the number you set for your direction (second set of coordinates, the faster the arrow will travel! You can set anything for the damage (except dont get too crazy :P)
As for your "Tool Box" Idea, you can do the test for command on a redstone ticker:
testfor @e[x,y,z,r,type=Item] {Item:{id:minecraft:iron_block}}
(Unfortunately, you cant test for a custom named block/entity - at least to my knowledge) Run a comparator out of this command block, to another command block (does not NEED to be a command block). This will start a fast ticking redstone clock on another command block. This command block will have the command:
testfor @e[x,y+1,z,r,type=Item] {Item:{id:minecraft: ... }}
Make sure that the coordinates you plug into the last testfor command have y+1 the y coordinate of the testfor command before that. This means it will test for the item on top of your "tool box". Run a comparator out of that command block to start the /summon Arrow command, or in other words, start up your sentry!
(The arrows are seen only as little black dots in this photo, but thats because I have the speed ramped up :)
Basically, its a system of Testing positive for an iron block at x y z - starting ticker to test for ... entity at x y+1 z - testing positive for ... entity at x y+1 z - starting ticker to shoot "sentry gun"
Hope this helps
Best Answer
I think I have it. The operation requires four commands, not counting the fill clock. The arrow will still exist but will spawn fireworks that explode immediately.
Type this in chat:
1st Command Block on fill clock:
2nd Command Block on fill clock:
3rd Command Block on fill clock:
You can make your own firework to put in the execute command at http://www.minecraftupdates.com/fireworks but make sure the lifetime is set to -1.
I hope this helped and that this was what you were looking for.