Skip to content

Commit

Permalink
fix main minestom support
Browse files Browse the repository at this point in the history
  • Loading branch information
mworzala committed Jun 6, 2023
1 parent 0b3dfbb commit e00e837
Showing 1 changed file with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.NotNull;

import java.lang.invoke.MethodHandle;
import java.lang.invoke.MethodHandles;

/**
* A shim for {@link net.minestom.server.utils.chunk.ChunkSupplier} to allow for
* compatibility with main Minestom which does not have the lighting PR (which
Expand All @@ -17,10 +20,10 @@ public interface ChunkSupplierShim {

static @NotNull ChunkSupplierShim select() {
try {
// If this class is present we have the lighting branch and should use that chunk supplier
Class.forName("net.minestom.server.utils.chunk.ChunkSupplier");
// If this function is present we have the lighting branch and should use that chunk supplier
Instance.class.getDeclaredMethod("getChunkSupplier");
return (instance, cx, cz) -> instance.getChunkSupplier().createChunk(instance, cx, cz);
} catch (ClassNotFoundException e) {
} catch (NoSuchMethodException e) {
// Otherwise we should use the default chunk supplier
return DynamicChunk::new;
}
Expand Down

0 comments on commit e00e837

Please sign in to comment.