Skip to content

Commit 11e4f9f

Browse files
committed
palette fix when id block is -1
1 parent 7c76723 commit 11e4f9f

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

src/main/java/me/mapacheee/extendedhorizons/viewdistance/service/ChunkLoaderService.java

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -468,8 +468,26 @@ private void sendChunkPacket(Player player, Object chunk, long key, Set<Long> se
468468
.performance().fakeChunks().antiXray();
469469

470470
if (antiXray != null && antiXray.enabled()) {
471-
chunkToSend = nmsChunkAccess.cloneChunk(chunk);
472-
if (chunkToSend != null) {
471+
CompletableFuture<Object> cloneFuture = new CompletableFuture<>();
472+
final Object sourceChunk = chunkToSend;
473+
474+
Bukkit.getScheduler().runTask(ExtendedHorizonsPlugin.getInstance(), () -> {
475+
try {
476+
cloneFuture.complete(nmsChunkAccess.cloneChunk(sourceChunk));
477+
} catch (Exception ex) {
478+
cloneFuture.completeExceptionally(ex);
479+
}
480+
});
481+
482+
try {
483+
chunkToSend = cloneFuture.get();
484+
} catch (Exception ex) {
485+
if (DEBUG)
486+
logger.warn("[EH] Failed to clone chunk on main thread: {}", ex.getMessage());
487+
chunkToSend = chunk;
488+
}
489+
490+
if (chunkToSend != null && chunkToSend != chunk) {
473491
nmsChunkAccess.obfuscateChunk(
474492
chunkToSend,
475493
antiXray.hideOres(),

0 commit comments

Comments
 (0)