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

World.updateEntityWithOptionalForce has sense of "forceUpdate" reversed.

XMLWordPrintable

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

      I am in the midst of investigating MC-22147, where some others are testing the proposed fixes. They are still running into some bugs related to processing in lazy chunks, so I've been looking into how that is handled. Specifically, I'm looking at entity processing at this time, and I'm looking at MCP for 1.12-pre1.

      Every game tick, entities get processed by calling World.updateEntities(). For every non-player entity, updateEntity is called. That calls "this.updateEntityWithOptionalForce(ent, true);"

      Now, the way the comments are written, the forceUpdate argument should FORCE AN UPDATE, even if the entity is not in a lazy chunk. However, there's this code:

      {{ public void updateEntityWithOptionalForce(Entity entityIn, boolean forceUpdate)
      {
      // unimportant code not pasted
      if (!forceUpdate || this.isAreaLoaded(i - 32, 0, j - 32, i + 32, 0, j + 32, true))}}

      Entity processing occurs if the location has surrounding chunks loaded (i.e. is not a lazy chunk) OR if forceUpdate is FALSE.

      That seems like a mistake. All other comments indicate that forceUpdate should ensure that entity processing occurs regardless of whether or not neighboring chunks are loaded, as does other code inside updateEntityWithOptionalForce ifself. But the sense of forceUpdate in that first if is REVERSED. Notice the "!" there.

      Now as a consequence, if it is supposed to be the case that entities ticked by World.updateEntities that are in lazy chunks are not supposed to be updated, then this code path is accidentally getting it right. But the sense of forceUpdate is reversed for everything else, and that method is called in lots of places. So if we fix this, then we need to go to World.updateEntities() and change this:

      this.updateEntity(entity2);

      To this:

      this.updateEntityWithOptionalForce(entity2, false);

      I think calls to these two methods should be more thoroughly investigated, and I can look into that. But could I please get a quick comment from one of the devs on this? Is there something about this code that I don't understand?

      Thanks.

            Unassigned Unassigned
            theosib2 Timothy Miller
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: