Yatopia/patches/server/0024-Optimize-some-stuff-in-WorldServer-ticking.patch
Simon Gardling 679a88af3f
Upstream (#447)
* Updated Upstream and Sidestream(s) (Paper/Airplane/Purpur/Empirecraft)

Upstream/An Sidestream has released updates that appears to apply and compile correctly
This update has NOT been tested by YatopiaMC and as with ANY update, please do your own testing.

Paper Changes:
4b78c0b80 [CI-SKIP] [Auto] Rebuild Patches
2d9ff13eb forced whitelist: use configuable kick message (fixes #5417) (#5418)
000cec2ab bug #5432 - post modern event even if legacy event is cancelled
6c83bc6e5 Remove from Map by key
857852c28 Make sure to remove correct TE during TE tick
f7b4abb25 [Auto] Updated Upstream (Bukkit/CraftBukkit)

Airplane Changes:
9a4bd85 Remove Multithreaded Tracker
1068498 Updated Upstream (Tuinity)

Purpur Changes:
083a86e [ci-skip] Update for Toothpick changes
8b9b214 Updated Upstream (Paper & Tuinity)

Empirecraft Changes:
6b5cffc2 Updated Paper

* Updated Upstream and Sidestream(s) (Airplane/Purpur)

Upstream/An Sidestream has released updates that appears to apply and compile correctly
This update has NOT been tested by YatopiaMC and as with ANY update, please do your own testing.

Airplane Changes:
3ed988c Use AIR library for configuration parsing

Purpur Changes:
9631959 Add 5 sec TPS to GUI (#260)
2a0a5e6 [ci-skip] Bump Toothpick Kotlin version
02b3444 Add back multithreaded entity tracker
43b4a2f Updated Upstream (Paper & Airplane)

* update gradle from 6.8.2 to 6.8.3

* fix build (hopefully)

* Updated Upstream and Sidestream(s) (Paper)

Upstream/An Sidestream has released updates that appears to apply and compile correctly
This update has NOT been tested by YatopiaMC and as with ANY update, please do your own testing.

Paper Changes:
211f8e041 Prevent light queue overfill when no players are online

* well that was dumb

* FINALLY it works

* Updated Upstream and Sidestream(s) (Empirecraft)

Upstream/An Sidestream has released updates that appears to apply and compile correctly
This update has NOT been tested by YatopiaMC and as with ANY update, please do your own testing.

Empirecraft Changes:
018fcff7 Updated Paper
2021-04-03 15:49:43 -04:00

83 lines
4.3 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 some stuff in WorldServer ticking
Replaced some streams and some array lists with glue lists
diff --git a/src/main/java/net/minecraft/server/level/WorldServer.java b/src/main/java/net/minecraft/server/level/WorldServer.java
index 62d1ee6f091d1b80d6f96930d2edb91259e15ffa..c97d29ef4b6d64a641d72ad754dab18932d185d5 100644
--- a/src/main/java/net/minecraft/server/level/WorldServer.java
+++ b/src/main/java/net/minecraft/server/level/WorldServer.java
@@ -1005,12 +1005,21 @@ 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
+ boolean sleepyMatch = true;
+ 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);
+ }
+ if (sleepyMatch && !player.isSpectator() && !player.isDeeplySleeping() && !player.fauxSleeping) {
+ sleepyMatch = false;
}
+ // 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) {
@@ -1025,11 +1034,9 @@ public class WorldServer extends World implements GeneratorAccessSeed {
}
}
// CraftBukkit end
+ */ // Yatopia end
- if (this.purpurConfig.playersSkipNight && this.everyoneSleeping && this.players.stream().noneMatch((entityplayer) -> { // Purpur
- return !entityplayer.isSpectator() && !entityplayer.isDeeplySleeping() && !entityplayer.fauxSleeping && !(purpurConfig.idleTimeoutCountAsSleeping && entityplayer.isAfk()); // CraftBukkit // Purpur
- })) {
- // CraftBukkit start
+ if (this.purpurConfig.playersSkipNight && this.everyoneSleeping && sleepyMatch) { // Purpur // Yatopia
long l = this.worldData.getDayTime() + 24000L;
TimeSkipEvent event = new TimeSkipEvent(this.getWorld(), TimeSkipEvent.SkipReason.NIGHT_SKIP, (l - l % 24000L) - this.getDayTime());
if (this.getGameRules().getBoolean(GameRules.DO_DAYLIGHT_CYCLE)) {
@@ -1235,9 +1242,9 @@ public class WorldServer extends World implements GeneratorAccessSeed {
}
private void wakeupPlayers() {
- (this.players.stream().filter(EntityLiving::isSleeping).collect(Collectors.toList())).forEach((entityplayer) -> { // CraftBukkit - decompile error
+ for (EntityPlayer entityplayer : players) { if (entityplayer.isSleeping()) { // Yatopia
entityplayer.wakeup(false, false);
- });
+ }} // Yatopia
}
// Paper start - optimise random block ticking
@@ -2067,8 +2074,9 @@ public class WorldServer extends World implements GeneratorAccessSeed {
// Spigot start
if ( entity instanceof EntityHuman )
{
- this.getMinecraftServer().worldServer.values().stream().map( WorldServer::getWorldPersistentData ).forEach( (worldData) ->
+ for ( WorldServer worldServer : getMinecraftServer().worldServer.values() ) // Yatopia
{
+ WorldPersistentData worldData = worldServer.getWorldPersistentData(); // Yatopia
for (Object o : worldData.data.values() )
{
if ( o instanceof WorldMap )
@@ -2085,7 +2093,7 @@ public class WorldServer extends World implements GeneratorAccessSeed {
}
}
}
- } );
+ } // Yatopia
}
// Spigot end
// Spigot Start