2

I'm trying to set up a series of command blocks that will make a rain of arrows around the player when a specific item is held.

The idea is that as soon as the player holds a specific item, command blocks will spawn arrows 10 blocks above him. Then I want to randomly spread out the arrows over a certain radius, excluding the block the player is standing on.

I've thought about using the /spreadplayers command;

/execute @a[score_Arrows_min=1] ~ ~ ~ /spreadplayers ~ ~ 0 5 false @e[type=Arrow]

However, this makes the arrows teleport to the ground, instead of placing them in the air. I'm also unable to exclude the block the player is standing on as location.

I've looked around for a way to randomize teleportation coordinates in order to replace the /spreadplayers command, but that doesn't seem to be possible.

Can someone with more experience help me out, please? Also, I'm trying to keep the amount of command block as low as possible because my PC isn't that powerful.

  • Put arrows into team and player into same team. Disable friendly fire in that team, maybe then the arrows won't hurt him. Untested and I have no way to test it. If that works, just spawn them on one place aiming straight up, then they will turn down in random directions, falling around player. Need to be tested, if works. – Antoine Hejlík Oct 21 '16 at 23:41
  • @Antoine Hejlík It kind of works, but with a way too small radius, even if I summon them very high. – Jaïr Paalman Oct 26 '16 at 14:43
1

The way I can think of this works rather well. It involves the "arrow storm" activator being in a specific inventory slot, as if like an option.

First, you set a loop command block to this:

/replaceitem entity @a[m=2] slot.hotbar.0 minecraft:arrow 1 0 {display:{Name:"Activate Arrow Storm",Lore:[Select this slot to activate an arrow storm!]}}

Then have another loop command block activating the following:

/execute @a[tag=SelectedItemSlot:0,m=0] ~ ~ ~ summon arrow ~ ~10 ~ {Life:1000,pickup:0}

Along with another loop that does this:

/execute @a[tag=SelectedItemSlot:0,m=0] ~ ~ ~ summon creeper ~ ~9.9 ~ {ignited:1,ExplosionRadius:1,Fuse:1,Silent:1b,NoAI:1b}

I added tags to the arrows so that they could not be picked up {pickup:0} and despawned after 200 ticks {Life:1000}

The creepers are so the arrows fly everywhere, while allowing for the safety of the buildings if the command

/gamerule mobGreifing false

is executed. Notice that the creeper is slightly lower than the arrows so that they mostly fly upwards.

Have fun with your new arrow storm, or potential entity fountain! ;)


May require a powerful computer depending on how many people are going to use this. May require several /replaceitem commands to get rid of any arrows created by moving the arrows in the inventory

0

I came up with a bit alternate solution - using /fill to fill an area above the player with arow-filled dispensers facing down (1), powering them (2), and then replacing them with air (3) an a fraction of a second:

Insert the following command in a repeat command block (1):

/execute @a[score_Arrows_min=1] ~ ~ ~ /fill ~-3 ~+10 ~-3 ~+3 ~+10 ~+3 minecraft:dispenser 0 replace {Items:[{id:"arrow",Count:64b,Slot:0b}, {id:"arrow",Count:64b,Slot:1b}, {id:"arrow",Count:64b,Slot:2b},{id:"arrow",Count:64b,Slot:3b}, {id:"arrow",Count:64b,Slot:4b}, {id:"arrow",Count:64b,Slot:5b}, {id:"arrow",Count:64b,Slot:6b}, {id:"arrow",Count:64b,Slot:7b}, {id:"arrow",Count:64b,Slot:8b}]}

Next to this command block place another one, chain this time. Put this command inside (2):

/execute @a[score_Arrows_min=1] ~ ~ ~ /fill ~-3 ~+11 ~-3 ~+3 ~+11 ~+3 minecraft:redstone_block 0

Next to that command block, place a chain command block with this command (3):

/execute @a[score_Arrows_min=1] ~ ~ ~ /fill ~-4 ~+9 ~-4 ~+4 ~+12 ~+4 minecraft:air 0

Notes:

  • the commands might be outdated, as I didn't test them, just took them out of thin air All is tested and working. You might want to remove /'s and +'s to improve readability (but it works in both cases)

  • don't use this solution if you want to use it in closed areas - buildings, caves etc.

  • change the fill area of the commands to whatever you want, I'd recommend more dispensers placed higher.

  • the last command, though, has to fill both the dispensers and the redstone blocks, and has to have a bigger fill area in case of the player moving.

  • @Jaïr Paalman please consider marking this question as accepted by clicking on the gray check mark next to this answer if it helped you. Thanks! – RudolfJelin Nov 12 '16 at 18:07
  • You need to get rid of secondary "/"s in /execute commands for them to work. Also, the "+"s are unnecessary and will probably confuse the command system. – Chemical Comrade Nov 28 '16 at 6:15
  • 1
    @FungusKing the +'s and /'s don't harm the code, it works even so. And it seems the OP downvoted both posts for some reason. – RudolfJelin Nov 28 '16 at 19:45
  • 1
    Ok, but they are still unnecessary and could be typoed so minimising the characters in the commands is normally desirable. – Chemical Comrade Dec 5 '16 at 9:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.