hollow-cube / polar

Fast and small world format for Minestom
MIT License
96 stars 13 forks source link

1.21 Anvil File Not Being Converted #58

Closed Hycord closed 1 month ago

Hycord commented 1 month ago

I pulled the whole world from our server and was able to load it fine in single player, but when I convert it using polar it is just a void world

The file is like 100kb

// In server init

        WorldManager.FromAnvil(Path.of("data/worlds/lobby"), "lobby");   
// WorldManager
 public static Path FromAnvil(Path anvilPath, String worldName) {
        Path worldFile = worldFolder.resolve(worldName + ".polar");
        try {
            if (!Files.exists(worldFile)) {
                LogManager.info("Converting world file to " + worldFile.toString());  

                PolarWorld polarWorld = AnvilPolar.anvilToPolar(anvilPath);
                byte[] polarWorldBytes = PolarWriter.write(polarWorld);
                Files.write(worldFile, polarWorldBytes, StandardOpenOption.CREATE);
                LogManager.info("Converted world file " + worldFile.toString()); 
            } else {
                LogManager.info("World file already exists at " + worldFile.toString());
            }

            return worldFile;
        } catch (IOException e) {
            throw new RuntimeException("Unable to create world file", e);
        }
    }
Hycord commented 1 month ago

The problem was that I was doing worldLoader.loadInstance(instance); instead of instance.setChunkLoader(worldLoader);