2

I want to summon an arrow with the same velocity as an egg that has just been thrown. I know about the NBT tag Motion:[x,y,z], but I have no idea how to match that with the velocity of another entity.

I tried to just have the arrow be constantly be teleported to the egg, but it doesn't land where the egg lands.

1
  • Teleporting does not copy velocity? Now I have to edit my answer to another question in this forum... Commented Jun 22, 2017 at 3:37

2 Answers 2

1

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:

/execute at @e[type=egg] run summon minecraft:arrow ~ ~ ~
/execute as @e[type=minecraft:arrow] at @s run data modify entity @s Motion set from entity @e[type=egg,distance=0,limit=1] Motion
/kill @e[type=egg]

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.

1

The short answer is: you can't.


The longer answer is: You still can't, but here is why:
You can't transfer NBT data from one entity to another. Normally you might be able to work around that by detecting the NBT data in the first entity with a few hardcoded values, and then giving that same tag to the other entity.
This however won't work for the Motion tag since that incorporates three double values, and a typical Motion tag looks something like this: Motion[0.17361829472d,1.38572958294d,0.72483746234d] (good luck finding that one with hardcoded values)

4
  • 1
    Do you think that it will be possible to do the midair-replacement in 1.13 with the ^ ^ ^ coordinates? Commented Jul 9, 2017 at 13:37
  • 1
    form what it looks like now, you'll be able to copy the facing but not other NBT data. using ^ ^ ^ you could however teleport the arrows along the way they are supposed to, maybe that will help. But I really can't say anthing for sure yet.
    – Plagiatus
    Commented Jul 11, 2017 at 12:25
  • 1
    In 1.14 you can copy NBT. Commented Apr 9, 2019 at 8:26
  • Thanks for the reminder. in 1.13 and 1.14 the answer above wouldn't be correct anymore. I'll try to find the time to edit in the current possibilities
    – Plagiatus
    Commented Apr 10, 2019 at 9:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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