Folia/patches/server/0017-Sync-vehicle-position-to-player-position-on-player-d.patch
Spottedleaf 6928284a56 Update Paper and add configurable region shift
The region shift is configurable under `grid-exponent`, which
allows setting the region shift to any value in [0, 31]. Note
that values above 6 affect the lock shift, as the lock shift
currently is computed as max(ticket shift = 6, region shift).
The shift is left configurable for now as the lower default
shift of 2 may have negative performance impacts.

The default region shift has been adjusted to 2 from 4, and
the empty chunk buffer has been reduced to 8 from 16. These
changes reduce, but do not eliminate, player spread
requirements. The previous block range was around ~1500 blocks
at VD = 10, but is now closer to ~900 blocks at VD = 10. This
roughly reduces the area that each player uses in the regioniser
by 2.5x.
2023-12-30 17:20:19 -08:00

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 eb797313a13b5a805f834b2e9f08989e381f0761..e63ad8ed0318fb99e99a8609ef6a31d16f87e7ff 100644
--- a/src/main/java/net/minecraft/server/players/PlayerList.java
+++ b/src/main/java/net/minecraft/server/players/PlayerList.java
@@ -514,7 +514,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
});