I'm trying to make something like a snitch that tells you where you are and if you are in the radius of a block, but the only thing that's missing is finding the coordinates of a player so I can see where they entered the area.
I already got the player-detecting part done - finding their coordinates is the only thing left to do.

The server I'm on is 1.12.2, and I'm OP on it. I don't want to use scoreboards for it if possible.


This process is very simple in 1.13+, you only need to use /execute store together with /data get to store a player's "Pos" array into three scores (instructions see here). But 1.12 has neither of these commands, so you need to do something called a "binary search" through the entire world.

How this works: You first select half of the world, for example from X=0 to X=30000000 and check whether the player is in it (using the x, y, z, dx, dy, dz selector arguments). If the player is in the negative half, you continue there, otherwise in the positive half. There you select half of the remaining world again, in this case for example from X=0 to X=15000000. After that you can half the search area again and again, until after just 27 steps you have narrowed down this 60 million block range into less than one block range. And you can continue, if you want the position to be even more precise. Then you do the same for Y and Z, after 62 steps you have all three coordinates precise to one block and can put it into a scoreboard.

But it's still quite a lot of effort to write down all of these commands, so luckily someone did it for you and made a datapack: https://www.reddit.com/r/Minecraft/comments/6id4k0/112_coordinate_finder_function/ (datapack archive)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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