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

Reading Bedrock level.dat/.mcstructure files #3

Open
BJTMastermind opened this issue Oct 12, 2021 · 4 comments
Open

Reading Bedrock level.dat/.mcstructure files #3

BJTMastermind opened this issue Oct 12, 2021 · 4 comments

Comments

@BJTMastermind
Copy link

BJTMastermind commented Oct 12, 2021

I am trying to use quartz_nbt to read nbt data from Bedrock files but I can't seem to get it to work.
Im getting an Error: TagTypeMismatch { expected: 10, found: 8 } with this code:

use std::fs::File;
use quartz_nbt::io::{self, Flavor, NbtIoError};

fn main() -> Result<(), NbtIoError> {
    let mut bedrock_test = File::open("assets/bedrock/level.dat")?;
    //let mut java_test = File::open("assets/java/level.dat")?;
    
    let nbt = io::read_nbt(&mut bedrock_test, Flavor::Uncompressed)?;

    println!("uncompressed: {:?}", nbt);
    
    Ok(())
}

this works fine with the java files though when the "Flavor" is also set to GzCompressed.
Any help? I do know Bedrock nbt files are Uncompressed I believe.

I can also provide the nbt files if they are needed.

Thank you.

@BJTMastermind BJTMastermind changed the title Reading Bedrock level.dat/*.mcstructure files Reading Bedrock level.dat/.mcstructure files Oct 12, 2021
@BJTMastermind
Copy link
Author

After looking through the source files of quartz_nbt I think the reason for this is because quartz_nbt currently does not support little-endian byte order. If this were added I believe it will work with minor changes to the code I showed.

@Cassy343
Copy link
Collaborator

Bedrock edition actually makes quite a few changes to NBT format. They store some integers and longs as variable-length integers using zig-zag encoding; there are different variations of the format for disk storage vs. network traffic; root tags can be compounds or lists; and as you mentioned, they also use little-endian byte order. Supporting this would require a fairly substantial overhaul of the current code base and require changing several of the APIs, so I'm inclined to say it's unlikely that we'll support encoding/decoding of bedrock's NBT format for the foreseeable future.

@BJTMastermind
Copy link
Author

BJTMastermind commented Oct 14, 2021

oh ok, didn't think it had that many differences. I was hoping that it could be added so there could be a good rust crate to use for both versions of the game. Do you know of any rust crates that support the bedrock format that I could use because I'm not aware of any? If not could you give me a link to bedrock nbt documentation so I could try to make my own?

@Cassy343
Copy link
Collaborator

I do not know of any rust NBT libraries which support bedrock unfortunately. This wiki explains the Java format as well as how bedrock differs from it. I will be leaving this issue open however so that it can be revisited in the future.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants