Example: /kill @my_list. It kills all the entities that were added to the custom list called "my_list".
Whenever you want to target entities with the same "nature" in your datapack, you would summon them with a certain common tag.
Example: execute as @e[tag=A] run function update.
The problem with this is that it iterates through the whole entities list. Let N be the no. of entities loaded. you will get O(N).
If you use tags to mark unique entities, to access them it will take you at least O(N), when logically what you are doing should run in O(1). Maybe this not a very drastic change, especially considering that N is usually a small number, <100.
But operations which now run in O(N^2) could be reduced to O(n). and this is a big deal.
It hurts my eyes whenever i have a function which doesn't simply run with @s everywhere.
Problems that could appear:
- what happens when an entity is unloaded
- Or when it is loaded back
Possible options:
- modify the list so it works as a stack/queue
- selecting a criteria and then modify the list so it works as a(n) unordered list/ set / heap (also known as a priority queue)
Please sign in to leave a comment.
0 Comments