-
-
Notifications
You must be signed in to change notification settings - Fork 331
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
Blocks toml #351
base: main
Are you sure you want to change the base?
Blocks toml #351
Conversation
I'm not sure why these were initally functions. I think they are better off as global arrays, since the function would initialize a new vec every time its called, whereas this only initializes it once.
src/data_processing.rs
Outdated
@@ -141,7 +141,7 @@ pub fn generate_world( | |||
let total_iterations_grnd: f64 = (scale_factor_x + 1.0) * (scale_factor_z + 1.0); | |||
let progress_increment_grnd: f64 = 30.0 / total_iterations_grnd; | |||
|
|||
let groundlayer_block = if args.winter { SNOW_BLOCK } else { GRASS_BLOCK }; | |||
let groundlayer_block = if args.winter { BLOCKS.by_name("snow_block").unwrap() } else { BLOCKS.by_name("grass_block").unwrap() }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is... not the most elegant API. 🤷🏼♂️
This is a good idea, but right now the implementation has some drawbacks:
|
8af2e3b
to
f121fae
Compare
Meh, I guess the performance penalty is small...
True. That might be worth looking into. It still requires a global variable, though, and it seems clunky and tough to massage your struct into something nice.
Returning an Option is probably the right thing to do. You can always just |
Would it be better to use something like If we had |
TODO squash this and reword
f121fae
to
ce5bcf4
Compare
Trying to get static_toml working is not the best, but I asked about potentially modifying it to generate Option types for optional values here: cptpiepmatz/static-toml#6 |
The current
block-defs.rs
is not a great solution. Instead, put all block info in a toml file, and pull it in (ideally, at compile time). Then, simply query the one you need either by its ID or name.Note
The things to look at in this PR are
block_definitions.rs
andblocks.toml
. Everything else is just myfailed(it's getting there!) attempt to update all the API calls, and is now outdated anyway. We will get there eventually.All, let me know if you like this change, and see my below comments for more info.