From 52a97308f84a6b77f2e57acc56207457759e053d Mon Sep 17 00:00:00 2001 From: MrIvanPlays Date: Sun, 9 Aug 2020 21:35:16 +0300 Subject: [PATCH 1/2] Optimize player loops around weather --- ...Optimize-player-loops-around-weather.patch | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 patches/server/0033-Optimize-player-loops-around-weather.patch diff --git a/patches/server/0033-Optimize-player-loops-around-weather.patch b/patches/server/0033-Optimize-player-loops-around-weather.patch new file mode 100644 index 00000000..b77b4cb5 --- /dev/null +++ b/patches/server/0033-Optimize-player-loops-around-weather.patch @@ -0,0 +1,39 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: MrIvanPlays +Date: Sun, 9 Aug 2020 21:33:37 +0300 +Subject: [PATCH] Optimize player loops around weather + + +diff --git a/src/main/java/net/minecraft/server/WorldServer.java b/src/main/java/net/minecraft/server/WorldServer.java +index 988ce5aab920e0660098941e4bc89f0128cef23d..2eb59319360592145172a1cfd2395bb548c3b780 100644 +--- a/src/main/java/net/minecraft/server/WorldServer.java ++++ b/src/main/java/net/minecraft/server/WorldServer.java +@@ -823,12 +823,17 @@ public class WorldServer extends World implements GeneratorAccessSeed { + this.server.getPlayerList().sendAll(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.i, this.thunderLevel)); + } + // */ +- for (int idx = 0; idx < this.players.size(); ++idx) { +- if (this.players.get(idx).world == this) { +- this.players.get(idx).tickWeather(); ++ // Yatopia start ++ for (EntityPlayer player : players) { ++ if (player.world == this) { ++ player.tickWeather(); ++ player.updateWeather(this.lastRainLevel, this.rainLevel, this.lastThunderLevel, this.thunderLevel); ++ if (flag != this.isRaining()) player.setPlayerWeather((!flag ? WeatherType.DOWNFALL : WeatherType.CLEAR), false); ++ // Origami end + } + } + ++ /* // Yatopia start - moved up + if (flag != this.isRaining()) { + // Only send weather packets to those affected + for (int idx = 0; idx < this.players.size(); ++idx) { +@@ -842,6 +847,7 @@ public class WorldServer extends World implements GeneratorAccessSeed { + this.players.get(idx).updateWeather(this.lastRainLevel, this.rainLevel, this.lastThunderLevel, this.thunderLevel); + } + } ++ */ // Yatopia end + // CraftBukkit end + + if (this.everyoneSleeping) { From 8c2374d01ac842071e4176721c1f7e3100468f83 Mon Sep 17 00:00:00 2001 From: MrIvanPlays Date: Sun, 9 Aug 2020 22:14:14 +0300 Subject: [PATCH 2/2] Fix mistake --- ...er.patch => 0032-Optimize-player-loops-around-weather.patch} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename patches/server/{0033-Optimize-player-loops-around-weather.patch => 0032-Optimize-player-loops-around-weather.patch} (98%) diff --git a/patches/server/0033-Optimize-player-loops-around-weather.patch b/patches/server/0032-Optimize-player-loops-around-weather.patch similarity index 98% rename from patches/server/0033-Optimize-player-loops-around-weather.patch rename to patches/server/0032-Optimize-player-loops-around-weather.patch index b77b4cb5..76f18e07 100644 --- a/patches/server/0033-Optimize-player-loops-around-weather.patch +++ b/patches/server/0032-Optimize-player-loops-around-weather.patch @@ -21,7 +21,7 @@ index 988ce5aab920e0660098941e4bc89f0128cef23d..2eb59319360592145172a1cfd2395bb5 + player.tickWeather(); + player.updateWeather(this.lastRainLevel, this.rainLevel, this.lastThunderLevel, this.thunderLevel); + if (flag != this.isRaining()) player.setPlayerWeather((!flag ? WeatherType.DOWNFALL : WeatherType.CLEAR), false); -+ // Origami end ++ // Yatopia end } }