Paper/Spigot-Server-Patches/0391-Optimize-World-Time-Updates.patch
Shane Freeder ea855e2b46 Updated Upstream (Bukkit/CraftBukkit/Spigot)
Upstream has released updates that appears to apply and compile correctly.
This update has not been tested by PaperMC and as with ANY update, please do your own testing

Developers!: You will need to clean up your work/Minecraft/1.13.2 folder
for this

Also, restore a patch that was dropped in the last upstream

Bukkit Changes:
279eeab3 Fix command description not being set
96e2bb18 Remove debug print from SyntheticEventTest

CraftBukkit Changes:
d3ed1516 Fix dangerously threaded beacons
217a293d Don't relocate joptsimple to allow --help to work.
1be05a21 Prepare for imminent Java 12 release
a49270b2 Mappings Update
5259d80c SPIGOT-4669: Fix PlayerTeleportEvent coordinates for relative teleports

Spigot Changes:
e6eb36f2 Rebuild patches
2019-03-20 01:55:16 +00:00

46 lines
2.6 KiB
Diff

From 354a84e86917aacb348049818f5a2bacb3f4caf7 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
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 236fbafeb..ce39ea09e 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
@@ -1033,12 +1033,24 @@ public abstract class MinecraftServer implements IAsyncTaskHandler, IMojangStati
MinecraftTimings.timeUpdateTimer.startTiming(); // Spigot
// Send time updates to everyone, it will get the right time from the world the player is in.
- if (this.ticks % 20 == 0) {
- for (int i = 0; i < this.getPlayerList().players.size(); ++i) {
- EntityPlayer entityplayer = (EntityPlayer) this.getPlayerList().players.get(i);
- entityplayer.playerConnection.sendPacket(new PacketPlayOutUpdateTime(entityplayer.world.getTime(), entityplayer.getPlayerTime(), entityplayer.world.getGameRules().getBoolean("doDaylightCycle"))); // Add support for per player time
+ // Paper start - optimize time updates
+ for (final WorldServer world : this.getWorlds()) {
+ final boolean doDaylight = world.getGameRules().getBoolean("doDaylightCycle");
+ final long dayTime = world.getDayTime();
+ long worldTime = world.getTime();
+ final PacketPlayOutUpdateTime worldPacket = new PacketPlayOutUpdateTime(worldTime, dayTime, doDaylight);
+ for (EntityHuman entityhuman : world.players) {
+ if (!(entityhuman instanceof EntityPlayer) || (ticks + entityhuman.getId()) % 20 != 0) {
+ continue;
+ }
+ EntityPlayer entityplayer = (EntityPlayer) entityhuman;
+ long playerTime = entityplayer.getPlayerTime();
+ PacketPlayOutUpdateTime packet = (playerTime == dayTime) ? worldPacket :
+ new PacketPlayOutUpdateTime(worldTime, playerTime, doDaylight);
+ entityplayer.playerConnection.sendPacket(packet); // Add support for per player time
}
}
+ // Paper end
MinecraftTimings.timeUpdateTimer.stopTiming(); // Spigot
// WorldServer worldserver; // CraftBukkit - dropped down
--
2.21.0