0
0
mirror of https://github.com/PaperMC/Folia.git synced 2024-11-27 06:59:03 +00:00
Folia/patches/server/0017-Sync-vehicle-position-to-player-position-on-player-d.patch
2024-05-30 17:17:02 -07:00

27 lines
1.8 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 db2903276c694d395f62afdc7c71344466ae505f..5f9c89dbbfa9b3e4d2b68c0d8628cf223c1f7aa0 100644
--- a/src/main/java/net/minecraft/server/players/PlayerList.java
+++ b/src/main/java/net/minecraft/server/players/PlayerList.java
@@ -522,7 +522,13 @@ public abstract class PlayerList {
if (optional.isPresent() && ((CompoundTag) optional.get()).contains("RootVehicle", 10)) {
CompoundTag nbttagcompound = ((CompoundTag) optional.get()).getCompound("RootVehicle");
ServerLevel finalWorldServer = worldserver1; // CraftBukkit - decompile error
+ Vec3 playerPos = player.position(); // Paper - force sync root vehicle to player position
Entity entity = EntityType.loadEntityRecursive(nbttagcompound.getCompound("Entity"), worldserver1, (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; // CraftBukkit - decompile error // Paper - Entity#getEntitySpawnReason
});