mojira.dev
MC-81485

Performance Issue for entity selectors

A few days ago, I was working with Entity selectors, and wanted to target any players at y=4 or below. My Entity selector ended up like this:

@a[x=-30000000,y=0,z=-30000000,dx=60000001,dy=4,dz=60000001]
This would essentially track any player inside the map, but I ran into a problem while doing so, and the server froze.

From this I've assumed that the game is analyzing the world block by block, looking for a player. Putting this into perspective, it's scanning 1.8e+16 blocks, one by one, attempting to do this in less than 1/20 of a second, which is not always possible.

To get around this, I suggest the following:

Instead of testing block for block, perhaps... just iterate through each entity, and selecting those who match the interval. In coding (For this, I'll use Javascript, the only language I know and can put this on), this would be:

for(i in world.entities){
if(world.entities[i].x >= x && world.entities[i].x <= x + dx){
command.selector.selectedEntities.push(world.entities[i]);
}
}

(Only handling x values as an example)
This means, that if... an entity is at x=10, and the selector is @e[x=0,dx=100], it will be selected because...
10 >= 0 and 10 =< 100

I believe this could potentially boost command block creations by a considerable amount and allow more with less calculations.

Comments 2

This site is for bug reports only. For feature suggestions or changes please see: Minecraft Suggestions on Reddit.

The game does not check block by block, but chunk by chunk. Even if it's not the best design choose, there still exist some "correct" way to check for players below with the selector like @e[y=0,dy=4].

A bug like this has already been reported here : MC-73916

energyxxer

(Unassigned)

Unconfirmed

Minecraft 1.8.7

Retrieved