Skip to content

World.updateEntityWithOptionalForce has sense of "forceUpdate" reversed. (FWD from MC-119548) #478

@Pokechu22

Description

@Pokechu22

#As brought up by Timothy Miller on mojira in MC-119548, the forceUpdate parameter to "World.updateEntityWithOptionalForce" seems to be reversed.

Timothy Miller writes:

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.

This seems to have been wrong for a long time. Should probably be corrected, but first I think we should make sure we actually understand this.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions