Yatopia/patches/server/0049-Configurable-BlockPhysicsEvent.patch
Simon Gardling cc91a8080f
Upstream (#461)
* Updated Upstream and Sidestream(s) (Paper)

Upstream/An Sidestream has released updates that appears to apply and compile correctly
This update has NOT been tested by YatopiaMC and as with ANY update, please do your own testing.

Paper Changes:
8a29f5894 [Auto] Updated Upstream (Bukkit/CraftBukkit)
8756d232c Expose server protocol version (#5416)

* Updated Upstream and Sidestream(s) (Tuinity/Purpur)

Upstream/An Sidestream has released updates that appears to apply and compile correctly
This update has NOT been tested by YatopiaMC and as with ANY update, please do your own testing.

Tuinity Changes:
32b4d52 Updated Upstream (Paper)
ac5adca Make sure lit is set for pre 1.14 chunks

Purpur Changes:
24d9e61 Piglin portal spawn modifier
5866f36 Fix #263 - NPE on TPSBar when player disconnects
7f7f024 Updated Upstream (Paper, Tuinity, & Airplane)

* bump kotlin-stdlib

* Updated Upstream and Sidestream(s) (Paper/Airplane/Purpur)

Upstream/An Sidestream has released updates that appears to apply and compile correctly
This update has NOT been tested by YatopiaMC and as with ANY update, please do your own testing.

Paper Changes:
606cdac60 Update the view distance before scheduling chunk loads (#5269)

Airplane Changes:
0789789 Updated Upstream (Tuinity)
c1e4d71 Fluid cache patch

Purpur Changes:
04f73c5 Fix error when using non living entity on monster egg
76c35fc Fix #287 - TPSBarTask NPE (again)

* Updated Upstream and Sidestream(s) (Purpur)

Upstream/An Sidestream has released updates that appears to apply and compile correctly
This update has NOT been tested by YatopiaMC and as with ANY update, please do your own testing.

Purpur Changes:
2e62618 Fix #280 - Ridables do not reset idle timer
2021-04-15 14:46:34 -04:00

36 lines
2.7 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Mykyta Komarnytskyy <nkomarn@hotmail.com>
Date: Sat, 24 Oct 2020 21:12:45 -0500
Subject: [PATCH] Configurable BlockPhysicsEvent
Bukkit's BlockPhysicsEvent is *ridiculously* spammy and can easily rack in 1,600 calls/sec on a server with just one player. This hogs a ton of CPU time.
Paper does alleviate this quite well by only firing if plugins are listening, but a lot of common world protection plugins use this event do not offer toggles for their listeners, which makes Paper's change ineffective for most servers.
This patch implements a hard toggle for the event.
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
index df1d8aa345518101320a4ec0636c34ebb872ff98..d90deadd51fe2fadbd972f029204bee92640663d 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
@@ -1536,7 +1536,7 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
while (iterator.hasNext()) {
WorldServer worldserver = (WorldServer) iterator.next();
- worldserver.hasPhysicsEvent = org.bukkit.event.block.BlockPhysicsEvent.getHandlerList().getRegisteredListeners().length > 0; // Paper
+ worldserver.hasPhysicsEvent = org.yatopiamc.yatopia.server.YatopiaConfig.fireBlockPhysicsEvent && org.bukkit.event.block.BlockPhysicsEvent.getHandlerList().getRegisteredListeners().length > 0; // Paper // Yatopia
worldserver.hasEntityMoveEvent = EntityMoveEvent.getHandlerList().getRegisteredListeners().length > 0; // Paper
worldserver.hasRidableMoveEvent = net.pl3x.purpur.event.entity.RidableMoveEvent.getHandlerList().getRegisteredListeners().length > 0; // Purpur
TileEntityHopper.skipHopperEvents = worldserver.paperConfig.disableHopperMoveEvents || org.bukkit.event.inventory.InventoryMoveItemEvent.getHandlerList().getRegisteredListeners().length == 0; // Paper
diff --git a/src/main/java/org/yatopiamc/yatopia/server/YatopiaConfig.java b/src/main/java/org/yatopiamc/yatopia/server/YatopiaConfig.java
index 2100ac9c1f4d0df75347579cc5d58255b77ec252..4d6410401457afe91457ae72df14bf687e9c62fd 100644
--- a/src/main/java/org/yatopiamc/yatopia/server/YatopiaConfig.java
+++ b/src/main/java/org/yatopiamc/yatopia/server/YatopiaConfig.java
@@ -245,4 +245,8 @@ public class YatopiaConfig {
criterionTriggerTick = getBoolean("settings.criterion-triggers.tick", true);
}
+ public static boolean fireBlockPhysicsEvent = true;
+ private static void fireBlockPhysicsEvent() {
+ fireBlockPhysicsEvent = getBoolean("settings.fire-block-physics-event", true);
+ }
}