Paper/Spigot-Server-Patches/0461-Don-t-move-existing-players-to-world-spawn.patch
Aikar f37381ea8a
Optimize Network Manager to not need synchronization
Removes synchronization from sending packets
Makes normal packet sends no longer need to be wrapped and queued like it use to work.
Adds more packet queue immunities on top of keep alive to let the following scenarios go out
without delay:
  - Keep Alive
  - Chat
  - Kick
  - All of the packets during the Player Joined World event

Hoping that latter one helps join timeout issues more too for slow connections.

Removes processing packet queue off of main thread
  - for the few cases where it is allowed, order is not necessary nor
    should it even be happening concurrently in first place (handshaking/login/status)

Ensures packets sent asynchronously are dispatched on main thread

This helps ensure safety for ProtocolLib as packet listeners
are commonly accessing world state. This will allow you to schedule
a packet to be sent async, but itll be dispatched sync for packet
listeners to process.

This should solve some deadlock risks

This may provide a decent performance improvement because thread synchronization incurs a cache reset
so by avoiding ever entering a synchronized block, we get to avoid that, and packet sending is a really
hot activity.
2020-05-06 05:28:47 -04:00

57 lines
2.9 KiB
Diff

From 979cdaa4c29974dac18a2c256333b98b8cd2cc56 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 aa9c903aa82..d51af68a920 100644
--- a/src/main/java/net/minecraft/server/EntityPlayer.java
+++ b/src/main/java/net/minecraft/server/EntityPlayer.java
@@ -114,7 +114,7 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
this.serverStatisticManager = minecraftserver.getPlayerList().getStatisticManager(this);
this.advancementDataPlayer = minecraftserver.getPlayerList().f(this);
this.H = 1.0F;
- this.a(worldserver);
+ //this.a(worldserver); // Paper - don't move to spawn on login, only first join
this.cachedSingleHashSet = new com.destroystokyo.paper.util.misc.PooledLinkedHashSets.PooledObjectLinkedOpenHashSet<>(this); // Paper
@@ -162,6 +162,7 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
}
// CraftBukkit end
+ public void moveToSpawn(WorldServer worldserver) { a(worldserver); } // Paper - OBFHELPER
private void a(WorldServer worldserver) {
BlockPosition blockposition = worldserver.getSpawn();
@@ -302,7 +303,7 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
position = new Vec3D(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.dimension = ((WorldServer) this.world).getWorldProvider().getDimensionManager();
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 909d86e14c7..0b5800649ab 100644
--- a/src/main/java/net/minecraft/server/PlayerList.java
+++ b/src/main/java/net/minecraft/server/PlayerList.java
@@ -108,6 +108,7 @@ public abstract class PlayerList {
NBTTagCompound bukkit = nbttagcompound.getCompound("bukkit");
s = bukkit.hasKeyOfType("lastKnownName", 8) ? bukkit.getString("lastKnownName") : s;
}
+ if (nbttagcompound == null) entityplayer.moveToSpawn(worldserver); // Paper - only move to spawn on first login, otherwise, stay where you are....
// CraftBukkit end
entityplayer.spawnIn(worldserver);
--
2.26.2