mirror of
https://github.com/PaperMC/Paper.git
synced 2024-09-12 06:58:11 +02:00
Add helper functions to ChunkProviderServer to make this easier for other uses Co-authored-by: Spottedleaf <Spottedleaf@users.noreply.github.com>
42 lines
2.3 KiB
Diff
42 lines
2.3 KiB
Diff
From d1b5d9b592e1f4d6763a1d8e4873d4752975bb72 Mon Sep 17 00:00:00 2001
|
|
From: Aikar <aikar@aikar.co>
|
|
Date: Sun, 19 Apr 2020 04:28:29 -0400
|
|
Subject: [PATCH] Load Chunks for Login Asynchronously
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/PlayerList.java b/src/main/java/net/minecraft/server/PlayerList.java
|
|
index c2850d50d..d145c4bf1 100644
|
|
--- a/src/main/java/net/minecraft/server/PlayerList.java
|
|
+++ b/src/main/java/net/minecraft/server/PlayerList.java
|
|
@@ -106,8 +106,9 @@ public abstract class PlayerList {
|
|
// CraftBukkit start - Better rename detection
|
|
if (nbttagcompound != null && nbttagcompound.hasKey("bukkit")) {
|
|
NBTTagCompound bukkit = nbttagcompound.getCompound("bukkit");
|
|
- s = bukkit.hasKeyOfType("lastKnownName", 8) ? bukkit.getString("lastKnownName") : s;
|
|
+ s = bukkit.hasKeyOfType("lastKnownName", 8) ? bukkit.getString("lastKnownName") : s; // Diff below
|
|
}
|
|
+ String lastKnownName = s; // Paper
|
|
if (nbttagcompound == null) entityplayer.moveToSpawn(worldserver); // Paper - only move to spawn on first login, otherwise, stay where you are....
|
|
// CraftBukkit end
|
|
|
|
@@ -132,6 +133,16 @@ public abstract class PlayerList {
|
|
entityplayer.setYawPitch(loc.getYaw(), loc.getPitch());
|
|
// Spigot end
|
|
|
|
+ // Paper start - async load spawn in chunk
|
|
+ WorldServer finalWorldserver = worldserver;
|
|
+ worldserver.getChunkProvider().getTickingChunkAsync(loc.getBlockX() >> 4, loc.getBlockZ() >> 4, (chunk -> { // use ticking - as it has at least 1 neighbours loaded
|
|
+ if (networkmanager.isConnected()) {
|
|
+ postChunkLoadJoin(entityplayer, finalWorldserver, nbttagcompound, networkmanager, lastKnownName, networkmanager.getSocketAddress().toString());
|
|
+ }
|
|
+ }));
|
|
+ }
|
|
+ private void postChunkLoadJoin(EntityPlayer entityplayer, WorldServer worldserver, NBTTagCompound nbttagcompound, NetworkManager networkmanager, String s, String s1) {
|
|
+ // Paper end
|
|
// CraftBukkit - Moved message to after join
|
|
// PlayerList.LOGGER.info("{}[{}] logged in with entity id {} at ({}, {}, {})", entityplayer.getDisplayName().getString(), s1, entityplayer.getId(), entityplayer.locX(), entityplayer.locY(), entityplayer.locZ());
|
|
WorldData worlddata = worldserver.getWorldData();
|
|
--
|
|
2.26.0
|
|
|