diff --git a/src/main/java/xiamomc/morph/backends/server/renderer/network/datawatcher/watchers/types/LivingEntityWatcher.java b/src/main/java/xiamomc/morph/backends/server/renderer/network/datawatcher/watchers/types/LivingEntityWatcher.java index 268cc4d4..b6cffdd6 100644 --- a/src/main/java/xiamomc/morph/backends/server/renderer/network/datawatcher/watchers/types/LivingEntityWatcher.java +++ b/src/main/java/xiamomc/morph/backends/server/renderer/network/datawatcher/watchers/types/LivingEntityWatcher.java @@ -3,6 +3,7 @@ import io.papermc.paper.event.player.PlayerStopUsingItemEvent; import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap; import it.unimi.dsi.fastutil.objects.ObjectArrayList; +import net.minecraft.core.BlockPos; import org.bukkit.Bukkit; import org.bukkit.Color; import org.bukkit.entity.EntityType; @@ -20,6 +21,7 @@ import java.util.List; import java.util.Map; +import java.util.Optional; public class LivingEntityWatcher extends EntityWatcher implements Listener { @@ -102,6 +104,24 @@ protected void doSync() write(values.STUCKED_ARROWS, player.getArrowsInBody()); write(values.BEE_STINGERS, player.getBeeStingersInBody()); + Optional bedPos = Optional.empty(); + if (player.isSleeping()) + { + try + { + var bukkitPos = player.getBedLocation(); + bedPos = Optional.of( + new BlockPos(bukkitPos.blockX(),bukkitPos.blockY(), bukkitPos.blockZ()) + ); + } + catch (Throwable t) + { + logger.warn("Error occurred while processing bed pos: " + t.getMessage()); + } + } + + write(values.BED_POS, bedPos); + super.doSync(); } }