Hello, I am trying to make my first data pack, but I am already running into issues. The biggest issue I have is understanding how the execute command works.
I need to get the position of the player, make it a whole number (round it), and then add 0.5 to the X, Y, and Z values. So for example, if I am standing on 246.22, 67.00, -178.31, I want it to first round all the values (doesn't matter if it rounds up, rounds down, or rounds to the nearest whole number), so 246, 67, -179, and then add 0.5, making the final result 246.5, 67.5, -178.5.
Finally, with this value I need to test each axis independently to see if the player is behind this point, or after. So bascially I want to check if the player's X is < 246.5 and if it is execute a command, if the player's Y is < 67.5 and if it is execute a command and so on...
Is there a way to do this? I don't know if this is better to be done in a data pack or should I try to make a mod, but mod seems very hard. Please help. I am on these forums first time sorry if I posted in wrong place. Pls help me
Hello, I am trying to make my first data pack, but I am already running into issues. The biggest issue I have is understanding how the execute command works.
I need to get the position of the player, make it a whole number (round it), and then add 0.5 to the X, Y, and Z values. So for example, if I am standing on 246.22, 67.00, -178.31, I want it to first round all the values (doesn't matter if it rounds up, rounds down, or rounds to the nearest whole number), so 246, 67, -179, and then add 0.5, making the final result 246.5, 67.5, -178.5.
Finally, with this value I need to test each axis independently to see if the player is behind this point, or after. So bascially I want to check if the player's X is < 246.5 and if it is execute a command, if the player's Y is < 67.5 and if it is execute a command and so on...
Is there a way to do this? I don't know if this is better to be done in a data pack or should I try to make a mod, but mod seems very hard. Please help. I am on these forums first time sorry if I posted in wrong place. Pls help me
This would, as @p, teleport them from where they are +0.5 x y & z
/execute as @p at @s run tp ~0.5 ~0.5 ~0.5
Execute as players
at position of self
run teleport
You can also check a location using the y,y,z,dx,dy,dz functions but I don't know if you can do so generically
See these for examples:
https://www.minecraftforum.net/forums/minecraft-java-edition/redstone-discussion-and/commands-command-blocks-and/2929196-using-dx-dy-dz-in-player-detection
https://www.reddit.com/r/Minecraft/comments/43cmfx/help_testfor_players_in_a_rectangular_area/