6

I want to shoot an arrow named "GreenArrow" that constantly summons enderpearls named "GreenPearl". Those pearls should execute a command at armorstands within 1 block. That command is /setblock ~ ~-1 ~ wool 5.

To do this, I have 4 command blocks, and 2 dummy scoreboard objectives. the dummy objectives are as follows:

/scoreboard objectives add GreenArrow dummy
/scoreboard objectives add GreenPearl dummy

The 4 command blocks that are repeating and always active, are as such:

/scoreboard players set @e[type=arrow] GreenArrow 1 {CustomName:"GreenArrow"}

/execute @e[type=arrow,score_GreenArrow_min=1] ~ ~ ~ summon ender_pearl ~ ~ ~ {CustomName:"GreenPearl"}

/scoreboard players set @e[type=ender_pearl] GreenPearl 1 {CustomName:"GreenPearl"}

/execute @e[type=ender_pearl,score_GreenPearl_min=1] ~ ~ ~ execute @e[type=armor_stand,r=1] ~ ~ ~ setblock ~ ~-1 ~ wool 5

This works when the arrow us summoned using this command,

/summon arrow ~ ~80 ~ {CustomName:"GreenArrow"}

but not when shot by a player. I have tested with a arrow with the custom name in it's NBT data and when renamed in a anvil.

The arrow is shot just fine, but is not detected by the command blocks unless summoned as previously mentioned.

I do belive it has something to do with the way the arrow is shot, in creative mode or survival/adventure there is no difference. It seemes like the arrow looses it's NBT data after being fired from a bow. There were no issues with this before the CustomName was added.

Are anyone here able to assist?

2
  • I found out that I need to use /entitydata, but not sure where. Tried adding it to this command: /scoreboard players set @e[type=arrow] GreenArrow 1 {CustomName:"GreenArrow"} so that command now looks like this: /scoreboard players set /entitydata@e[type=arrow] GreenArrow 1 {CustomName:"GreenArrow"}. I am not familiar with this command, and not sure how to properly use it. Commented Dec 14, 2016 at 1:39
  • 1
    It might be best to also name the bow something special. That way, you can test if the player is holding the named bow, then apply the name to the just shot arrow.
    – MBraedley
    Commented Dec 14, 2016 at 2:24

2 Answers 2

1

You cannot do this specifically, but what you can do is have the player hold the arrow in their off hand (like potion arrows) and set a score to 1, then use the command

/execute @a[score_SCORENAME_min=1] ~ ~ ~ scoreboard players set @e[type=Arrow,r=1] GreenArrow 1.
1

You cannot do this because once an arrow is shot they are all basically the same, however, you could use tipped arrows and change the color of the tip and have like /give @p tipped_arrow{display:{Name:'{"text":"Green Arrow","color":"dark_green","bold":true}'},CustomPotionColor:44288} 64 and then use the execute command

execute at @e[type=arrow,nbt={Color:44288}] run summon ender_pearl ~ ~ ~ {CustomName:"GreenPearl"}

with this method I would suggest added another command block that kills the arrow once it's in the ground with

kill @e[type=arrow,nbt={Color:44288,inGround:1b}]

the second two should be on repeating command blocks unconditionally

and if you don't want the pearls to fall you could add the tag NoGravity:1b inside here {CustomName:"GreenPearl",NoGravity:1b} however if you do that i would also suggest creating a

kill @e[type=ender_pearl,nbt={CustomName:"GreenPearl",NoGravity:1b}] command that is either on a redstone clock or you could set up a /schedule command. If you want it to be on it's own time(how long it's been alive) you should set up a dummy scoreboard called lifetime for it that adds 1 to its score every tick with

execute if entity @e[type=ender_pearl,nbt={NoGravity:1b}] run scoreboard players add @e[type=ender_pearl,nbt={NoGravity:1b}] lifetime 1

and then kill it with

execute if entity @e[type=ender_pearl,nbt={NoGravity:1b},scores={lifetime=300..}] run kill @s

You must log in to answer this question.

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