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

Add Chunk Batch support #3263

Merged
merged 6 commits into from
Jan 2, 2024

Conversation

wgaylord
Copy link
Contributor

Adds support for 1.20.2 chunk batches.

chunkBatchStartTime = Date.now()
})

bot._client.on('chunk_batch_finished', (packet) => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you add a comment explaining what is the purpose of this system ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a comment and comments each part of the calculation now that I am doing it correctly.

bot._client.on('chunk_batch_finished', (packet) => {
const chunkPerMill = packet.batchSize / (Date.now() - chunkBatchStartTime) // Get chunks per millisecond
bot._client.write('chunk_batch_received', {
chunksPerTick: 25 / chunkPerMill
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is 25 ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A constant the client uses in that calculation.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do you know why?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/ what is the source of this ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, now I feel dumb and have learned to always double check wiki.vg's info since there is a good chance it could be wrong or slightly incorrect.

Normal client uses this insanity to get its chunksPerTick.

https://github.com/extremeheat/extracted_minecraft_data/blob/client1.20.2/client/net/minecraft/client/multiplayer/ChunkBatchSizeCalculator.java

While the input to the onBatchFinished is the batchsize. No sure where someone got the 25 from and put it on wiki.vg going to probably correct that information later.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated to used the same calculation as 1.20.2 Vanilla client uses. (Although converted to millisecond instead of the nanoseconds they use.)

})

bot._client.on('chunk_batch_finished', (packet) => {
const MilliPerChunk = (Date.now() - chunkBatchStartTime) / packet.batchSize // Gets millisecond per chunk
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should start variable named with lower case

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will fix that when I get home, surprised the linter didnt carch that.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both now start with lower case

@rom1504 rom1504 merged commit c5982bd into PrismarineJS:mc-1.20.2 Jan 2, 2024
20 of 21 checks passed
rom1504 added a commit that referenced this pull request Jan 14, 2024
* Implement configuration.registry_data packet handling

* Fix player entities in >= 1.20.2

* add 1.20.2 in tested versions

* Add Chunk Batch support (#3263)

* Add Chunk Batch support

* Fix linting errors.

* I really hate the linter right now.

* Comment what chunkbatches are for.

* Update chunk batch calculation to use Vanilla's calc but updated for Milliseconds vs Nanoseconds

* Fix usage of variables starting with capital letters

* Update package.json dump mcdata

* server on `login` -> `playerJoin`

* try CI on node20

* node20 on mc test

* revert CI to node18

* update entity handling

* fix typo

* update internal tests

* update internalTest to use feature

* Update README.md

* update pathfinder dep in example and add npmrc in examples

---------

Co-authored-by: Crux <crux153@gmail.com>
Co-authored-by: William Gaylord <chibill110@gmail.com>
Co-authored-by: extremeheat <extreme@protonmail.ch>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Closed
Development

Successfully merging this pull request may close these issues.

2 participants