I think it would be easier to execute players who have thrown a specific type of egg instead of executing the egg itself. Since I don't know Bedrock Edition commands, I'll use PC commands and hopefully you can edit them to your liking, or someone else can edit them in this answer.
Add an objective that tracks players who throw eggs:
/scoreboard objectives add egg minecaft.used:minecraft.egg
Then have these commands running in a repeating chain:
tp @a[tag=egg,scores={egg=1}] <write your spawnpoint coordinates here>
tag @a remove egg
tag @a[nbt={SelectedItem:{id:"minecraft:egg",tag:{display:{Name:"\"Spawnpoint\""}}}}] add egg
scoreboard players reset @a egg
What this does is:
- Teleports all players who have thrown an egg with the egg tag to the spawnpoint.
- Removes the egg tag of all players, then adds it for those who are holding the specific egg. In the next tick, if they had held this egg before throwing it, they will be tped. The reason why I added the tag after the tp command is because they wouldn't have had the egg anymore so tagging them would have been impossible.
- Resets their egg score.
That system was for 1.13 commands. If you're using 1.12, use these commands instead.
tp @a[tag=egg,score_egg_min=1] <write your spawnpoint coordinates here>
tag @a remove egg
tag @a add egg {SelectedItem:{id:"minecraft:egg",tag:{display:{Name:"Spawnpoint"}}}}
scoreboard players reset @a egg
The problem with your command is that you are asking the command block running it to Tag itself if an arrow [Execute At arrow] has the closest player with a certain bow [@p[nbt...], in which fails since a command block can not even be tagged.
To fix this, you must change it to:
/execute as @e[type=minecraft:arrow] at @s run execute if entity @p[nbt={SelectedItem:{id:"minecraft:bow",tag:{display:{Name:"{\"text\":\"TP Bow\"}"}}}}] run tag @s add tparrow
This way, it will execute as and at the arrow, tagging it self
However, if you are going to use this in multiplayer, there is some bugs. First, if a player uses a normal bow, and another player or even the same one selects, later on, the bow with the correct name, it will be tagged and teleported. Secondly, if you shoot it near a friend, depending on how you programmed the rest, it might end up teleporting him.
Here it is a chain of commands to prevent these bugs but before, create this scoreboard
/scoreboard objectives add Bow minecraft.used:minecraft.bow
Here is the chain:
/execute as @a[scores={Bow=1},nbt={SelectedItem:{id:"minecraft:bow",tag:{display:{Name:"{\"text\":\"TP Bow\"}"}}}}] at @s run tag @e[type=minecraft:arrow,distance=0..2,sort=nearest,limit=1] add tparrow
/execute as @e[type=minecraft:arrow,tag=tparrow] at @s run tag @p[distance=0..2,scores={Bow=1}] add tpplayer
/execute as @e[type=minecraft:arrow,tag=tparrow,nbt={inGround:1b}] at @s run tp @p[tag=tpplayer] ~ ~ ~
/execute as @e[type=minecraft:arrow,tag=tparrow,nbt={inGround:1b}] at @s run tag @a[distance=0..1] remove tpplayer
/execute as @e[type=minecraft:arrow,tag=tparrow,nbt={inGround:1b}] at @s run kill @s
/scoreboard players set @a Bow 0
The first command block should be a "Repeat" one and the rest should be "Chain", All connected up.
If you wish to only tag the arrow while fixing those bugs: create the scoreboard and use the 1st, 2nd and last commands in the chain.
Best Answer
You can transfer NBT data from one entity to another in newer versions of minecraft. To replace all eggs with arrows with the same
Motion
-tag, you could use these three commands, executed in a repeating command block and then two chain command blocks:The first command summons an arrow at the position of every egg.
The second command sets the
Motion
-tag of every arrow to the same value as any egg that is in exactly the same position.The third command kills all eggs.