Arqade Asked on May 21, 2021
Target selectors are used to select certain entities. They accept different arguments to choose which entity to select. Usually, this returns a list of found entities.
Using the limit=n
parameter limits the length of the list to n
(useful with 1
as n
to get a single entity selection). The sort
parameter lets you choose which order the list of targets are sorted in.
The sort
parameter has 4 options, arbitrary
, furthest
, nearest
, and random
. The Minecraft Wiki displays what each of these do:
sort=nearest
— Sort by increasing distance. (Default for @p, @e,[BE] @a[BE])sort=furthest
— Sort by decreasing distance.sort=random
— Sort randomly. (Default for @r)sort=arbitrary
— Do not sort. (Default for @e,[JE] @a[JE])
nearest
, furthest
, and random
are easy to understand in what they do. The one I am curious about is when the arbitrary
choice is selected.
The item returned by a target selector is always an ordered list. What order are they in if they are not sorted?
Here are some possible theories:
It is by definition not guaranteed how they are ordered and Mojang explicitly said (somewhere) that no command contraption should rely on this order. If someone finds this Q&A for any reason other than curiosity, they're probably doing something wrong.
That being said, it seems to have been the order of creation of the entity in memory in all versions from 1.13 to 1.16. This means that if you summon entities and do not close+reopen the world, restart the server, unload and reload the chunks etc., they are pretty much always in summoning order. If you do any of those actions, they are in the order in which their chunks were loaded. Within a chunk, I don't know the order, it might be the same as in the chunk file, which you can inspect with NBTExplorer.
Correct answer by Fabian Röling on May 21, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP