Skip to content

Commit

Permalink
chore: remove forget packet
Browse files Browse the repository at this point in the history
  • Loading branch information
PierreSchwang committed Dec 15, 2024
1 parent b634274 commit bc40f72
Showing 1 changed file with 9 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -150,10 +150,12 @@ public final class PaperweightPlatformAdapter extends NMSAdapter {
fieldBiomes = tmpFieldBiomes;
fieldBiomes.setAccessible(true);

Method getVisibleChunkIfPresent = ChunkMap.class.getDeclaredMethod(Refraction.pickName(
"getVisibleChunkIfPresent",
"b"
), long.class);
Method getVisibleChunkIfPresent = ChunkMap.class.getDeclaredMethod(
Refraction.pickName(
"getVisibleChunkIfPresent",
"b"
), long.class
);
getVisibleChunkIfPresent.setAccessible(true);
methodGetVisibleChunk = lookup.unreflect(getVisibleChunkIfPresent);

Expand Down Expand Up @@ -354,14 +356,11 @@ public static void sendChunk(IntPair pair, ServerLevel nmsWorld, int chunkX, int
MinecraftServer.getServer().execute(() -> {
try {
ChunkPos pos = levelChunk.getPos();
// NOTE: the ClientboundForgetLevelChunkPacket packet is required on 1.21.3
// as the client won't update empty -> non-empty sections properly otherwise
ClientboundForgetLevelChunkPacket forget = new ClientboundForgetLevelChunkPacket(pos);
ClientboundLevelChunkWithLightPacket packet;
if (PaperLib.isPaper()) {
packet = new ClientboundLevelChunkWithLightPacket(
levelChunk,
nmsWorld.getChunkSource().getLightEngine(),
nmsWorld.getLightEngine(),
null,
null,
false // last false is to not bother with x-ray
Expand All @@ -370,15 +369,12 @@ public static void sendChunk(IntPair pair, ServerLevel nmsWorld, int chunkX, int
// deprecated on paper - deprecation suppressed
packet = new ClientboundLevelChunkWithLightPacket(
levelChunk,
nmsWorld.getChunkSource().getLightEngine(),
nmsWorld.getLightEngine(),
null,
null
);
}
nearbyPlayers(nmsWorld, pos).forEach(p -> {
p.connection.send(forget);
p.connection.send(packet);
});
nearbyPlayers(nmsWorld, pos).forEach(p -> p.connection.send(packet));
} finally {
NMSAdapter.endChunkPacketSend(nmsWorld.getWorld().getName(), pair, lockHolder);
}
Expand Down

0 comments on commit bc40f72

Please sign in to comment.