mirror of
https://github.com/YatopiaMC/Yatopia.git
synced 2025-02-18 13:21:31 +01:00
56 lines
2.9 KiB
Diff
56 lines
2.9 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/world/entity/player/EntityHuman.java b/src/main/java/net/minecraft/world/entity/player/EntityHuman.java
|
|
index 587eb3a9fd8a155fcb8acc6c5850cfa4de77d626..8e6fd7ed9d79e61b8b82b853bf0017057ff74269 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/player/EntityHuman.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/player/EntityHuman.java
|
|
@@ -266,18 +266,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 90760a81f2d66082d4603df430f931403e5989b4..db1f0c57adbe2aacba9422820cf1a8757ea9ad4f 100644
|
|
--- a/src/main/java/org/yatopiamc/yatopia/server/YatopiaConfig.java
|
|
+++ b/src/main/java/org/yatopiamc/yatopia/server/YatopiaConfig.java
|
|
@@ -225,4 +225,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));
|
|
+ }
|
|
}
|