Skip to content

Commit c4267b3

Browse files
authored
Send forget packet to avoid invisible chunk sections (#3005)
1 parent 2158981 commit c4267b3

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

worldedit-bukkit/adapters/adapter-1_21_3/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_21_3/PaperweightPlatformAdapter.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import net.minecraft.core.Holder;
2525
import net.minecraft.core.IdMap;
2626
import net.minecraft.core.Registry;
27+
import net.minecraft.network.protocol.game.ClientboundForgetLevelChunkPacket;
2728
import net.minecraft.network.protocol.game.ClientboundLevelChunkWithLightPacket;
2829
import net.minecraft.server.MinecraftServer;
2930
import net.minecraft.server.level.ChunkHolder;
@@ -335,7 +336,6 @@ public static void sendChunk(IntPair pair, ServerLevel nmsWorld, int chunkX, int
335336
if (chunkHolder == null) {
336337
return;
337338
}
338-
ChunkPos coordIntPair = new ChunkPos(chunkX, chunkZ);
339339
LevelChunk levelChunk;
340340
if (PaperLib.isPaper()) {
341341
// getChunkAtIfLoadedImmediately is paper only
@@ -353,6 +353,10 @@ public static void sendChunk(IntPair pair, ServerLevel nmsWorld, int chunkX, int
353353
}
354354
MinecraftServer.getServer().execute(() -> {
355355
try {
356+
ChunkPos pos = levelChunk.getPos();
357+
// NOTE: the ClientboundForgetLevelChunkPacket packet is required on 1.21.3
358+
// as the client won't update empty -> non-empty sections properly otherwise
359+
ClientboundForgetLevelChunkPacket forget = new ClientboundForgetLevelChunkPacket(pos);
356360
ClientboundLevelChunkWithLightPacket packet;
357361
if (PaperLib.isPaper()) {
358362
packet = new ClientboundLevelChunkWithLightPacket(
@@ -371,7 +375,10 @@ public static void sendChunk(IntPair pair, ServerLevel nmsWorld, int chunkX, int
371375
null
372376
);
373377
}
374-
nearbyPlayers(nmsWorld, coordIntPair).forEach(p -> p.connection.send(packet));
378+
nearbyPlayers(nmsWorld, pos).forEach(p -> {
379+
p.connection.send(forget);
380+
p.connection.send(packet);
381+
});
375382
} finally {
376383
NMSAdapter.endChunkPacketSend(nmsWorld.getWorld().getName(), pair, lockHolder);
377384
}

0 commit comments

Comments
 (0)