Folia/patches/server/0015-Skip-worldstate-access-when-waking-players-up-during.patch
Spottedleaf 3cf16eeaf2 Reset player before running place logic
As part of Folia's place logic, the player's health is sent
after the respawn packet.

Since the health is <= 0.0, this would cause the client to
die again. This would cause the respawn screen to appear again,
and would additionally cause other players to see the player as
dead as well.

There is a small window where this would not have occurred, and
that is where the server would send the correct health before
the client ticks again. This is why the issue was not reproducable
locally, as there was is almost zero delay between those events
on an idle server and on perfect 0ms ping.

Fixes https://github.com/PaperMC/Folia/issues/112
2023-08-07 14:35:18 -07:00

40 lines
1.8 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Spottedleaf <Spottedleaf@users.noreply.github.com>
Date: Sun, 23 Apr 2023 07:38:50 -0700
Subject: [PATCH] Skip worldstate access when waking players up during data
deserialization
In general, worldstate read/write is unacceptable during
data deserialization and is racey even in Vanilla. But in Folia,
some accesses may throw and as such we need to fix this directly.
diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java
index 7c4ec191dc64968d349b244818f65c64ba7ab308..c0ad878cd29e2f72b7899d9539031b15ccbf6193 100644
--- a/src/main/java/net/minecraft/server/level/ServerPlayer.java
+++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java
@@ -629,7 +629,7 @@ public class ServerPlayer extends Player {
this.getBukkitEntity().readExtraData(nbt); // CraftBukkit
if (this.isSleeping()) {
- this.stopSleeping();
+ this.stopSleepingRaw(); // Folia - do not modify or read worldstate during data deserialization
}
// CraftBukkit start
diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
index 40dd667bacd296a3a329391dc87a5713c464f4a2..f636bdf1075fa784ce7ee25478d4d94bacb05677 100644
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
@@ -4280,6 +4280,11 @@ public abstract class LivingEntity extends Entity implements Attackable {
}
});
+ // Folia start - separate out
+ this.stopSleepingRaw();
+ }
+ public void stopSleepingRaw() {
+ // Folia end - separate out
Vec3 vec3d = this.position();
this.setPose(Pose.STANDING);