Is there a way to clone relative coordinates of a player and the command block? [duplicate]

It sounds to me like you're trying to clone from a location relative to a command block to a location relative to the player. As Fabian says, ~ is for relative coordinates. Specifically, relative coordinates are relative to the executor of the command. When a command block runs a command, the command block is the executor. When you run a command in chat, you are the executor. So both entities and blocks can be the executor. To do anything from a command block relative to the player, you will have to use the command block to make the player the executor, which is done using the /execute command.

The catch here, of course, is that since /clone is a single command, it can only be executed relative to a single executor. So you will either need to first clone from relative to the command block to an intermediary location addressed using absolute coordinates, and then /execute at the player to clone from there to beside them, or execute everything relative to the player in the first place.


To clone an area from one variable location to another location, you can first clone it to some coordinates you know, then from there to where you want to have it and then delete the middle copy. So for example to clone a 10x10x10 area with the player Horst as the lowest x, y and z coordinate to another area with the player Herbert as the lowest x, y and z coordinate you can use the following commands: /execute at @p[name=Horst] run clone ~ ~ ~ ~9 ~9 ~9 0 245 0 /execute at @p[name=Herbert] run clone 0 245 0 9 254 9 ~ ~ ~ /fill 0 245 0 9 254 9 air

Keep in mind that you delete everything in the area from 0 254 0 to 9 254 9, so make sure to choose an area with nothing (important) in it.