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

Support for POI mca files? #92

Open
Charlweed opened this issue Jul 14, 2023 · 0 comments
Open

Support for POI mca files? #92

Charlweed opened this issue Jul 14, 2023 · 0 comments

Comments

@Charlweed
Copy link

Charlweed commented Jul 14, 2023

It seems that neither NBTUtil nor MCAUtil can read Minecraft POI files, as found in foo/world/poi.
I am expecting to find data as described in this fandom wiki
MCAUtil fails with "java.lang.IllegalArgumentException: data does not contain "Level" tag" at "net.querz.mca.Chunk.initReferences(Chunk.java:71)"
I tried this method, and I have not been able to get any tag content.

    public static void readPOIMCAs() {
        final String POI_DIR_STR = "L:\\bin\\minecraft-server\\server_instance\\latest\\world\\poi";
        java.nio.file.Path poi_dir = Path.of(POI_DIR_STR);
        if (!Files.exists(poi_dir)) {
            IOException inner = new IOException("Could not find directory " + poi_dir);
            throw new RuntimeException(inner);
        }
        LOGGER.info("Scanning files in " + poi_dir);
        Set<Path> mcaPaths = new HashSet<>();
        try (DirectoryStream<Path> stream = Files.newDirectoryStream(poi_dir)) {
            for (Path path : stream) {
                String fileName = path.getFileName().toString();
                if (fileName.matches("r\\..+\\.mca")) {
                    mcaPaths.add(path);
                }
            }
            LOGGER.info(String.format("POI dir \"%s\" has %d mca files", poi_dir, mcaPaths.size()));
            for(Path mcaPath : mcaPaths){
                String mcaFileString = mcaPath.toAbsolutePath().toString();
                // MCAFile mcaFile = MCAUtil.read(mcaFileString);
                NamedTag namedTag = NBTUtil.read(mcaFileString);
                String tagName= namedTag.getName();
                Tag<?> innerTag = namedTag.getTag();
                String snbt = SNBTUtil.toSNBT(innerTag);
                LOGGER.info(String.format("File: %s; Tag \"%s\"; SNBT: \"%s\"; JSON: %s", mcaFileString, tagName, snbt,innerTag.toString()));
            }
        }
        catch (IOException ioe) {
            throw new RuntimeException(ioe);
        }
    }
    

There is no content from snbt nor json. The log output here looks like:

INFO: File: L:\bin\minecraft-server\server_instance\latest\world\poi\r.1.2.mca; Tag ""; SNBT: ""; JSON: {"type":"EndTag","value":"end"}

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

1 participant