aboutsummaryrefslogtreecommitdiffhomepage
path: root/patches/server/0263-Optimize-World-Time-Updates.patch
diff options
context:
space:
mode:
authorSpottedleaf <[email protected]>2024-07-17 10:24:53 -0700
committerSpottedleaf <[email protected]>2024-07-17 10:28:32 -0700
commit00b949f1bbbf444e2b5e7b8de7c9b14fbd2133c6 (patch)
tree82639515bc5e9ae00c1e639e72137ed51e1ac688 /patches/server/0263-Optimize-World-Time-Updates.patch
parent967f98aa81da851740aeb429778e46159fd188df (diff)
downloadPaper-00b949f1bbbf444e2b5e7b8de7c9b14fbd2133c6.tar.gz
Paper-00b949f1bbbf444e2b5e7b8de7c9b14fbd2133c6.zip
Remove Moonrise utils to MCUtils, remove duplicated/unused utils
Diffstat (limited to 'patches/server/0263-Optimize-World-Time-Updates.patch')
-rw-r--r--patches/server/0263-Optimize-World-Time-Updates.patch42
1 files changed, 42 insertions, 0 deletions
diff --git a/patches/server/0263-Optimize-World-Time-Updates.patch b/patches/server/0263-Optimize-World-Time-Updates.patch
new file mode 100644
index 0000000000..1ce97af599
--- /dev/null
+++ b/patches/server/0263-Optimize-World-Time-Updates.patch
@@ -0,0 +1,42 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Aikar <[email protected]>
+Date: Fri, 2 Nov 2018 23:11:51 -0400
+Subject: [PATCH] Optimize World Time Updates
+
+Splits time updates into incremental updates as well as does
+the updates per world, so that we can re-use the same packet
+object for every player unless they have per-player time enabled.
+
+diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
+index 995ee6b2af01a14d61a031008dd05518668a98ae..0b266d3855723752d7789340f5d98ea106a97722 100644
+--- a/src/main/java/net/minecraft/server/MinecraftServer.java
++++ b/src/main/java/net/minecraft/server/MinecraftServer.java
+@@ -1562,12 +1562,24 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
+
+ MinecraftTimings.timeUpdateTimer.startTiming(); // Spigot // Paper
+ // Send time updates to everyone, it will get the right time from the world the player is in.
+- if (this.tickCount % 20 == 0) {
+- for (int i = 0; i < this.getPlayerList().players.size(); ++i) {
+- ServerPlayer entityplayer = (ServerPlayer) this.getPlayerList().players.get(i);
+- entityplayer.connection.send(new ClientboundSetTimePacket(entityplayer.level().getGameTime(), entityplayer.getPlayerTime(), entityplayer.level().getGameRules().getBoolean(GameRules.RULE_DAYLIGHT))); // Add support for per player time
++ // Paper start - Perf: Optimize time updates
++ for (final ServerLevel level : this.getAllLevels()) {
++ final boolean doDaylight = level.getGameRules().getBoolean(GameRules.RULE_DAYLIGHT);
++ final long dayTime = level.getDayTime();
++ long worldTime = level.getGameTime();
++ final ClientboundSetTimePacket worldPacket = new ClientboundSetTimePacket(worldTime, dayTime, doDaylight);
++ for (Player entityhuman : level.players()) {
++ if (!(entityhuman instanceof ServerPlayer) || (tickCount + entityhuman.getId()) % 20 != 0) {
++ continue;
++ }
++ ServerPlayer entityplayer = (ServerPlayer) entityhuman;
++ long playerTime = entityplayer.getPlayerTime();
++ ClientboundSetTimePacket packet = (playerTime == dayTime) ? worldPacket :
++ new ClientboundSetTimePacket(worldTime, playerTime, doDaylight);
++ entityplayer.connection.send(packet); // Add support for per player time
+ }
+ }
++ // Paper end - Perf: Optimize time updates
+ MinecraftTimings.timeUpdateTimer.stopTiming(); // Spigot // Paper
+
+ while (iterator.hasNext()) {