Skip to content

Round position fixed-point numbers down - #723

Closed
roccodev wants to merge 1 commit into
ViaVersion:masterfrom
roccodev:fix/fixed-point-rounding
Closed

Round position fixed-point numbers down#723
roccodev wants to merge 1 commit into
ViaVersion:masterfrom
roccodev:fix/fixed-point-rounding

Conversation

@roccodev

@roccodev roccodev commented Sep 3, 2026

Copy link
Copy Markdown

While #707 correctly points out that truncating the 1.8 fixed-point position numbers is wrong, the solution presented there is also wrong. In all the packet handlers that transformer is used, the result should be rounded down (towards negative infinity) instead.

See source for things like PacketPlayOutEntityTeleport etc.

@Beaness

Beaness commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Even though vanilla uses floor, wouldn't it still better to use the round? This makes it as close as possible to the "real" value.
Using floor would just recreate vanilla bias that isn't needed?

@Term4

Term4 commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

In the case in which that solution applies, the true "server position" broadcast to players (ignoring translation) uses round. While this is different from 1.8, I don't see why we would want to intentionally create a desync between what clients on differing protocols see. The server is the source of truth, not the translation. If there's a legitimate use case or a case where this solution causes a problem I would like to know so we can get the correct solution in place. Maybe a config option? But to be honest this seems like more of a server side solution. If you want to preserve floor, the server should broadcast floor, and using round in translation will preserve whatever the server broadcasts more accurately anyways.

@roccodev

roccodev commented Sep 5, 2026

Copy link
Copy Markdown
Author

@Term4 That makes sense! Honestly I'm coming from a 1.8 background so I've somewhat been trying to make everything like 1.8, but yeah it should probably be the other way around.

@roccodev roccodev closed this Sep 5, 2026
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.

3 participants