Skip to content

Separate library from Minestom #67

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion BENCHMARK.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class ScuffedBenchmark {
System.out.println("Starting iteration " + iter);
// TNTLoader loader = new TNTLoader(new FileTNTSource(Path.of("src/test/resources/bench/bench.tnt")));
// AnvilLoader loader = new AnvilLoader(Path.of("src/test/resources/bench"));
PolarLoader loader = new PolarLoader(PolarReader.read(Files.readAllBytes(Path.of("src/test/resources/bench.polar"))));
PolarLoader loader = new PolarLoader(MinestomPolarReader.read(Files.readAllBytes(Path.of("src/test/resources/bench.polar"))));
for (int x = 0; x < 32; x++) {
for (int z = 0; z < 32; z++) {
loader.loadChunk(instance, 0, 0).join();
Expand Down
117 changes: 0 additions & 117 deletions build.gradle.kts

This file was deleted.

44 changes: 44 additions & 0 deletions common/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
plugins {
`java-library`
kotlin("jvm")
}

group = "dev.hollowcube"
version = System.getenv("TAG_VERSION") ?: "dev"
description = "Fast and small world format for Minestom"

repositories {
mavenLocal()
mavenCentral()
maven(url = "https://jitpack.io")
}

dependencies {
compileOnly("org.jetbrains:annotations:26.0.2")
api("net.kyori:adventure-api:4.21.0")
api("net.kyori:adventure-nbt:4.21.0")
api(libs.zstd)
// Fastutil is only included because minestom already uses it, otherwise it is a crazy dependency
// for how it is used in this project.
api(libs.fastutil)

testImplementation("ch.qos.logback:logback-core:1.4.7")
testImplementation("ch.qos.logback:logback-classic:1.4.7")

testImplementation(platform("org.junit:junit-bom:5.9.1"))
testImplementation("org.junit.jupiter:junit-jupiter")
implementation(kotlin("stdlib-jdk8"))
}

java {
withSourcesJar()
withJavadocJar()
}

tasks.test {
maxHeapSize = "2g"
useJUnitPlatform()
}
kotlin {
jvmToolchain(21)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package net.hollowcube.polar;

public interface DimensionTypeWrapper {
int minY();
int maxY();
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
package net.hollowcube.polar;

import net.minestom.server.utils.validate.Check;

final class PaletteUtil {
private PaletteUtil() {}

public static int bitsToRepresent(int n) {
Check.argCondition(n < 1, "n must be greater than 0");
assert n > 0: "n must be greater than 0";
return Integer.SIZE - Integer.numberOfLeadingZeros(n);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@


import net.kyori.adventure.nbt.CompoundBinaryTag;
import net.minestom.server.instance.Chunk;
import org.jetbrains.annotations.Nullable;

import java.util.List;
Expand Down Expand Up @@ -35,7 +34,7 @@ public record PolarChunk(
HEIGHTMAP_WORLD_SURFACE,
HEIGHTMAP_WORLD_SURFACE_WG,
};
static final int HEIGHTMAP_SIZE = Chunk.CHUNK_SIZE_X * Chunk.CHUNK_SIZE_Z;
static final int HEIGHTMAP_SIZE = 16 * 16;
static final int MAX_HEIGHTMAPS = 32;

public int @Nullable [] heightmap(int type) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package net.hollowcube.polar;

import net.kyori.adventure.nbt.CompoundBinaryTag;
import net.minestom.server.MinecraftServer;
import org.jetbrains.annotations.NotNull;

import java.util.Map;
Expand All @@ -19,14 +18,14 @@ public interface PolarDataConverter {
* do not store a data version. Defaults to the current Minestom data version.
*/
default int defaultDataVersion() {
return MinecraftServer.DATA_VERSION;
return -1;
}

/**
* Returns the current data version of the world.
*/
default int dataVersion() {
return MinecraftServer.DATA_VERSION;
return -1;
}

/**
Expand Down
Loading