2

I'm attempting to track a player's Y value so that I have a "lowest" and "current" set in scoreboard to do things with. However, I can't find anything -- elsewhere online or here in Arqade -- that can help me. I know it requires use of /execute store and /data get, but I can't for the life of me figure the syntax. All I have right now is execute as @s at @s store result entity @s Pos[1] int, but that doesn't get me anywhere, as it prompts me for some form of argument after int, which it refuses to actually tell me.

Everything I've found either only mentions execute store and data get briefly, e.g. here. It helps guide me, but because the question asks about 1.12, it doesn't help me much else past that basic knowledge.

2
  • Wow, thanks for linking me to my own answer, now I don't need to look for a duplicate target myself. :D I'll update it to include a full command. Mar 4, 2020 at 5:08
  • Actually, the asker there specifically asked about 1.12, so I'll better answer here and link the other way around. Mar 4, 2020 at 5:09

1 Answer 1

5

Firstly, if you want to get the position into a scoreboard and not into NBT, then you don't need /execute store result entity, but /execute store result score. That also avoids this issue. Here is an explanation of the issue anyway:

The argument that the game expects is "scale", which allows you to multiply the return value of the /data get command by a number before storing it. You can also do this in /data get, see below.

It's really weird how the syntax help for that doesn't show up. It actually does appear once you start typing anything at that position, no matter if it's correct or not. I created a bug report about that: https://bugs.mojang.com/browse/MC-173701

Here are the commands you actually want, with scoreboards:

/execute store result score @s x run data get entity @s Pos[0]
/execute store result score @s y run data get entity @s Pos[1]
/execute store result score @s z run data get entity @s Pos[2]

You can add a factor at the end of each of these. For example if you multiply by 50 when reading from NBT and later with 0.02 when reading from the scoreboard, you get the coordinate precise to 20cm. But be careful when using scale factors above 71.58, because you might get overflow issues if the player coordinates are very high. Currently you don't need to worry about Y coordinates above 30 million, because the player gets kicked anyway.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .