Yatopia/patches/server/0028-Optimize-player-loops-around-weather.patch
Ivan Pekov 0a19056af0
Drop akarin's stream replacements
Fixes bad performance out of the box for production. 
Apparently there's another issue which is thinkering our minds up, it is that after certain amount of time the gc just can't keep up. We're investigating into this, but until it is fixed - this is gonna be a stable build 

Co-authored-by: Mykyta Komarn <nkomarn@hotmail.com>
2020-10-08 14:04:22 +03:00

40 lines
2.0 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: MrIvanPlays <ivan@mrivanplays.com>
Date: Sun, 9 Aug 2020 16:58:18 -0500
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 7c60ad59e7dbb2fd4089f762c9bbe1cb5f7b6054..274b7e04ff09e459cd63040b1c29e3d197aafe72 100644
--- a/src/main/java/net/minecraft/server/WorldServer.java
+++ b/src/main/java/net/minecraft/server/WorldServer.java
@@ -821,12 +821,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 (((EntityPlayer) this.players.get(idx)).world == this) {
- ((EntityPlayer) this.players.get(idx)).tickWeather();
+ // Yatopia start
+ for (EntityPlayer player : players) {
+ if (player.world == this) {
+ player.tickWeather();
+ if (flag != this.isRaining()) player.setPlayerWeather((!flag ? WeatherType.DOWNFALL : WeatherType.CLEAR), false);
+ player.updateWeather(this.lastRainLevel, this.rainLevel, this.lastThunderLevel, this.thunderLevel);
+ // Yatopia 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) {
@@ -841,6 +846,7 @@ public class WorldServer extends World implements GeneratorAccessSeed {
}
}
// CraftBukkit end
+ */ // Yatopia end
if (this.everyoneSleeping && this.players.stream().noneMatch((entityplayer) -> {
return !entityplayer.isSpectator() && !entityplayer.isDeeplySleeping() && !entityplayer.fauxSleeping; // CraftBukkit