(I’m making this answer because the execute command changed in 1.19.50)
The only way to do this is to change where ~ ~ ~ is, so you would have to provide the first set of coordinates. The new command is:
/execute at @e[type=armor_stand] run fill [x] [y] [z] ~ ~ ~ [block]
Make sure to replace [x] [y] [z] and [block] with your first set of coordinates and your block of choice.
Explanation: The execute
command can change the way following commands are run, or only run them if a condition is met. at
is a modifier that changes the position, dimension, and rotation of the following modifiers and commands, and @e[type=armor_stand]
selects all entities that are armor stands, so at @e[type=armor_stand]
sets the position to an armor stand. There are ways to make it only target one stand with tags, but that is more complicated, so it is recommended to remove all other armor stands, or use /tag
, which is explained below. run
is where you put the command you want to run, you can put multiple modifiers before run
, so run
tells execute
where the modifiers end and the main command begins. Now when fill
runs, ~ ~ ~ is the position of the armor stand.
If you want/need other armor stands, the simplest way is to use /tag
. Get in the same block as the armor stand you want to tag, and run
/tag @e[type=armor_stand,r=1] add fill
.
/tag
adds a word (called a tag) to entities that can be looked for with @a, @p, @s, @r, and @e
. r=1 (distance=..1 on Java)
selects all armor stands within 1 block of the player. The command needs to be changed to:
/execute at @e[type=armor_stand,tag=fill] run fill [x] [y] [z] ~ ~ ~ [block]
Now, the @e
selector is looking for entities that are armor stands and have the tag “fill” attached, instead of whatever random stand it chooses.
/fill
command only accepts integer coordinates of the corners of the area. You can't fill 'to' an entity. There's probably a work-around that I don't dare to write, but you can't do this with just /fill.