9
0
mirror of https://github.com/Winds-Studio/Leaf.git synced 2026-01-06 15:51:31 +00:00
Files
Leaf/leaf-server/minecraft-patches/features/0079-Measure-last-tick-time.patch
Dreeam f5b95a6716 Updated Upstream (Paper)
Upstream has released updates that appear to apply and compile correctly

Paper Changes:
PaperMC/Paper@b0da38c2 Repository details in RuntimeException for MavenLibraryResolver#addRepository (#12939)
PaperMC/Paper@1922be90 Update custom tags (#12183)
PaperMC/Paper@79cf1353 Ignore HopperInventorySearchEvent when it has no listeners (#13009)
PaperMC/Paper@ea014f7a feat: add stuckEntityPoiRetryDelay config (#12949)
PaperMC/Paper@a9e76749 Support for showNotification in PlayerRecipeDiscoverEvent (#12992)
PaperMC/Paper@5622c9dd Expose attribute sentiment (#12974)
PaperMC/Paper@42b653b1 Expose more argument types (#12665)
PaperMC/Paper@52d9a221 [ci/skip] Fix typo in Display javadoc (#13010)
PaperMC/Paper@614e9acf Improve APIs around riptide tridents (#12996)
PaperMC/Paper@51706e5a Fixed DyeItem sheep dye hunk
2025-08-25 15:52:00 -04:00

65 lines
3.5 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Martijn Muijsers <martijnmuijsers@live.nl>
Date: Sat, 26 Nov 2022 16:54:05 +0100
Subject: [PATCH] Measure last tick time
License: MIT (https://opensource.org/licenses/MIT)
Gale - https://galemc.org
This patch is based on the following patch:
"Add getLastTickMs api"
By: tr7zw <tr7zw@live.de>
As part of: YAPFA (https://github.com/tr7zw/YAPFA)
Licensed under: MIT (https://opensource.org/licenses/MIT)
* YAPFA copyright *
Copyright 2020 tr7zw
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/net/minecraft/server/MinecraftServer.java b/net/minecraft/server/MinecraftServer.java
index 94cd410cde9bb4d09c30bd31046184846ee3503d..e5a10873e2ee8e4f75861eee46dec16c701c086f 100644
--- a/net/minecraft/server/MinecraftServer.java
+++ b/net/minecraft/server/MinecraftServer.java
@@ -1141,6 +1141,11 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
private static final java.math.BigDecimal TPS_BASE = new java.math.BigDecimal(1E9).multiply(new java.math.BigDecimal(SAMPLE_INTERVAL));
// Paper end
+ // Gale start - YAPFA - last tick time
+ public static long lastTickProperTime;
+ public static long lastTickOversleepTime;
+ // Gale end - YAPFA - last tick time
+
protected void runServer() {
try {
if (!this.initServer()) {
@@ -1226,7 +1231,9 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
this.nextTickTimeNanos += l;
this.tickFrame.start();
+ long tickProperStart = System.nanoTime(); // Gale - YAPFA - last tick time
this.tickServer(flag ? () -> false : this::haveTime);
+ lastTickProperTime = (System.nanoTime() - tickProperStart) / 1_000_000L; // Gale - YAPFA - last tick time
// Paper start - rewrite chunk system
final Throwable crash = this.chunkSystemCrash;
if (crash != null) {
@@ -1355,11 +1362,13 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
protected void waitUntilNextTick() {
this.runAllTasks();
this.waitingForNextTick = true;
+ long tickOversleepStart = System.nanoTime(); // Gale - YAPFA - last tick time
try {
this.managedBlock(() -> !this.haveTime());
} finally {
this.waitingForNextTick = false;
+ lastTickOversleepTime = (System.nanoTime() - tickOversleepStart) / 1000000L; // Gale - YAPFA - last tick time
}
}