Yatopia/patches/server/0052-Configurable-BlockPhysicsEvent.patch
Simon Gardling 021f928c4d
Updated Upstream and Sidestream(s) (Paper/Purpur/AirplaneLite/Origami) (#382)
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:
0514fc4e2 Add missing effects
8f5d9effd Add getMainThreadExecutor to BukkitScheduler
313b5020b Allow adding items to BlockDropItemEvent (#5093)
9a556d9da [CI-SKIP] [Auto] Rebuild Patches
72b2768ad Inline shift fields in EnumDirection (#5082)
ffff53fa7 added option to disable pathfinding updates on block changes (#5123)
b67081fd7 add DragonEggFormEvent (fixes #5110) (#5112)
3eefafbaf Fix javadoc build
0081ed1c4 Add javadoc step to GH Actions
01082503e Add dropLeash variable to EntityUnleashEvent (#5130)
31f9f869a [CI-SKIP] Fix YourKit links in readme, fixes #5091
8ac27aa38 [Auto] Updated Upstream (CraftBukkit)
c4d9cc831 [Auto] Updated Upstream (Bukkit/CraftBukkit)
d0477d326 [Auto] Updated Upstream (CraftBukkit)
d9f5f7018 EntityMoveEvent (#4614)

Purpur Changes:
e581a73 Updated Upstream (Paper)

AirplaneLite Changes:
10c5810 Updated Upstream (Tuinity)

Origami Changes:
45d89cc Update Paper
578ef16 Automatically disable online-mode if bungeecord is enabled
de51baa Update Paper
5986aef Import Purpur patch to not send useless entity packets
2021-02-02 10:17:46 -05: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 2d6f650c98a8254c722eb851d73b42d7066c8f17..052d02824acb69fbba17ca605afe576b9977820e 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
@@ -1418,7 +1418,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);
+ }
}