Skip to content

Fix player walking on contraption causes lag (#9598)#10570

Open
lzpoupl wants to merge 1 commit into
Creators-of-Create:mc1.21.1/devfrom
lzpoupl:mc1.21.1/dev
Open

Fix player walking on contraption causes lag (#9598)#10570
lzpoupl wants to merge 1 commit into
Creators-of-Create:mc1.21.1/devfrom
lzpoupl:mc1.21.1/dev

Conversation

@lzpoupl

@lzpoupl lzpoupl commented Jul 1, 2026

Copy link
Copy Markdown

Related issues: #9153 #4646 #9598 #6855

The bug appears to be caused by the contraption step sound Mixin

mistakenly passing a contraption-local BlockPos into playStepSound(pos, state). For non-player entity like zombie, this method won't use the pos parameter, so nothing happens.

However, for players this dispatches to Player.playStepSound, which treats the position as a world position and performs additional level.getBlockState(...) lookups. Then, the server takes the local coordinates and interprets them as world coordinates, repeatedly querying a chunk near (0, 0) that is not loaded, which is an unnecessary cost and causes lag and extra memory usage.

Example of the coordinate mismatch:

player world position: (10003, 58, 10007)
contraption-local position: (3, 1, 7)
queried world chunk: (0, 0)

My solution now is to fall back to the implementation of Entity.playStepSound(). There might be a better solution, but I don't know much about minecraft sound engine and Mixin so I can't figure it out, though the cause of the bug is now clear.

A temporary workaround for this bug: /forceload the chunks around (0, 0) to mitigate the lag caused by repeated chunk loading.

I have another question. The Mixin class is in client package, so in theory it shouldn't cause server thread to lag, but it indeed does.

@lzpoupl

lzpoupl commented Jul 2, 2026

Copy link
Copy Markdown
Author

@TqLxQuanZ Solution to your modpack lag issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant