--- a/net/minecraft/server/network/PlayerChunkSender.java
+++ b/net/minecraft/server/network/PlayerChunkSender.java
@@ -42,14 +42,27 @@
         this.pendingChunks.add(chunk.getPos().toLong());
     }
 
+    // Paper start - rewrite player chunk loader
+    public static void dropChunkStatic(ServerPlayer player, ChunkPos pos) {
+        player.serverLevel().chunkSource.chunkMap.getVisibleChunkIfPresent(pos.toLong()).removePlayer(player);
+        player.connection.send(new ClientboundForgetLevelChunkPacket(pos));
+        // Paper start
+        if (io.papermc.paper.event.packet.PlayerChunkUnloadEvent.getHandlerList().getRegisteredListeners().length > 0) {
+            new io.papermc.paper.event.packet.PlayerChunkUnloadEvent(player.getBukkitEntity().getWorld().getChunkAt(pos.longKey), player.getBukkitEntity()).callEvent();
+        }
+        // Paper end
+    }
+    // Paper end - rewrite player chunk loader
+
     public void dropChunk(ServerPlayer player, ChunkPos pos) {
         if (!this.pendingChunks.remove(pos.toLong()) && player.isAlive()) {
-            player.connection.send(new ClientboundForgetLevelChunkPacket(pos));
+           dropChunkStatic(player, pos); // Paper - rewrite player chunk loader - move into own method
         }
 
     }
 
     public void sendNextChunks(ServerPlayer player) {
+        if (true) return; // Paper - rewrite player chunk loader
         if (this.unacknowledgedBatches < this.maxUnacknowledgedBatches) {
             float f = Math.max(1.0F, this.desiredChunksPerTick);
             this.batchQuota = Math.min(this.batchQuota + this.desiredChunksPerTick, f);
@@ -75,8 +88,17 @@
         }
     }
 
-    private static void sendChunk(ServerGamePacketListenerImpl handler, ServerLevel world, LevelChunk chunk) {
-        handler.send(new ClientboundLevelChunkWithLightPacket(chunk, world.getLightEngine(), (BitSet)null, (BitSet)null));
+    public static void sendChunk(ServerGamePacketListenerImpl handler, ServerLevel world, LevelChunk chunk) { // Paper - rewrite chunk loader - public
+        handler.player.serverLevel().chunkSource.chunkMap.getVisibleChunkIfPresent(chunk.getPos().toLong()).addPlayer(handler.player);
+        // Paper start - Anti-Xray
+        final boolean shouldModify = world.chunkPacketBlockController.shouldModify(handler.player, chunk);
+        handler.send(new ClientboundLevelChunkWithLightPacket(chunk, world.getLightEngine(), (BitSet)null, (BitSet)null, shouldModify));
+        // Paper end - Anti-Xray
+        // Paper start - PlayerChunkLoadEvent
+        if (io.papermc.paper.event.packet.PlayerChunkLoadEvent.getHandlerList().getRegisteredListeners().length > 0) {
+            new io.papermc.paper.event.packet.PlayerChunkLoadEvent(new org.bukkit.craftbukkit.v1_20_R2.CraftChunk(chunk), handler.getPlayer().getBukkitEntity()).callEvent();
+        }
+        // Paper end - PlayerChunkLoadEvent
         ChunkPos chunkPos = chunk.getPos();
         DebugPackets.sendPoiPacketsForChunk(world, chunkPos);
     }
@@ -100,6 +122,7 @@
     }
 
     public void onChunkBatchReceivedByClient(float desiredBatchSize) {
+        if (true) return; // Paper - rewrite player chunk loader
         --this.unacknowledgedBatches;
         this.desiredChunksPerTick = Double.isNaN((double)desiredBatchSize) ? 0.01F : Mth.clamp(desiredBatchSize, 0.01F, 64.0F);
         if (this.unacknowledgedBatches == 0) {
