Paper/Spigot-Server-Patches/0615-Player-Chunk-Load-Unload-Events.patch
Jake Potrebic cb896d4710
Updated Upstream (Bukkit/CraftBukkit/Spigot) (#5643)
Upstream has released updates that appear to apply and compile correctly.
This update has not been tested by PaperMC and as with ANY update, please do your own testing

Bukkit Changes:
146a7e4b SPIGOT-5345: Add automatic library support

CraftBukkit Changes:
b1064c69 Remove sisu annotation processor from jar
32e40866 SPIGOT-6189: Persistent data disappears when calling setFacingDirection on an item frame
d189f78b # 827: Trigger vanilla dimension advancements in non-main worlds
5bbb4a65 Add plumbing for automatic library support

Spigot Changes:
9fb885e8 Rebuild patches
2021-05-15 22:52:07 +00:00

42 lines
2.1 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/level/EntityPlayer.java b/src/main/java/net/minecraft/server/level/EntityPlayer.java
index 78fcb90c86700ee6feef0d40753fc8d8a943777f..c0446ed3c7cc24fae2880dfba71228f5edee66d6 100644
--- a/src/main/java/net/minecraft/server/level/EntityPlayer.java
+++ b/src/main/java/net/minecraft/server/level/EntityPlayer.java
@@ -139,6 +139,8 @@ import net.minecraft.world.scores.ScoreboardScore;
import net.minecraft.world.scores.ScoreboardTeam;
import net.minecraft.world.scores.ScoreboardTeamBase;
import net.minecraft.world.scores.criteria.IScoreboardCriteria;
+import io.papermc.paper.event.packet.PlayerChunkLoadEvent; // Paper
+import io.papermc.paper.event.packet.PlayerChunkUnloadEvent; // Paper
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@@ -2098,11 +2100,21 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
public void a(ChunkCoordIntPair chunkcoordintpair, Packet<?> packet, Packet<?> packet1) {
this.playerConnection.sendPacket(packet1);
this.playerConnection.sendPacket(packet);
+ // Paper start
+ if(PlayerChunkLoadEvent.getHandlerList().getRegisteredListeners().length > 0){
+ new PlayerChunkLoadEvent(this.getBukkitEntity().getWorld().getChunkAt(chunkcoordintpair.longKey), this.getBukkitEntity()).callEvent();
+ }
+ // Paper end
}
public void a(ChunkCoordIntPair chunkcoordintpair) {
if (this.isAlive()) {
this.playerConnection.sendPacket(new PacketPlayOutUnloadChunk(chunkcoordintpair.x, chunkcoordintpair.z));
+ // Paper start
+ if(PlayerChunkUnloadEvent.getHandlerList().getRegisteredListeners().length > 0){
+ new PlayerChunkUnloadEvent(this.getBukkitEntity().getWorld().getChunkAt(chunkcoordintpair.longKey), this.getBukkitEntity()).callEvent();
+ }
+ // Paper end
}
}