Yatopia/patches/server/0026-Optimize-some-stuff-in-WorldServer-ticking.patch
Ivan Pekov 784079fc31
optimizations (#297)
* Drop useless stuff

* Faster Random

* TE opts

* Patches.md

* More Faster Random

* Fix Build

* More Opts

* AirplaneLite

* Update README.md

removed TIC-TACS and adding AirplaneLite

* Add AirplaneLite to the update script

* Rebuild patches

* Make enchanting table ticking configurable

* AirplaneLite to commitUpstream.sh

* Use FastRandom on more places

Co-authored-by: Bud Gidiere <sgidiere@gmail.com>
Co-authored-by: Simon Gardling <Titaniumtown@gmail.com>
2020-11-30 20:08:41 -06:00

82 lines
4.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 some stuff in WorldServer ticking
Replaced some streams and some array lists with glue lists
diff --git a/src/main/java/net/minecraft/server/WorldServer.java b/src/main/java/net/minecraft/server/WorldServer.java
index 79142c74bd5c9751a0c5f2f326cdf8adf8d61301..b3385a1522c82998420efcf0d27ecb87da76d039 100644
--- a/src/main/java/net/minecraft/server/WorldServer.java
+++ b/src/main/java/net/minecraft/server/WorldServer.java
@@ -960,12 +960,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) {
@@ -980,10 +989,9 @@ 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
- })) {
+ if (this.everyoneSleeping && sleepyMatch) { // Yatopia
// CraftBukkit start
long l = this.worldData.getDayTime() + 24000L;
TimeSkipEvent event = new TimeSkipEvent(this.getWorld(), TimeSkipEvent.SkipReason.NIGHT_SKIP, (l - l % 24000L) - this.getDayTime());
@@ -1153,9 +1161,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
@@ -1918,8 +1926,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 )
@@ -1936,7 +1945,7 @@ public class WorldServer extends World implements GeneratorAccessSeed {
}
}
}
- } );
+ } // Yatopia
}
// Spigot end
// Spigot Start