Locate a player's coordinates and then teleport to those coordinates

Started by Makito83 on

Topic category: Help with Minecraft modding (Java Edition)

Joined May 2025
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Locate a player's coordinates and then teleport to those coordinates

Hello!! I'm fairly new to modding to Minecraft, but I do have some knowledge in coding. I have an idea for a command that would track down a player's coordinates and then prompts you to be able to teleport to them. This command will only work if you hold a specific item AND if the person you are tracking has a specific item in their inventory.

 

For example, you input the command "/track <playername>" and then it shows the display name AND the location of that player through the chat.

(example 2 of how I want it to look/work)
NAME: <playername>
LOCATION: ~ ~ ~

Would you like to teleport?

[YES] [NO]
 

Though I fear this is where my knowledge fails me, as I'm unable to locate the location of any entity besides from myself while testing. I've tested it in multiplayer too, and every time I used the command, it just showed the name and location of myself and not the other tester. Is there a way to make this command work in the way that I want? or is it impossible to create, or is it a third secret reason (the solution is easy and I'm just dumb).