mojira.dev
MC-119548

World.updateEntityWithOptionalForce has sense of "forceUpdate" reversed.

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.

Comments 5

Remember that MCP mappings are crowdsourced, and not the version of the source that the actual developers see. If the code seems to differ from the comments, it's probably a MCP mistake. You can report MCP mapping issues [here|
https://github.com/ModCoderPack/MCPBot-Issues], and change comments and such through mcpbot.

Thanks, Pokechu22. But could we get a comment on this from the source to find out what the correct semantics are? I mean, I can tell from OTHER CODE that forceUpdate should have positive semantics. The comments may be crowd-sourced, but the code is from decompiling.

Thanks.

The parameter names (and method and field names) are also crowdsourced FYI. I do agree that this seems weird, but it feels more like a case of MCP having inaccurate mappings than it's something that would be fixed there.

I've created MCPBot issue #478; let's discuss this further there. I'll also ask the devs, but it's not exactly the best time of day for that.

Thanks, Pokechu22. I really appreciate the help on this!

Pokechu22, I think we should hold off contacting anyone at Mojang about this. I've dug through all the code that gives "forceUpdate" meaning, and I think it really means something on the line of "update on the basis of applied forces." The name isn't wrong so much as misleadingly ambiguous. Either way, I'm sure it doesn't mean what I or anyone writing the comments thought it meant.

Timothy Miller

(Unassigned)

Unconfirmed

Minecraft 1.12

Retrieved