Folia/patches/server/0013-Skip-worldstate-access-when-waking-players-up-during.patch
2024-04-11 17:03:29 -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 36d074d1abed62b09ca808dc2774bc83a6fd5df7..9d7837f90340a96edbd544826ae2241c61ae72c4 100644
--- a/src/main/java/net/minecraft/server/level/ServerPlayer.java
+++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java
@@ -644,7 +644,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 73e0c2ec5ab8cf54767755f31d1a8d0a168ee46f..b9f6e599afd4bdfb97e7f1b1881730cbed781bba 100644
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
@@ -4390,6 +4390,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);