3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-12-14 18:40:10 +01:00
Paper/patches/server/0281-Server-Tick-Events.patch

32 Zeilen
1.7 KiB
Diff

2021-06-11 14:02:28 +02:00
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 0f1a7b649d398a875b57746530242e3ced595bfd..59bd596a140b4b389c5b73adaab94323759abfc2 100644
2021-06-11 14:02:28 +02:00
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
@@ -1481,6 +1481,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
2024-10-27 18:11:15 +01:00
}
}
2021-06-11 14:02:28 +02:00
2024-10-27 18:11:15 +01:00
+ new com.destroystokyo.paper.event.server.ServerTickStartEvent(this.tickCount+1).callEvent(); // Paper - Server Tick Events
2021-06-11 14:02:28 +02:00
++this.tickCount;
2023-12-05 23:21:44 +01:00
this.tickRateManager.tick();
2024-10-27 18:11:15 +01:00
this.tickChildren(shouldKeepTicking);
@@ -1497,6 +1498,11 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
2024-10-27 18:11:15 +01:00
ProfilerFiller gameprofilerfiller = Profiler.get();
this.runAllTasks(); // Paper - move runAllTasks() into full server tick (previously for timings)
+ // Paper start - Server Tick Events
2021-06-11 14:02:28 +02:00
+ 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 - Server Tick Events
2024-10-23 15:02:51 +02:00
gameprofilerfiller.push("tallying");
long k = Util.getNanos() - i;
int l = this.tickCount % 100;