mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-01 05:47:45 +01:00
Player Chunk Load/Unload Events
This commit is contained in:
parent
b22a956d7c
commit
e32901791b
@ -0,0 +1,26 @@
|
||||
--- a/net/minecraft/server/network/PlayerChunkSender.java
|
||||
+++ b/net/minecraft/server/network/PlayerChunkSender.java
|
||||
@@ -44,6 +44,11 @@
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
@@ -75,6 +80,11 @@
|
||||
|
||||
private static void sendChunk(ServerGamePacketListenerImpl handler, ServerLevel world, LevelChunk chunk) {
|
||||
handler.send(new ClientboundLevelChunkWithLightPacket(chunk, world.getLightEngine(), null, null));
|
||||
+ // 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.CraftChunk(chunk), handler.getPlayer().getBukkitEntity()).callEvent();
|
||||
+ }
|
||||
+ // Paper end - PlayerChunkLoadEvent
|
||||
ChunkPos chunkPos = chunk.getPos();
|
||||
DebugPackets.sendPoiPacketsForChunk(world, chunkPos);
|
||||
}
|
Loading…
Reference in New Issue
Block a user