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-04-24 15:46:45 +02:00
index 3548be0bfacc7ff2cf0ed5fac4d8de09bd2a415f..c502d9b85eb68b277ae17dfea34e0475f0156647 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
2024-04-12 21:14:06 +02:00
@@ -44,6 +44,11 @@ public class PlayerChunkSender {
2024-01-24 15:57:53 +01:00
public void dropChunk(ServerPlayer player, ChunkPos pos) {
if (!this.pendingChunks.remove(pos.toLong()) && player.isAlive()) {
player.connection.send(new ClientboundForgetLevelChunkPacket(pos));
+ // Paper start - PlayerChunkUnloadEvent
+ 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 - PlayerChunkUnloadEvent
}
2023-09-22 22:13:57 +02:00
}
2024-04-12 21:14:06 +02:00
@@ -75,6 +80,11 @@ public class PlayerChunkSender {
2023-09-22 22:13:57 +02:00
2024-01-24 15:57:53 +01:00
private static void sendChunk(ServerGamePacketListenerImpl handler, ServerLevel world, LevelChunk chunk) {
2024-04-12 21:14:06 +02:00
handler.send(new ClientboundLevelChunkWithLightPacket(chunk, world.getLightEngine(), null, null));
2023-09-24 04:35:16 +02:00
+ // 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);
}