mirror of
https://github.com/PaperMC/Folia.git
synced 2024-11-25 12:35:23 +01:00
40 lines
1.8 KiB
Diff
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 ea396c3b2a7d738ec4331d332b5cff550c9d9ffb..da87c4825c67e62ae238877f1fb3220f4c57f553 100644
|
|
--- a/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
|
+++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
|
@@ -672,7 +672,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 ed1aa10948897780aefa9a2b4034abb4c7efbb17..a1e90547816ebf0811e7b22af793f40015d6c4f3 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
|
@@ -4382,6 +4382,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);
|