mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-02 13:07:06 +01:00
34 lines
1.9 KiB
Diff
34 lines
1.9 KiB
Diff
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
|
|
index a82d550697ffd11c85542cade2950d8862e37c65..2c9d8a6fe5d67d2c7b347eb0fe99a9b284c0bfba 100644
|
|
--- a/src/main/java/net/minecraft/server/network/PlayerChunkSender.java
|
|
+++ b/src/main/java/net/minecraft/server/network/PlayerChunkSender.java
|
|
@@ -45,6 +45,11 @@ public class PlayerChunkSender {
|
|
public void dropChunk(ServerPlayer player, ChunkPos pos) {
|
|
if (!this.pendingChunks.remove(pos.toLong()) && player.isAlive()) {
|
|
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
|
|
}
|
|
|
|
}
|
|
@@ -77,6 +82,11 @@ public class PlayerChunkSender {
|
|
|
|
private static void sendChunk(ServerGamePacketListenerImpl handler, ServerLevel world, LevelChunk chunk) {
|
|
handler.send(new ClientboundLevelChunkWithLightPacket(chunk, world.getLightEngine(), (BitSet)null, (BitSet)null));
|
|
+ // Paper start
|
|
+ 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();
|
|
+ }
|
|
+ // Paper end
|
|
ChunkPos chunkPos = chunk.getPos();
|
|
DebugPackets.sendPoiPacketsForChunk(world, chunkPos);
|
|
}
|