Paper/patches/server/0830-Prevent-GameEvents-being-fired-from-unloaded-chunks.patch
Riley Park f17519338b
Expose server build information (#10729)
* Expose server build information

* squash patches

* final tweaks

---------

Co-authored-by: Jake Potrebic <jake.m.potrebic@gmail.com>
Co-authored-by: masmc05 <masmc05@gmail.com>
2024-05-15 17:06:59 -07:00

23 lines
1.1 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Shane Freeder <theboyetronic@gmail.com>
Date: Wed, 5 Apr 2023 20:15:47 +0100
Subject: [PATCH] Prevent GameEvents being fired from unloaded chunks
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
index 1e122d5b49aa7f6a626e781e53de53be18afc346..055fcf3d51852ca466c7189f36382e0b0d0d86d2 100644
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
@@ -1374,6 +1374,11 @@ public class ServerLevel extends Level implements WorldGenLevel {
@Override
public void gameEvent(Holder<GameEvent> event, Vec3 emitterPos, GameEvent.Context emitter) {
+ // Paper start - Prevent GameEvents being fired from unloaded chunks
+ if (this.getChunkIfLoadedImmediately((Mth.floor(emitterPos.x) >> 4), (Mth.floor(emitterPos.z) >> 4)) == null) {
+ return;
+ }
+ // Paper end - Prevent GameEvents being fired from unloaded chunks
this.gameEventDispatcher.post(event, emitterPos, emitter);
}