2023-09-22 22:13:57 +02:00
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: ysl3000 <yannicklamprecht@live.de>
Date: Mon, 5 Oct 2020 21:25:16 +0200
Subject: [PATCH] Player Chunk Load/Unload Events
diff --git a/src/main/java/net/minecraft/server/network/PlayerChunkSender.java b/src/main/java/net/minecraft/server/network/PlayerChunkSender.java
2024-01-20 12:50:16 +01:00
index 19b3f4fa7678a038bf25efc2a8b46ddad0193fde..fb1863d235a61ec977e8ad87a289d935a9c5d0e4 100644
2023-09-22 22:13:57 +02:00
--- a/src/main/java/net/minecraft/server/network/PlayerChunkSender.java
+++ b/src/main/java/net/minecraft/server/network/PlayerChunkSender.java
2023-09-23 02:07:02 +02:00
@@ -46,6 +46,11 @@ public class PlayerChunkSender {
2023-09-22 22:13:57 +02:00
public static void dropChunkStatic(ServerPlayer player, ChunkPos pos) {
2023-09-23 02:07:02 +02:00
player.serverLevel().chunkSource.chunkMap.getVisibleChunkIfPresent(pos.toLong()).removePlayer(player);
2023-09-22 22:13:57 +02:00
player.connection.send(new ClientboundForgetLevelChunkPacket(pos));
2024-01-20 12:50:16 +01:00
+ // Paper start - PlayerChunkUnloadEvent
2023-09-22 22:13:57 +02:00
+ 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();
+ }
2024-01-20 12:50:16 +01:00
+ // Paper end - PlayerChunkUnloadEvent
2023-09-22 22:13:57 +02:00
}
// Paper end - rewrite player chunk loader
2023-09-24 04:35:16 +02:00
@@ -89,6 +94,11 @@ public class PlayerChunkSender {
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
2023-09-22 22:13:57 +02:00
+ if (io.papermc.paper.event.packet.PlayerChunkLoadEvent.getHandlerList().getRegisteredListeners().length > 0) {
+ new io.papermc.paper.event.packet.PlayerChunkLoadEvent(new org.bukkit.craftbukkit.CraftChunk(chunk), handler.getPlayer().getBukkitEntity()).callEvent();
+ }
2023-09-24 04:35:16 +02:00
+ // Paper end - PlayerChunkLoadEvent
2023-09-22 22:13:57 +02:00
ChunkPos chunkPos = chunk.getPos();
DebugPackets.sendPoiPacketsForChunk(world, chunkPos);
}