Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix velocity precision errors #1074

Closed
wants to merge 1 commit into from

Conversation

Beaness
Copy link
Contributor

@Beaness Beaness commented Nov 30, 2024

Having re-encode on by default causes packetevents to write a different velocity due to precision errors.
This uses the raw values for writing to not have any precision loss.

An example of a velocity packet that gets rewritten to a different velocity

PacketEvents read -> X: 1.07625, Y: 0.5035, Z: 0.221
1.8.9 client read -> X: 1.07625 Y: 0.503375 Z: 0.221

@booky10
Copy link
Collaborator

booky10 commented Dec 2, 2024

do you have a specific example where packetevents actually changes the value which the client reads?
minecraft encodes velocity values as a short on the protocol level, so even without packetevents there will be a small loss of precision

@Beaness
Copy link
Contributor Author

Beaness commented Dec 2, 2024

Yes I have an example in my first message of this pull request. I wrote a small java file to test all 65535 short values and 744/65535 of those values result into a different velocity value on the client. The precision loss for each of those value is ~0.000125

@Beaness
Copy link
Contributor Author

Beaness commented Dec 2, 2024

minecraft encodes velocity values as a short on the protocol level, so even without packetevents there will be a small loss of precision

The problem is the re-encoding of the velocity which does not convert to the same short values back which causes the client to read a different velocity value.

@booky10 booky10 closed this in 9819db6 Dec 2, 2024
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.

2 participants