How can I /execute a command on all Endermen on the outer End islands in Minecraft 1.13?
When you use a selector that includes dimension-binding parameters (x/y/z/dx/dy/dz/distance
), the dimension of execution will be restricted to the command sender's dimension. The gameLoopFunction
function will run commands with the Overworld as the dimension of execution.
For example, the following command says the names of all entities in all loaded dimensions because no dimension-binding parameter is used:
say All entities: @e
Once one of the parameters is included, the command will only say the names of entities in the command sender's dimension. If the command were run in a command block in the Overworld, it will only say the names of entities in the Overworld. If the command block were in the End, it will only say the names of entities in the End:
say Entities in the current dimension: @e[x=0]
Since your command is running via gameLoopFunction
and includes distance=256..
, it will be restricted to selecting endermen in the Overworld (of which none will have their Dimension
tag naturally set to 1).
In 1.12, you would work around this by using /execute
to change the command sender to one that is known to be in the desired dimension, who will then run the command you wish to affect only that dimension. For example, assuming that an entity with the tag "end" exists only in the End, the following will say the names of all entities in the End dimension even if the command block (or gameLoopFunction
) running this command is not in the End:
execute @e[tag=end] ~ ~ ~ say Entities in the End: @e[x=0]
Unfortunately for 1.13, there is currently a bug preventing the dimension of execution from changing to the relevant target in /execute
: https://bugs.mojang.com/browse/MC-122893
That bug must be fixed in order to use this method. Otherwise you will have to have physical command blocks in the End, though that does not help if they are not loaded.