Skip to content

Commit

Permalink
feat: anvilpolar simplified using new anvil loader
Browse files Browse the repository at this point in the history
  • Loading branch information
mworzala committed Apr 25, 2024
1 parent fe16a1a commit 3312f50
Show file tree
Hide file tree
Showing 7 changed files with 148 additions and 298 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ instance.saveChunksToStorage();

Anvil conversion utilities are also included, and can be used something like the following.

> Note: Anvil conversion is only guaranteed to work on recent (1.19+) worlds.
> Note: Anvil conversion is only guaranteed to work on the latest version worlds. Try loading and saving the world in a
> vanilla client or server if it doesnt work!
```
var polarWorld = AnvilPolar.anvilToPolar(Path.of("/path/to/anvil/world/dir"));
Expand Down Expand Up @@ -93,7 +94,7 @@ public class UpdateTimeWorldAccess implements PolarWorldAccess {
}
```

Using a `PolarWorldAccess` implementation is as simple as attaching it to the `PolarLoader`:
Using a `PolarWorldAccess` implementation is as simple as attaching it to the `PolarLoader`:
`new PolarLoader(world).setWorldAccess(new UpdateTimeWorldAccess())`

## Comparison to others
Expand Down
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
metadata.format.version = "1.1"

[versions]
minestom = "dev"
minestom = "1_20_5-d51c6c75e2"
zstd = "1.5.5-3"
fastutil = "8.5.12"

Expand Down
404 changes: 122 additions & 282 deletions src/main/java/net/hollowcube/polar/AnvilPolar.java

Large diffs are not rendered by default.

28 changes: 19 additions & 9 deletions src/test/java/net/hollowcube/polar/TestAnvilPolar.java
Original file line number Diff line number Diff line change
@@ -1,20 +1,30 @@
package net.hollowcube.polar;

import net.minestom.server.MinecraftServer;
import org.junit.jupiter.api.Test;

import java.nio.file.Files;
import java.nio.file.Path;

import static org.junit.jupiter.api.Assertions.assertEquals;

class TestAnvilPolar {

static {
MinecraftServer.init();
}

@Test
void testConvertAnvilWorld() throws Exception {
// var world = AnvilPolar.anvilToPolar(
// Path.of("/Users/matt/Downloads/dripleaf copy 4").toRealPath(),
// -4, 19
// );
// assertEquals(-4, world.minSection());
//
// var result = PolarWriter.write(world);
// System.out.println(result.length);
// Files.write(Path.of("./src/test/resources/7c1d979c-3660-40fa-a7e3-acf9417411ac"), result);
var world = AnvilPolar.anvilToPolar(
Path.of("./src/test/resources/bench").toRealPath(),
-4, 19
);
assertEquals(-4, world.minSection());

var result = PolarWriter.write(world);
System.out.println(result.length);
Files.write(Path.of("./src/test/resources/test123"), result);
}

}
7 changes: 3 additions & 4 deletions src/test/java/net/hollowcube/polar/demo/DemoServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import net.minestom.server.event.player.PlayerChatEvent;
import net.minestom.server.event.player.PlayerSpawnEvent;
import net.minestom.server.instance.InstanceContainer;
import net.minestom.server.instance.LightingChunk;

import java.nio.file.Files;
import java.nio.file.Path;
Expand All @@ -32,10 +31,10 @@ public static void main(String[] args) throws Exception {
var instance = MinecraftServer.getInstanceManager().createInstanceContainer();

// Unlit
// instance.setChunkSupplier(LightingChunk::new);
// instance.setChunkLoader(new PolarLoader(Path.of("./src/test/resources/hcspawn.polar")));
instance.setChunkLoader(new PolarLoader(Path.of("./src/test/resources/bench_1205.polar")));
// Lit
instance.setChunkLoader(new PolarLoader(Path.of("./hcspawn.polar")));
// instance.setChunkSupplier(LightingChunk::new);
// instance.setChunkLoader(new PolarLoader(Path.of("./hcspawn.polar")));


MinecraftServer.getGlobalEventHandler()
Expand Down
Binary file modified src/test/resources/bench/region/r.0.0.mca
Binary file not shown.
Binary file added src/test/resources/bench_1205.polar
Binary file not shown.

0 comments on commit 3312f50

Please sign in to comment.