mirror of
https://github.com/PaperMC/Folia.git
synced 2024-11-22 12:05:12 +01:00
34039e3709
Player spawn position changing caused any player to log in while on a boat to trip a thread check. To resolve this, simply reposition any mounted entities if they are more than 5 blocks away from the player. In general, this may happen to other entities that are loaded from chunks as well. In these cases, we can delete the entity if it itself is not saved in the correct chunk, and we can reposition the mounted entities if they are not in the correct chunk. For tile entities, we can simply remove them if they are not in the chunk. These changes broadly should make loading player/chunk data more resiliant to bad logic run by plugins. Also, the Folia test revealed that the chunk generate rate limiter also affected chunk loading, which was not intended and has been resolved by exempting already FULL status chunks from the limit.
27 lines
1.7 KiB
Diff
27 lines
1.7 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Spottedleaf <Spottedleaf@users.noreply.github.com>
|
|
Date: Sun, 25 Jun 2023 13:57:30 -0700
|
|
Subject: [PATCH] Sync vehicle position to player position on player data load
|
|
|
|
This allows the player to be re-positioned before logging into
|
|
the world without causing thread checks to trip on Folia.
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java
|
|
index d4620ddfcd06a037f647ab0a8938797405e001b2..654ab7fc8caa9af7dc665391a197b41599c2bc8f 100644
|
|
--- a/src/main/java/net/minecraft/server/players/PlayerList.java
|
|
+++ b/src/main/java/net/minecraft/server/players/PlayerList.java
|
|
@@ -498,7 +498,13 @@ public abstract class PlayerList {
|
|
CompoundTag nbttagcompound1 = nbttagcompound.getCompound("RootVehicle");
|
|
// CraftBukkit start
|
|
ServerLevel finalWorldServer = worldserver1;
|
|
+ Vec3 playerPos = player.position(); // Paper - force sync root vehicle to player position
|
|
Entity entity = EntityType.loadEntityRecursive(nbttagcompound1.getCompound("Entity"), finalWorldServer, (entity1) -> {
|
|
+ // Paper start - force sync root vehicle to player position
|
|
+ if (entity1.distanceToSqr(player) > (5.0 * 5.0)) {
|
|
+ entity1.setPosRaw(playerPos.x, playerPos.y, playerPos.z, true);
|
|
+ }
|
|
+ // Paper end - force sync root vehicle to player position
|
|
return !finalWorldServer.addWithUUID(entity1, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.MOUNT) ? null : entity1; // Paper
|
|
// CraftBukkit end
|
|
});
|