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

Cant get a nested tag #30

Open
Awire9966 opened this issue Apr 26, 2024 · 1 comment
Open

Cant get a nested tag #30

Awire9966 opened this issue Apr 26, 2024 · 1 comment

Comments

@Awire9966
Copy link

Hi. I am trying to read from the Minecraft level.dat file for a project i am working on. This is my code:

CompoundTag WorldData = NbtFile.Read(WorldFolder + @".\level.dat", FormatOptions.Java, CompressionType.AutoDetect);
var seed = WorldData["Data"]["WorldGenSettings"]["Seed"];

It is giving me the error stating that I cant use [] on the Array.

@ForeverZer0
Copy link
Owner

I am uncertain why you would be getting an array-related error based on the given example. According to the wiki, the key for the seed should be "seed", and not "Seed", though I assume that would cause an error related to the key, not an indexing error for an Array.

Would you be able to separate these out to see which accessor specifically is causing the error, and confirming that each tag is being deserialized correctly?

var data = WorldData["Data"];
var gen = data["WorldGenSettings"];
var seed =  gen["seed"];

On another note, not likely related to your problem, is the leading dot in WorldFolder + @".\level.dat" intended?

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