owengage / fastnbt

Fast serde serializer and deserializer for Minecraft's NBT and Anvil formats
MIT License
185 stars 35 forks source link

Complete chunk #81

Closed ToBinio closed 1 year ago

ToBinio commented 1 year ago

this would be the basic structure of complete::chunk

its not even close to being finished. But i wanted to check if you thought about it like this.

any thoughts on the structure?

maby i misunderstood something about y_range() becouse if i try getting a block from the lowest y it always fails. this is true for complete::chunk but also for CurrentJavaChunk

owengage commented 1 year ago

maby i misunderstood something about y_range() becouse if i try getting a block from the lowest y it always fails. this is true for complete::chunk but also for CurrentJavaChunk

-64 should be the lowest y value that is valid for a Minecraft chunk nowadays correct? Is that what's failing?

ToBinio commented 1 year ago

normaly -64 is the lowest, yes.

it is also the lowest y a block can be read from. but why does y_range() return -80 then?

owengage commented 1 year ago

I can't replicate the -80.

Running the following with a random region file from one of my worlds:


fn main() {
    let args: Vec<_> = std::env::args().skip(1).collect();
    let file = std::fs::File::open(args[0].clone()).unwrap();

    let mut region = Region::from_stream(file).unwrap();

    for chunk in region.iter().flatten() {
        let chunk: CurrentJavaChunk = from_bytes(&chunk.data).unwrap();
        let range = chunk.y_range();
        println!("{:?}", range);
    }
}

and I get lots of:

-64..320
-64..320
-64..320
-64..320
-64..320

as expected.

ToBinio commented 1 year ago

ok... i kinda figured it out.

it seems like on of my mods (only perfomance optimizations) does something weird with the world data.

owengage commented 1 year ago

Not sure how far you want to take this PR. The basic structure is here and allows iterating over blocks in a read only way. I'm happy for that to be this PR.

I might be interested in working on top of this to make it serializable back into a region file, if you're not already interested in doing so.

ToBinio commented 1 year ago

just wanted to add the most basic pre18 | pre13 support.

btw... thanks for your always quick answers, and for letting me work on this

owengage commented 1 year ago

Sounds great, and no problem. Thank you for contributing.

Let me know when the PR is ready and I'll have a look again.