The x
, y
, and z
parameters only specify origin, and will still search the entire world for a target closest to that origin (which will always be found). You must use an area limiter such as r
for a radius or dx/dy/dz
for a square.
However, any of the coordinate origin values not specified will default to the value of the command executor. In this case, by not specifying x
or y
, they will default to the command block's coordinates. By adding an area limiter to your first command, it would only find players at the specified Z coordinate, but those players must have the same X and Y coordinate as the command block.
The solution is to use /execute
to change the origin to that of the targets, and then modify the origin and include an area limiter. You can either modify the origin in the /execute
syntax directly, or in the nested selector:
/execute @a ~ ~ 0 /replaceitem entity @a[dx=0,c=1] slot.hotbar.4 written_book 1 0 {Written book data}
Or:
/execute @a ~ ~ ~ /replaceitem entity @a[z=0,dx=0,c=1] slot.hotbar.4 written_book 1 0 {Written book data}
The !
operator can only be used with string-based parameters, being team
, name
, type
, tag
, and m
.
Best Answer
Make sure that your repeating command block either has a redstone signal, or is set to always active.
The command will also fail if the coordinates
90 56 33 107 59 30
are too far away.Try to use
at
instead ofas
.If you use
as
, then your command executes as all arrows, at the location of your command block.If you use
at
, then your command executes as the command block, at the loaction of every arrow.The command that you currently have should do something once, it should clone whatever is at
90 56 33 107 59 30
to the location of your command block, which effectively replaces the command block with the block at90 56 30
.