Yatopia/patches/server/0024-Optimize-some-stuff-in-WorldServer-ticking.patch
Simon Gardling 61f261ee2a
Updated Upstream and Sidestream(s) (Paper/Airplane/Purpur/Empirecraft/Origami) (#474)
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:
b8020379c Extract Adventure Version into a variable, add reminder to update the linked JD on the homepage (#5422)
809466f2e Fix anchor respawn acting as a bed respawn when using the end portal (#5540)
d219fd642 [Auto] Updated Upstream (Bukkit/CraftBukkit)
db464b099 Implement methods to convert between Component and Brigadier's Message (#5542)
4047cffca Add PlayerBedFailEnterEvent (#4935)
70d697e6e Update Paperpclip
5ed771591 [CI-SKIP] Remove bad null annotation (#5538)
454a4c78e More World API (#3850)
869e02304 Add PlayerDeepSleepEvent (#5525)
fb56fc35e fix non-dummy objectives not updating
dc859a61f [CI-SKIP] [Auto] Rebuild Patches
7d1689f1a  Add missing checkReachable check for shulker boxes (#5453)
ba8eb3d4b Add missing Javadoc for COLORABLE MaterialTag (#5376)
db801cbf3 Fix PlayerItemHeldEvent firing twice (#5534)
14de2b795 fix PigZombieAngerEvent cancellation (fixes #5319) (v2) (#5329)
86d684ad1 Add get-set drop chance to EntityEquipment (#5528)
33fb8cf63 Add consumeFuel to FurnaceBurnEvent (#5532)
9957f4630 Fix duplicating /give items on item drop cancel (#5536)
d94882043 Fix legacyComposer not using AsyncChatEvent messages (#5509)
053bd82cc Don't print spawn load time when not loading spawn (#5467)
a6d78caae Add isDeeplySleeping to HumanEntity (#5470)
711b7a80b Expose more Adventure serializers through PaperComponents (#5443)
3f63bde0c Set Area Effect Cloud Rotation (#5462)
3523f0fda Remove useless check on player interact cancellation (#5448)
6574d1aa8 fix #5526 - use correct type when sending message to clients
dbfa833ec don't throw when loading TE with invalid keys
a9525a6f7 Do not schedule poi task for each block write on chunk gen

Airplane Changes:
f5fb024 Temporarily revert patch
3c728a7 Oops, these 2 too
37a93e5 Your daily dose of 1-3% optimization patches
bbd689a Remove useless check
d8bdbc5 Reduce allocations for fire spreading
41051fd Redo reduction of entity chunk ticking check patch
31272d8 Flare Update
8f32713 Remove criterion patch
0fed2df Various patches that need to be reorganized later
f78856b Updated Upstream (Tuinity)
f7d6382 Flare Update
71d0799 Update gradle configuration
0f79774 Updated Upstream (Tuinity)

Purpur Changes:
3dce975 Updated Upstream (Paper & Airplane) (#298)
eb07368 Run GitHub Actions for pull requests
e97d062 Updated Upstream (Paper, Tuinity, & Airplane)

Empirecraft Changes:
2a021ede Updated Paper
e963bb2c Add Paper MojangAPI to pom
6f5bf24e Updated Paper

Origami Changes:
73ecdf1 Update Paper
73a3735 Item and exp merge improvements
2021-04-27 12:40:55 -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 13c90105d62a599120e9872383a0c2b9aa4110cb..e584df4af6b1b29ceb3af8f267c281bc0903246c 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)) {
@@ -1236,9 +1243,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
@@ -2066,8 +2073,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 )
@@ -2084,7 +2092,7 @@ public class WorldServer extends World implements GeneratorAccessSeed {
}
}
}
- } );
+ } // Yatopia
}
// Spigot end
// Spigot Start