Paper/Spigot-Server-Patches/0440-Don-t-move-existing-players-to-world-spawn.patch

55 lines
2.8 KiB
Diff
Raw Normal View History

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Thu, 9 Apr 2020 21:20:33 -0400
Subject: [PATCH] Don't move existing players to world spawn
This can cause a nasty server lag the spawn chunks are not kept loaded
or they aren't finished loading yet, or if the world spawn radius is
larger than the keep loaded range.
By skipping this, we avoid potential for a large spike on server start.
diff --git a/src/main/java/net/minecraft/server/EntityPlayer.java b/src/main/java/net/minecraft/server/EntityPlayer.java
index c6f326787328ff6b2f974d653dc9e7932c3c0205..03e1b76a8b6850a26ed8a7b1992e09756166f5b8 100644
--- a/src/main/java/net/minecraft/server/EntityPlayer.java
+++ b/src/main/java/net/minecraft/server/EntityPlayer.java
2020-06-27 06:57:36 +02:00
@@ -118,7 +118,7 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
this.serverStatisticManager = minecraftserver.getPlayerList().getStatisticManager(this);
this.advancementDataPlayer = minecraftserver.getPlayerList().f(this);
this.G = 1.0F;
- this.b(worldserver);
+ //this.b(worldserver); // Paper - don't move to spawn on login, only first join
this.cachedSingleHashSet = new com.destroystokyo.paper.util.misc.PooledLinkedHashSets.PooledObjectLinkedOpenHashSet<>(this); // Paper
@@ -168,6 +168,7 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
}
// CraftBukkit end
+ public final void moveToSpawn(WorldServer worldserver) { b(worldserver); } // Paper - OBFHELPER
private void b(WorldServer worldserver) {
BlockPosition blockposition = worldserver.getSpawn();
@@ -343,7 +344,7 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
position = Vec3D.a(((WorldServer) world).getSpawn());
}
this.world = world;
- this.setPosition(position.getX(), position.getY(), position.getZ());
+ this.setPositionRaw(position.getX(), position.getY(), position.getZ()); // Paper - don't register to chunks yet
}
this.playerInteractManager.a((WorldServer) world);
}
diff --git a/src/main/java/net/minecraft/server/PlayerList.java b/src/main/java/net/minecraft/server/PlayerList.java
index 31f33e8de4b976b6a895568dd55dae35645e9a80..502f4b93e04c78f4681459abfb160c6fc2279c72 100644
--- a/src/main/java/net/minecraft/server/PlayerList.java
+++ b/src/main/java/net/minecraft/server/PlayerList.java
@@ -134,6 +134,8 @@ public abstract class PlayerList {
worldserver1 = worldserver;
}
+ if (nbttagcompound == null) entityplayer.moveToSpawn(worldserver1); // Paper - only move to spawn on first login, otherwise, stay where you are....
+
entityplayer.spawnIn(worldserver1);
entityplayer.playerInteractManager.a((WorldServer) entityplayer.world);
String s1 = "local";