From 7c0d056637abcd7758ecb07ff759e24cdd85478c Mon Sep 17 00:00:00 2001 From: XiaoMoMi Date: Wed, 7 May 2025 02:02:26 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BD=BF=E7=94=A8=E7=BA=BF=E7=A8=8B=E5=AE=89?= =?UTF-8?q?=E5=85=A8=E7=9A=84=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../worldedit/FastAsyncWorldEditDelegate.java | 25 ++++++++++--------- gradle.properties | 2 +- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/bukkit/compatibility/src/main/java/net/momirealms/craftengine/bukkit/compatibility/worldedit/FastAsyncWorldEditDelegate.java b/bukkit/compatibility/src/main/java/net/momirealms/craftengine/bukkit/compatibility/worldedit/FastAsyncWorldEditDelegate.java index e464eb263..901a741ae 100644 --- a/bukkit/compatibility/src/main/java/net/momirealms/craftengine/bukkit/compatibility/worldedit/FastAsyncWorldEditDelegate.java +++ b/bukkit/compatibility/src/main/java/net/momirealms/craftengine/bukkit/compatibility/worldedit/FastAsyncWorldEditDelegate.java @@ -76,18 +76,17 @@ public class FastAsyncWorldEditDelegate extends AbstractDelegateExtent { }); } - private static void injectLevelChunk(CEChunk ceChunk) { + private static void injectLevelChunk(Object chunkSource, CEChunk ceChunk) { ChunkPos pos = ceChunk.chunkPos(); - CESection[] ceSections = ceChunk.sections(); - Object worldServer = ceChunk.world().world().serverWorld(); - Object chunkSource = FastNMS.INSTANCE.method$ServerLevel$getChunkSource(worldServer); - // TODO THREAD SAFETY? - Object levelChunk = FastNMS.INSTANCE.method$ServerChunkCache$getChunkAtIfLoadedMainThread(chunkSource, pos.x, pos.z); - Object[] sections = FastNMS.INSTANCE.method$ChunkAccess$getSections(levelChunk); - for (int i = 0; i < ceSections.length; i++) { - CESection ceSection = ceSections[i]; - Object section = sections[i]; - BukkitInjector.injectLevelChunkSection(section, ceSection, ceChunk, new SectionPos(pos.x, ceChunk.sectionY(i), pos.z)); + Object levelChunk = FastNMS.INSTANCE.method$ServerChunkCache$getChunk(chunkSource, pos.x, pos.z, false); + if (levelChunk != null) { + Object[] sections = FastNMS.INSTANCE.method$ChunkAccess$getSections(levelChunk); + CESection[] ceSections = ceChunk.sections(); + for (int i = 0; i < ceSections.length; i++) { + CESection ceSection = ceSections[i]; + Object section = sections[i]; + BukkitInjector.injectLevelChunkSection(section, ceSection, ceChunk, new SectionPos(pos.x, ceChunk.sectionY(i), pos.z)); + } } } @@ -146,11 +145,13 @@ public class FastAsyncWorldEditDelegate extends AbstractDelegateExtent { saveAllChunks(); List chunks = new ArrayList<>(BROKEN_CHUNKS); BROKEN_CHUNKS.clear(); + Object worldServer = this.ceWorld.world().serverWorld(); + Object chunkSource = FastNMS.INSTANCE.method$ServerLevel$getChunkSource(worldServer); for (ChunkPos chunk : chunks) { CEChunk loaded = this.ceWorld.getChunkAtIfLoaded(chunk.longKey()); // only inject loaded chunks if (loaded == null) continue; - injectLevelChunk(loaded); + injectLevelChunk(chunkSource, loaded); } return super.commitBefore(); } diff --git a/gradle.properties b/gradle.properties index 749c4cce7..980c2704a 100644 --- a/gradle.properties +++ b/gradle.properties @@ -50,7 +50,7 @@ byte_buddy_version=1.17.5 ahocorasick_version=0.6.3 snake_yaml_version=2.4 anti_grief_version=0.15 -nms_helper_version=0.64.5 +nms_helper_version=0.64.6 evalex_version=3.5.0 reactive_streams_version=1.0.4 amazon_awssdk_version=2.31.23