From 87d080416da4308c1ed22f0518a3d027fdb137a8 Mon Sep 17 00:00:00 2001 From: Ellpeck Date: Fri, 31 Dec 2021 11:28:39 +0100 Subject: [PATCH] possibly finally fixed the chunk nightmare of 2021 (#235) --- src/main/java/de/ellpeck/naturesaura/Helper.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/de/ellpeck/naturesaura/Helper.java b/src/main/java/de/ellpeck/naturesaura/Helper.java index 5136ed4d..8abdb955 100644 --- a/src/main/java/de/ellpeck/naturesaura/Helper.java +++ b/src/main/java/de/ellpeck/naturesaura/Helper.java @@ -102,12 +102,12 @@ public final class Helper { } public static ChunkAccess getLoadedChunk(LevelAccessor level, int x, int z) { - // thanks DrCat https://github.com/ldtteam/minecolonies/blob/version/1.18/src/api/java/com/minecolonies/api/util/WorldUtil.java#L66 + // as always, this code is EXTREMELY FRAGILE and editing it before the next major version will probably break it if (level.getChunkSource() instanceof ServerChunkCache cache) { - var future = cache.getChunkFuture(x, z, ChunkStatus.FULL, false); - return future.isDone() ? future.getNow(ChunkHolder.UNLOADED_CHUNK).left().orElse(null) : null; + return cache.isPositionTicking(ChunkPos.asLong(x, z)) ? cache.getChunk(x, z, ChunkStatus.FULL, false) : null; + } else { + return level.getChunk(x, z, ChunkStatus.FULL, false); } - return level.getChunk(x, z, ChunkStatus.FULL, false); } public static int blendColors(int c1, int c2, float ratio) {