Yatopia/patches/server/0050-Smarter-statistics-ticking.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

56 lines
2.8 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Mykyta Komarnytskyy <nkomarn@hotmail.com>
Date: Sat, 24 Oct 2020 21:03:53 -0500
Subject: [PATCH] Smarter statistics ticking
In vanilla, statistics that count time spent for an action (i.e. time played or sneak time) are incremented every tick. This is retarded. With this patch and a configured interval of 20, the statistics are only ticked every 20th tick and are incremented by 20 ticks at a time. This means a lot less ticking with the same accurate counting.
With an interval of 20, this patch saves roughly 3ms per tick on a server w/ 80 players online.
diff --git a/src/main/java/net/minecraft/server/EntityHuman.java b/src/main/java/net/minecraft/server/EntityHuman.java
index 6b09b5d10ba824d589ee998c19d347074ad81d17..0511d2a37a7cfc906f13df72e91ffed993639376 100644
--- a/src/main/java/net/minecraft/server/EntityHuman.java
+++ b/src/main/java/net/minecraft/server/EntityHuman.java
@@ -173,18 +173,23 @@ public abstract class EntityHuman extends EntityLiving {
this.p();
if (!this.world.isClientSide) {
this.foodData.a(this);
- this.a(StatisticList.PLAY_ONE_MINUTE);
+ // Yatopia start
+ int interval = org.yatopiamc.yatopia.server.YatopiaConfig.playerTimeStatisticsInterval;
+ if (ticksLived % interval == 0) {
+ this.a(StatisticList.PLAY_ONE_MINUTE, interval);
+ // Yatopia end
if (this.isAlive()) {
- this.a(StatisticList.TIME_SINCE_DEATH);
+ this.a(StatisticList.TIME_SINCE_DEATH, interval); // Yatopia
}
if (this.bx()) {
- this.a(StatisticList.SNEAK_TIME);
+ this.a(StatisticList.SNEAK_TIME, interval); // Yatopia
}
if (!this.isSleeping()) {
- this.a(StatisticList.TIME_SINCE_REST);
+ this.a(StatisticList.TIME_SINCE_REST, interval); // Yatopia
}
+ } // Yatopia
}
int i = 29999999;
diff --git a/src/main/java/org/yatopiamc/yatopia/server/YatopiaConfig.java b/src/main/java/org/yatopiamc/yatopia/server/YatopiaConfig.java
index 81ab5afa7bd397266d2afe77426d2e629529aa1a..045ace1444b4db8fa5fab09f970de7a696c56ab8 100644
--- a/src/main/java/org/yatopiamc/yatopia/server/YatopiaConfig.java
+++ b/src/main/java/org/yatopiamc/yatopia/server/YatopiaConfig.java
@@ -230,4 +230,9 @@ public class YatopiaConfig {
checkFlying = getBoolean("settings.checks.flight", checkFlying);
checkVehicleFlying = getBoolean("settings.checks.vehicle-flight", checkVehicleFlying);
}
+
+ public static int playerTimeStatisticsInterval = 1;
+ private static void intervals() {
+ playerTimeStatisticsInterval = Math.max(1, getInt("settings.intervals.player-time-statistics", 1));
+ }
}