Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR adds a memory-mapped anvil file reader
Description
The anvil file format is how minecraft chunks are stored in the vanilla implementation. Even though we aren't using the anvil file format to store our chunks, we still need to be able to read it in order to to import chunks. Due to that, this system only supports reading, not writing. While reading single chunks at a time is supported, it is optimized for reading all of the chunks from an anvil file in one go.
Motivation and Context
This is needed in order to import chunks from vanilla
How has this been tested?
Unit tests are included that verify it has the same output as fastanvil and that it can read valid anvil files properly. It also checks to make sure invalid anvil files cannot be read properly, as due to the minimal format it is reasonably possible for an invalid file to produce gibberish data. The ZLIB Addler32 checksum is checked to make sure the nbt data is correct.
This feature does use memory-mapping to speed up IO processes, but this does come with inherent unsafe code usage. This unsafe code is handled entirely by the memmap2 crate and we just have to use a couple unsafe blocks so we can use the unsafe functions they provide, so the chance of the unsafe code causing issues is minimal and the memmap2 crate would be at complete fault if that happened.
Screenshots (if appropriate):
Types of changes
Checklist: