mirror of
https://github.com/Dreeam-qwq/Gale.git
synced 2025-12-27 10:39:12 +00:00
124 lines
6.3 KiB
Diff
124 lines
6.3 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Martijn Muijsers <martijnmuijsers@live.nl>
|
|
Date: Wed, 30 Nov 2022 22:50:57 +0100
|
|
Subject: [PATCH] Increase time statistics in intervals
|
|
|
|
License: MIT (https://opensource.org/licenses/MIT)
|
|
Gale - https://galemc.org
|
|
|
|
This patch is based on the following patch:
|
|
"Smarter statistics ticking"
|
|
By: Mykyta Komarnytskyy <nkomarn@hotmail.com>
|
|
As part of: Hydrinity (https://github.com/duplexsystem/Hydrinity)
|
|
Licensed under: MIT (https://opensource.org/licenses/MIT)
|
|
|
|
* Hydrinity description *
|
|
|
|
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.
|
|
|
|
* Hydrinity copyright *
|
|
|
|
This patch was created for the Hydrinity project <https://github.com/Hydrinity/Hydrinity> by Mykyta Komarnytskyy <nkomarn@hotmail.com> under the MIT license.
|
|
|
|
MIT License
|
|
|
|
Copyright (c) 2020 Mykyta Komarnytskyy
|
|
|
|
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/src/main/java/net/minecraft/world/entity/player/Player.java b/src/main/java/net/minecraft/world/entity/player/Player.java
|
|
index 68247b9daf710c71f84e1fae9d91efed151d39aa..92b30f5293e80e078d8a1a740d22367ea36a71f1 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/player/Player.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/player/Player.java
|
|
@@ -114,6 +114,7 @@ import net.minecraft.world.phys.AABB;
|
|
import net.minecraft.world.phys.Vec3;
|
|
import net.minecraft.world.scores.PlayerTeam;
|
|
import net.minecraft.world.scores.Scoreboard;
|
|
+import org.galemc.gale.configuration.GaleGlobalConfiguration;
|
|
import org.slf4j.Logger;
|
|
import org.bukkit.craftbukkit.entity.CraftHumanEntity;
|
|
import org.bukkit.craftbukkit.event.CraftEventFactory;
|
|
@@ -281,19 +282,24 @@ public abstract class Player extends LivingEntity {
|
|
this.moveCloak();
|
|
if (!this.level.isClientSide) {
|
|
this.foodData.tick(this);
|
|
- this.awardStat(Stats.PLAY_TIME);
|
|
- this.awardStat(Stats.TOTAL_WORLD_TIME);
|
|
+ // Gale start - Hydrinity - increase time statistics in intervals
|
|
+ int interval = Math.max(1, GaleGlobalConfiguration.get().smallOptimizations.reducedIntervals.increaseTimeStatistics);
|
|
+ if (interval == 1 || this.tickCount % interval == 0) {
|
|
+ this.awardStat(Stats.PLAY_TIME, interval);
|
|
+ this.awardStat(Stats.TOTAL_WORLD_TIME, interval);
|
|
+ // Gale end - Hydrinity - increase time statistics in intervals
|
|
if (this.isAlive()) {
|
|
- this.awardStat(Stats.TIME_SINCE_DEATH);
|
|
+ this.awardStat(Stats.TIME_SINCE_DEATH, interval); // Gale - Hydrinity - increase time statistics in intervals
|
|
}
|
|
|
|
if (this.isDiscrete()) {
|
|
- this.awardStat(Stats.CROUCH_TIME);
|
|
+ this.awardStat(Stats.CROUCH_TIME, interval); // Gale - Hydrinity - increase time statistics in intervals
|
|
}
|
|
|
|
if (!this.isSleeping()) {
|
|
- this.awardStat(Stats.TIME_SINCE_REST);
|
|
+ this.awardStat(Stats.TIME_SINCE_REST, interval); // Gale - Hydrinity - increase time statistics in intervals
|
|
}
|
|
+ } // Gale - Hydrinity - increase time statistics in intervals
|
|
}
|
|
|
|
int i = 29999999;
|
|
diff --git a/src/main/java/org/galemc/gale/configuration/GaleGlobalConfiguration.java b/src/main/java/org/galemc/gale/configuration/GaleGlobalConfiguration.java
|
|
index 77adb09c2cffc153b3cc210441aa8e6cdb98482b..b3abe36458699b32ecfcf9cf8685ad9479cb75e2 100644
|
|
--- a/src/main/java/org/galemc/gale/configuration/GaleGlobalConfiguration.java
|
|
+++ b/src/main/java/org/galemc/gale/configuration/GaleGlobalConfiguration.java
|
|
@@ -27,7 +27,29 @@ public class GaleGlobalConfiguration extends ConfigurationPart {
|
|
public SmallOptimizations smallOptimizations;
|
|
public class SmallOptimizations extends ConfigurationPart {
|
|
|
|
- public int dummyValue = 0;
|
|
+ public ReducedIntervals reducedIntervals;
|
|
+ public class ReducedIntervals extends ConfigurationPart {
|
|
+
|
|
+ // Gale start - Hydrinity - increase time statistics in intervals
|
|
+ /**
|
|
+ * The interval at which to increase the time-related statistics such as total playtime, time since
|
|
+ * the last death, etc.
|
|
+ * For example:
|
|
+ * <ul>
|
|
+ * <li>If this value is set to 20, the total playtime in ticks will be increased by 20 every second.</li>
|
|
+ * <li>If this value is set to 100, the total playtime in ticks will be increased by 100 every 5 seconds.</li>
|
|
+ * </ul>
|
|
+ * Given in ticks.
|
|
+ * Any value <= 0 behaves like 1.
|
|
+ * <ul>
|
|
+ * <li><i>Default</i>: 100 (5 seconds)</li>
|
|
+ * <li><i>Vanilla</i>: 1</li>
|
|
+ * </ul>
|
|
+ */
|
|
+ public int increaseTimeStatistics = 100;
|
|
+ // Gale end - Hydrinity - increase time statistics in intervals
|
|
+
|
|
+ }
|
|
|
|
// Gale start - Pufferfish - SIMD support
|
|
public Simd simd;
|