How can I track the coordinates of an ender pearl?
I am creating an ender pearl cannon and I'm trying to get the precise timings down. Only I can't really see where the ender pearl goes after it launches because I propel it with a lot of TNT and therefore it travels at a very high speed. In an effort to optimize it, I want to be able to see where my ender pearl travels along its journey.
Is there any way I can do this? Maybe through chat, scoreboard, or teleportation to the ender pearl?
Solution 1:
This command prints the coordinates of an ender pearl into chat every tick as long as an ender pearl exists, otherwise stays silent:
/execute as @e[type=ender_pearl] run tellraw @a {"nbt":"Pos","entity":"@s"}
Simply put this into a repeating command block and you'll see all the data for the trajectory. You can do the same with Motion
instead of Pos
, if you want to see that.
This command summons an armour stand at the position of the ender pearl every tick that does not collide with the ender pearl and does not move, creating a nice visual representation of the trajectory (one that could potentially get laggy, but wasn't on my computer):
/execute at @e[type=ender_pearl] run summon armor_stand ~ ~ ~ {NoAI:1,NoGravity:1,Marker:1,Tags:["pearl_marker"]}
You can kill them again with /kill @e[tag=pearl_marker]
If you're planning to have ender pearl entities that exist for a long time, you should make sure that you either know the coordinates of the repeating command block so that you can disable it (/data merge block <coordinates> {auto:0}
) or run this in a function that you can edit outside Minecraft, otherwise lag might make your world unusable.
Note that the rotation of the armour stands will be weird. That's because the rotation of ender pearls is weird. It seems to be completely unrelated to their motion.