From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Spottedleaf 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 337763efee2c62721ec1320bd749ab55aeb84120..8ee61c2415455f8d4ff1ae687753117a40eb687b 100644 --- a/src/main/java/net/minecraft/server/level/ServerPlayer.java +++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java @@ -673,7 +673,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 f792fd137a964a40e2246d31ab2ddbbdeba6eab6..ed628d38136534b3391c0a06b9c892a922710235 100644 --- a/src/main/java/net/minecraft/world/entity/LivingEntity.java +++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java @@ -4366,6 +4366,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);