Paper/patches/server/0320-Server-Tick-Events.patch
Shane Freeder cfa5b37fa8
Updated Upstream (CraftBukkit)
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

CraftBukkit Changes:
03b725233 SPIGOT-6823: Fix loading custom world in combination with superflat
359d0533a #970: Correct typo in README.md
110492932 Fix per-world worldborder command
2021-12-03 00:26:54 +00:00

32 lines
1.5 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Wed, 27 Mar 2019 22:48:45 -0400
Subject: [PATCH] Server Tick Events
Fires event at start and end of a server tick
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
index 0c899c5f2d896d32aed7d165773ff2cd4a78f112..bc9937642a46ecd766a45ccb037de993dafa3608 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
@@ -1319,6 +1319,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
});
isOversleep = false;MinecraftTimings.serverOversleep.stopTiming();
// Paper end
+ new com.destroystokyo.paper.event.server.ServerTickStartEvent(this.tickCount+1).callEvent(); // Paper
++this.tickCount;
this.tickChildren(shouldKeepTicking);
@@ -1357,6 +1358,11 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
this.runAllTasks();
}
// Paper end
+ // Paper start
+ long endTime = System.nanoTime();
+ long remaining = (TICK_TIME - (endTime - lastTick)) - catchupTime;
+ new com.destroystokyo.paper.event.server.ServerTickEndEvent(this.tickCount, ((double)(endTime - lastTick) / 1000000D), remaining).callEvent();
+ // Paper end
this.profiler.push("tallying");
long l = this.tickTimes[this.tickCount % 100] = Util.getNanos() - i;