2020-10-22 13:37:58 +02:00
|
|
|
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
|
2021-03-14 20:20:20 +01:00
|
|
|
index 4e7700443c4f0725c0d032b620f84fcfadbde7a1..e695cf764cab6d64ea5bb00af03b25f4930946dd 100644
|
2020-10-22 13:37:58 +02:00
|
|
|
--- a/src/main/java/net/minecraft/server/WorldServer.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/WorldServer.java
|
2021-02-19 20:39:10 +01:00
|
|
|
@@ -885,12 +885,21 @@ public class WorldServer extends World implements GeneratorAccessSeed {
|
2020-10-22 13:37:58 +02:00
|
|
|
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);
|
2021-01-21 11:58:52 +01:00
|
|
|
+ }
|
2020-10-22 13:37:58 +02:00
|
|
|
+ if (sleepyMatch && !player.isSpectator() && !player.isDeeplySleeping() && !player.fauxSleeping) {
|
|
|
|
+ sleepyMatch = false;
|
2021-01-21 11:58:52 +01:00
|
|
|
}
|
2020-10-22 13:37:58 +02:00
|
|
|
+ // 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) {
|
2021-02-19 20:39:10 +01:00
|
|
|
@@ -905,11 +914,9 @@ public class WorldServer extends World implements GeneratorAccessSeed {
|
2020-10-22 13:37:58 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
// CraftBukkit end
|
2021-01-21 11:58:52 +01:00
|
|
|
+ */ // Yatopia end
|
2020-10-22 13:37:58 +02:00
|
|
|
|
|
|
|
- if (this.everyoneSleeping && this.players.stream().noneMatch((entityplayer) -> {
|
2021-01-21 11:58:52 +01:00
|
|
|
- return !entityplayer.isSpectator() && !entityplayer.isDeeplySleeping() && !entityplayer.fauxSleeping && !(purpurConfig.idleTimeoutCountAsSleeping && entityplayer.isAfk()); // CraftBukkit // Purpur
|
2020-10-22 13:37:58 +02:00
|
|
|
- })) {
|
2021-01-21 11:58:52 +01:00
|
|
|
- // CraftBukkit start
|
2020-10-22 13:37:58 +02:00
|
|
|
+ if (this.everyoneSleeping && sleepyMatch) { // Yatopia
|
|
|
|
long l = this.worldData.getDayTime() + 24000L;
|
|
|
|
TimeSkipEvent event = new TimeSkipEvent(this.getWorld(), TimeSkipEvent.SkipReason.NIGHT_SKIP, (l - l % 24000L) - this.getDayTime());
|
2021-01-21 11:58:52 +01:00
|
|
|
if (this.getGameRules().getBoolean(GameRules.DO_DAYLIGHT_CYCLE)) {
|
2021-03-14 20:20:20 +01:00
|
|
|
@@ -1115,9 +1122,9 @@ public class WorldServer extends World implements GeneratorAccessSeed {
|
2020-10-22 13:37:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
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
|
2021-03-14 20:20:20 +01:00
|
|
|
@@ -1920,8 +1927,9 @@ public class WorldServer extends World implements GeneratorAccessSeed {
|
2020-10-22 13:37:58 +02:00
|
|
|
// 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 )
|
2021-03-14 20:20:20 +01:00
|
|
|
@@ -1938,7 +1946,7 @@ public class WorldServer extends World implements GeneratorAccessSeed {
|
2020-10-22 13:37:58 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
- } );
|
|
|
|
+ } // Yatopia
|
|
|
|
}
|
|
|
|
// Spigot end
|
|
|
|
// Spigot Start
|