Yatopia/patches/server/0024-Optimize-some-stuff-in-WorldServer-ticking.patch
Simon Gardling c1a03b89af
Upstream (#469)
* Updated Upstream and Sidestream(s) (Paper/Tuinity/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:
fbae9dbe0 [Auto] Updated Upstream (Bukkit/CraftBukkit)
ac4a33aab [Auto] Updated Upstream (Bukkit)
c1e07158b [Auto] Updated Upstream (Bukkit/CraftBukkit)
5e4b88e95 Fix dangling sout
23afda179 basic hostname validation
0fb8bdf0e Updated Upstream (Bukkit/CraftBukkit) (#5508)
88ab784da [Auto] Updated Upstream (CraftBukkit)
ca7111d5f Fix PlayerItemConsumeEvent cancelling (fixes #4682) (#5383)
06fb560dc Add support for tab completing and highlighting console input from the Brigadier command tree (#5437)
0a9b89c7a Fix occasional light gen issues for neighbor blocks (#5500)
a08be1ec7 [Auto] Updated Upstream (CraftBukkit)

Tuinity Changes:
7d36676 Fix light source locking
f1ec0c2 Add concurrency check to ProtoChunk light sources
159d146 Improvements to chunk loader system

Airplane Changes:
3b3cde7 Correctly use DEAR values, fix config reloading
dd60919 Updated Upstream (Tuinity)

Purpur Changes:
5674cdc Updated Upstream (Paper)

Empirecraft Changes:
efda8c5b Updated Paper

* Updated Upstream and Sidestream(s) (Paper/Tuinity)

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:
39bf5b525 Update teams known as code owners

Tuinity Changes:
b12d0cc Replace ticket level propagator
42df8e1 Correctly handle recursion for chunkholder updates
73eb2a8 Do not copy visible chunks
8a4f3be Do not schedule poi task for each block write on chunk gen

* Multithreaded Entity Tracker fixup
2021-04-21 17:26:49 -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 1b15216d6a03c1031d2bbea2e0243a0de9a9199f..66b5fdd78aa8d394795550aec1203a4de9e4143d 100644
--- a/src/main/java/net/minecraft/server/level/WorldServer.java
+++ b/src/main/java/net/minecraft/server/level/WorldServer.java
@@ -1007,12 +1007,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) {
@@ -1027,11 +1036,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)) {
@@ -1237,9 +1244,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
@@ -2069,8 +2076,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 )
@@ -2087,7 +2095,7 @@ public class WorldServer extends World implements GeneratorAccessSeed {
}
}
}
- } );
+ } // Yatopia
}
// Spigot end
// Spigot Start