Uploaded image for project: 'Minecraft: Java Edition'
  1. Minecraft: Java Edition
  2. MC-81485

Performance Issue for entity selectors

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Invalid
    • None
    • Minecraft 1.8.7
    • None
    • Unconfirmed

      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.

            Unassigned Unassigned
            energyxxer Energyxxer
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: