-
-
Notifications
You must be signed in to change notification settings - Fork 148
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
Superflat Worldgeneration #63
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
These ensure that there aren't any out of bound values and make the code significantly more readable
Renamed `WORLD_Y_START_AT` to `WORLD_LOWEST_Y`. Added `WORLD_Y_END_AT`. Changed the type to i16 for ergonomics. Moved the constants under the use statements for readability.
renamed a few fields for clarity. added examples for fields that might not immediately be obvious. removed some `Option`s that are not necessary. renamed `BlockElement` to `BlockType` because you could mistake `BlockElement` for the main way to represent a Block (e.g. in Chunks).
`i32` is really ambiguous and it is not immediately obvious what it is supposed to represent. `BlockId` is much more readable. Changed internal type to u16 because we currently have ~30k/64k block states. (and i32 doesn't make a lot of sense for an Id, except when replicating mojang behavior)
Simply count blocks instead of doing some complex operation with k/j/i Marked comment with TODO Replaced if/else condition with std::cmp::max Removed some redundant `.enumerate()`s
ChunkBlocks makes it easy & safer to access blocks of a chunk. It also makes it possible to consistently handle the heightmap updates in 1 place.
Moved `BlockId` to it's own file. Prefixed all of the `block_registry` types with Registry to avoid confusion. Made stuff that should not be public private.
Added new error types to indicate a chunk should be generated. Renamed to `fetch_chunks` to indicate that it no longer just reads chunks (might write to the worldfile in the future) Take a reference to a slice instead of an owned vector because the data is Copy anyways. Remove the ChunkCoordinates that are sent over the mpsc Sender. - The coordinates are stored in ChunkData anyways. - If there is an Error the coordinates should not matter because the error can't be recovered from. Moved the reading from file logic to `read_chunk`. - So that we don't always have to repeat `channel.blocking_send(...); return;` - To make it clearly distinct from the main program logic. Replaced some verbose match statements with `Result.map_err()`.
When loading a partially generated world there's some incomplete chunks that might not have a heightmap yet. If that is the case we return a ChunkNotGeneratedError to indicate that it's ok to (re-)generate it.
Snowiiii
reviewed
Aug 28, 2024
…ile. Moved warning about ./world folder to only appear when necessary + Updated warning contents to reflect changes Made the save_file in the `Level` struct optional in case someone wants an entirely generated World. Removed now redundant asserts.
Great job. Thank you @DaniD3v ❤️ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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 Superflat Worldgeneration.
By default the vanilla
./world
file is still read but chunks that are not generated yet are replaced by newly generated chunks.This is currently not configurable because I plan on making it configurable after the "move config to
LazyLock
" PR will be rejected/merged.If I went a bit overboard with all the refactors tell me and I'll cherry-pick the commits into another branch.
All of the commits compile individually and were checked with
related to #36