Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
9400308
Add BedTile and BedItem classes
danqzq Jan 12, 2026
049d45a
Add bed tile rendering
danqzq Jan 12, 2026
80e662b
Add player sleeping logic
danqzq Jan 12, 2026
aeaa1a0
Add sleeping player rendering
danqzq Jan 12, 2026
a83ff4c
Add sleeping camera/view behavior
danqzq Jan 12, 2026
3c28830
Add multiplayer sleeping support
danqzq Jan 12, 2026
2192055
Add BedItem and BedTile source files to Xcode project for macOS build
danqzq Jan 12, 2026
e8d2b60
Add helper function to retrieve entity or local player in ClientSideN…
danqzq Jan 12, 2026
c64477c
Implement proper bed respawn validation and messaging for players
danqzq Jan 13, 2026
ae895ee
Add bed obstruction check to sleep and respawn position validation
danqzq Jan 13, 2026
1a770bc
Rename sleep -> startSleepInBed and wake -> stopSleepInBed
danqzq Jan 13, 2026
5a277af
Replace AnimatePacket::SLEEP with InteractionPacket for handling play…
danqzq Jan 13, 2026
1ec5a63
Add bed destruction handling to wake sleeping players
danqzq Jan 13, 2026
ad17095
Refactor bed direction handling to use Facing::Name enum for improved…
danqzq Jan 13, 2026
8fb2a12
Update multiplayer check to use m_bIsClientSide
danqzq Jan 13, 2026
1ba53fd
Remove displayClientMessage usage in BedTile.cpp - no localization at…
danqzq Jan 13, 2026
fa519f7
Remove license header comments from BedItem and BedTile files
danqzq Jan 13, 2026
931a1cc
Remove client-side bed spawn validation
danqzq Jan 13, 2026
0322c30
Rename getEntityOrLocalPlayer to _getEntityOrLocalPlayer
danqzq Jan 13, 2026
be00a99
Refactor BedTile hiddenFace to use Facing::Name type for better clarity
danqzq Jan 13, 2026
7513b80
Refactor bed respawn handling to align with b1.3 logic
danqzq Jan 13, 2026
06aa0bd
Merge branch 'master' into feat/beds
BrentDaMage Jan 27, 2026
6948adf
Fixed bad merge (I love git)
BrentDaMage Jan 27, 2026
51d47c7
Added BedItem to VS World Project
BrentDaMage Jan 27, 2026
4a6c1de
Merge branch 'master' into feat/beds
BrentDaMage Jan 28, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -520,6 +520,7 @@
84BF63162AF18631008A9995 /* SurvivalMode.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 840DD66D2AC810620006A435 /* SurvivalMode.cpp */; };
84BF63172AF18631008A9995 /* CameraItem.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 840DD6702AC810620006A435 /* CameraItem.cpp */; };
84BF63182AF18631008A9995 /* DoorItem.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 840DD6722AC810620006A435 /* DoorItem.cpp */; };
59B35F78C33D4247A5F2FB80 /* BedItem.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 275AF7A1723F44EE9B9C0DA7 /* BedItem.cpp */; };
84BF63192AF18631008A9995 /* Inventory.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 840DD6742AC810620006A435 /* Inventory.cpp */; };
84BF631A2AF18631008A9995 /* Item.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 840DD6762AC810620006A435 /* Item.cpp */; };
84BF631C2AF18631008A9995 /* TileItem.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 840DD67A2AC810620006A435 /* TileItem.cpp */; };
Expand Down Expand Up @@ -798,6 +799,7 @@
84E1C9D02E7FDC26007D2F5D /* CactusTile.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84E1C9C02E7FDC26007D2F5D /* CactusTile.hpp */; };
84E1C9D12E7FDC26007D2F5D /* DeadBush.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84E1C9C12E7FDC26007D2F5D /* DeadBush.cpp */; };
84E1C9D22E7FDC26007D2F5D /* DeadBush.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84E1C9C22E7FDC26007D2F5D /* DeadBush.hpp */; };
D025F1B21908432AAB13CCAB /* BedTile.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D025F1B21908432AAB13CCAC /* BedTile.cpp */; };
84E1C9D32E7FDC26007D2F5D /* FenceTile.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84E1C9C32E7FDC26007D2F5D /* FenceTile.cpp */; };
84E1C9D42E7FDC26007D2F5D /* FenceTile.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84E1C9C42E7FDC26007D2F5D /* FenceTile.hpp */; };
84E1C9D52E7FDC26007D2F5D /* GlowstoneTile.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84E1C9C52E7FDC26007D2F5D /* GlowstoneTile.cpp */; };
Expand Down Expand Up @@ -1176,6 +1178,8 @@
84F77A402EA1C01C0045C907 /* EntityEventPacket.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84F77A162EA1C01B0045C907 /* EntityEventPacket.hpp */; };
84F77A412EA1C01C0045C907 /* InteractPacket.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84F77A172EA1C01C0045C907 /* InteractPacket.cpp */; };
84F77A422EA1C01C0045C907 /* InteractPacket.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84F77A182EA1C01C0045C907 /* InteractPacket.hpp */; };
84F77AA12EA1C01C0045C907 /* InteractionPacket.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84F77AA32EA1C01C0045C907 /* InteractionPacket.cpp */; };
84F77AA22EA1C01C0045C907 /* InteractionPacket.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84F77AA42EA1C01C0045C907 /* InteractionPacket.hpp */; };
84F77A432EA1C01C0045C907 /* LevelDataPacket.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84F77A192EA1C01C0045C907 /* LevelDataPacket.hpp */; };
84F77A442EA1C01C0045C907 /* LevelEventPacket.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84F77A1A2EA1C01C0045C907 /* LevelEventPacket.cpp */; };
84F77A452EA1C01C0045C907 /* LevelEventPacket.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84F77A1B2EA1C01C0045C907 /* LevelEventPacket.hpp */; };
Expand Down Expand Up @@ -1625,6 +1629,8 @@
840DD6712AC810620006A435 /* CameraItem.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = CameraItem.hpp; sourceTree = "<group>"; };
840DD6722AC810620006A435 /* DoorItem.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DoorItem.cpp; sourceTree = "<group>"; };
840DD6732AC810620006A435 /* DoorItem.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = DoorItem.hpp; sourceTree = "<group>"; };
275AF7A1723F44EE9B9C0DA7 /* BedItem.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = BedItem.cpp; sourceTree = "<group>"; };
6CE4834EE148437C93D73250 /* BedItem.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = BedItem.hpp; sourceTree = "<group>"; };
840DD6742AC810620006A435 /* Inventory.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Inventory.cpp; sourceTree = "<group>"; };
840DD6752AC810620006A435 /* Inventory.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = Inventory.hpp; sourceTree = "<group>"; };
840DD6762AC810620006A435 /* Item.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Item.cpp; sourceTree = "<group>"; };
Expand Down Expand Up @@ -2424,6 +2430,8 @@
84E1C9C02E7FDC26007D2F5D /* CactusTile.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = CactusTile.hpp; sourceTree = "<group>"; };
84E1C9C12E7FDC26007D2F5D /* DeadBush.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DeadBush.cpp; sourceTree = "<group>"; };
84E1C9C22E7FDC26007D2F5D /* DeadBush.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = DeadBush.hpp; sourceTree = "<group>"; };
D025F1B21908432AAB13CCAC /* BedTile.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = BedTile.cpp; sourceTree = "<group>"; };
D025F1B21908432AAB13CCAD /* BedTile.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = BedTile.hpp; sourceTree = "<group>"; };
84E1C9C32E7FDC26007D2F5D /* FenceTile.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FenceTile.cpp; sourceTree = "<group>"; };
84E1C9C42E7FDC26007D2F5D /* FenceTile.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = FenceTile.hpp; sourceTree = "<group>"; };
84E1C9C52E7FDC26007D2F5D /* GlowstoneTile.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GlowstoneTile.cpp; sourceTree = "<group>"; };
Expand Down Expand Up @@ -2800,6 +2808,8 @@
84F77A162EA1C01B0045C907 /* EntityEventPacket.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = EntityEventPacket.hpp; sourceTree = "<group>"; };
84F77A172EA1C01C0045C907 /* InteractPacket.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InteractPacket.cpp; sourceTree = "<group>"; };
84F77A182EA1C01C0045C907 /* InteractPacket.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = InteractPacket.hpp; sourceTree = "<group>"; };
84F77AA32EA1C01C0045C907 /* InteractionPacket.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InteractionPacket.cpp; sourceTree = "<group>"; };
84F77AA42EA1C01C0045C907 /* InteractionPacket.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = InteractionPacket.hpp; sourceTree = "<group>"; };
84F77A192EA1C01C0045C907 /* LevelDataPacket.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = LevelDataPacket.hpp; sourceTree = "<group>"; };
84F77A1A2EA1C01C0045C907 /* LevelEventPacket.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LevelEventPacket.cpp; sourceTree = "<group>"; };
84F77A1B2EA1C01C0045C907 /* LevelEventPacket.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = LevelEventPacket.hpp; sourceTree = "<group>"; };
Expand Down Expand Up @@ -3310,6 +3320,8 @@
84F77A162EA1C01B0045C907 /* EntityEventPacket.hpp */,
84F77A172EA1C01C0045C907 /* InteractPacket.cpp */,
84F77A182EA1C01C0045C907 /* InteractPacket.hpp */,
84F77AA32EA1C01C0045C907 /* InteractionPacket.cpp */,
84F77AA42EA1C01C0045C907 /* InteractionPacket.hpp */,
840DD6422AC810620006A435 /* LevelDataPacket.cpp */,
84F77A192EA1C01C0045C907 /* LevelDataPacket.hpp */,
84F77A1A2EA1C01C0045C907 /* LevelEventPacket.cpp */,
Expand Down Expand Up @@ -3537,6 +3549,8 @@
84E1C9E22E7FDC72007D2F5D /* ClothItem.hpp */,
840DD6722AC810620006A435 /* DoorItem.cpp */,
840DD6732AC810620006A435 /* DoorItem.hpp */,
275AF7A1723F44EE9B9C0DA7 /* BedItem.cpp */,
6CE4834EE148437C93D73250 /* BedItem.hpp */,
840DD6742AC810620006A435 /* Inventory.cpp */,
840DD6752AC810620006A435 /* Inventory.hpp */,
840DD6762AC810620006A435 /* Item.cpp */,
Expand Down Expand Up @@ -3754,6 +3768,8 @@
840DD6ED2AC810620006A435 /* DoorTile.hpp */,
840DD6EE2AC810620006A435 /* FarmTile.cpp */,
840DD6EF2AC810620006A435 /* FarmTile.hpp */,
D025F1B21908432AAB13CCAC /* BedTile.cpp */,
D025F1B21908432AAB13CCAD /* BedTile.hpp */,
84E1C9C32E7FDC26007D2F5D /* FenceTile.cpp */,
84E1C9C42E7FDC26007D2F5D /* FenceTile.hpp */,
840DD6F02AC810620006A435 /* FireTile.cpp */,
Expand Down Expand Up @@ -5190,6 +5206,7 @@
84F77A522EA1C01C0045C907 /* RemoveEntityPacket.hpp in Headers */,
84F77A5A2EA1C01C0045C907 /* SetTimePacket.hpp in Headers */,
84F77A422EA1C01C0045C907 /* InteractPacket.hpp in Headers */,
84F77AA22EA1C01C0045C907 /* InteractionPacket.hpp in Headers */,
84F77A472EA1C01C0045C907 /* LoginStatusPacket.hpp in Headers */,
84F77A502EA1C01C0045C907 /* ReadyPacket.hpp in Headers */,
84F77A512EA1C01C0045C907 /* RemoveBlockPacket.hpp in Headers */,
Expand Down Expand Up @@ -6180,6 +6197,7 @@
84F77A3C2EA1C01C0045C907 /* AnimatePacket.cpp in Sources */,
84F77A392EA1C01C0045C907 /* AddMobPacket.cpp in Sources */,
84F77A412EA1C01C0045C907 /* InteractPacket.cpp in Sources */,
84F77AA12EA1C01C0045C907 /* InteractionPacket.cpp in Sources */,
842610702AE989720065905F /* NetEventCallback.cpp in Sources */,
84F77A562EA1C01C0045C907 /* SetEntityDataPacket.cpp in Sources */,
842610712AE989720065905F /* AddPlayerPacket.cpp in Sources */,
Expand Down Expand Up @@ -6450,6 +6468,7 @@
84E1C9E52E7FDC72007D2F5D /* AuxTileItem.cpp in Sources */,
84E1C9D52E7FDC26007D2F5D /* GlowstoneTile.cpp in Sources */,
84BF63182AF18631008A9995 /* DoorItem.cpp in Sources */,
59B35F78C33D4247A5F2FB80 /* BedItem.cpp in Sources */,
84BF63192AF18631008A9995 /* Inventory.cpp in Sources */,
8445E7A22D769329008DC834 /* EntityType.cpp in Sources */,
84BF631A2AF18631008A9995 /* Item.cpp in Sources */,
Expand Down Expand Up @@ -6505,6 +6524,7 @@
84BF633F2AF18631008A9995 /* LevelSource.cpp in Sources */,
84BF63402AF18631008A9995 /* LevelStorage.cpp in Sources */,
84BF63412AF18631008A9995 /* LevelStorageSource.cpp in Sources */,
D025F1B21908432AAB13CCAB /* BedTile.cpp in Sources */,
84E1C9D32E7FDC26007D2F5D /* FenceTile.cpp in Sources */,
8477B3BA2C4DC42E004E1AC5 /* Vec2.cpp in Sources */,
84BF63422AF18631008A9995 /* MemoryChunkStorage.cpp in Sources */,
Expand Down
2 changes: 2 additions & 0 deletions platforms/windows/projects/World/World.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@
<ClCompile Include="$(MC_ROOT)\source\world\entity\Zombie.cpp" />
<ClCompile Include="$(MC_ROOT)\source\world\entity\EntityFactory.cpp" />
<ClCompile Include="$(MC_ROOT)\source\world\level\levelgen\chunk\DataLayer.cpp" />
<ClCompile Include="$(MC_ROOT)\source\world\item\BedItem.cpp" />
<ClCompile Include="$(MC_ROOT)\source\world\ContainerListener.cpp" />
<ClCompile Include="$(MC_ROOT)\source\world\inventory\ContainerMenu.cpp" />
<ClCompile Include="$(MC_ROOT)\source\world\inventory\Slot.cpp" />
Expand Down Expand Up @@ -351,6 +352,7 @@
<ClInclude Include="$(MC_ROOT)\source\world\level\levelgen\chunk\DataLayer.hpp" />
<ClInclude Include="$(MC_ROOT)\source\world\level\TileChange.hpp" />
<ClInclude Include="$(MC_ROOT)\source\world\level\LevelEvent.hpp" />
<ClInclude Include="$(MC_ROOT)\source\world\item\BedItem.hpp" />
<ClInclude Include="$(MC_ROOT)\source\world\Container.hpp" />
<ClInclude Include="$(MC_ROOT)\source\world\ContainerListener.hpp" />
<ClInclude Include="$(MC_ROOT)\source\world\inventory\ContainerMenu.hpp" />
Expand Down
6 changes: 6 additions & 0 deletions platforms/windows/projects/World/World.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -566,6 +566,9 @@
<ClCompile Include="$(MC_ROOT)\source\world\level\levelgen\chunk\DataLayer.cpp">
<Filter>Source Files\Level\LevelGen\Chunk</Filter>
</ClCompile>
<ClCompile Include="$(MC_ROOT)\source\world\item\BedItem.cpp">
<Filter>Source Files\Item</Filter>
</ClCompile>
<ClCompile Include="$(MC_ROOT)\source\world\ContainerListener.cpp">
<Filter>Source Files</Filter>
</ClCompile>
Expand Down Expand Up @@ -1018,6 +1021,9 @@
<ClInclude Include="$(MC_ROOT)\source\world\level\LevelEvent.hpp">
<Filter>Header Files\Level</Filter>
</ClInclude>
<ClInclude Include="$(MC_ROOT)\source\world\item\BedItem.hpp">
<Filter>Header Files\Item</Filter>
</ClCompile>
<ClInclude Include="$(MC_ROOT)\source\world\Container.hpp">
<Filter>Header Files</Filter>
</ClInclude>
Expand Down
3 changes: 3 additions & 0 deletions source/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ add_library(reminecraftpe-core STATIC
network/packets/RequestChunkPacket.cpp
network/packets/PlayerEquipmentPacket.cpp
network/packets/InteractPacket.cpp
network/packets/InteractionPacket.cpp
network/packets/UseItemPacket.cpp
network/packets/SetEntityDataPacket.cpp
network/packets/SetHealthPacket.cpp
Expand Down Expand Up @@ -320,6 +321,7 @@ add_library(reminecraftpe-core STATIC
world/inventory/SimpleContainer.cpp
world/CompoundContainer.cpp
world/item/DoorItem.cpp
world/item/BedItem.cpp
world/item/ItemStack.cpp
world/item/RocketItem.cpp
world/item/Item.cpp
Expand Down Expand Up @@ -382,6 +384,7 @@ add_library(reminecraftpe-core STATIC
world/tile/GlowstoneTile.cpp
world/tile/Web.cpp
world/tile/FenceTile.cpp
world/tile/BedTile.cpp
renderer/GL/GL.cpp
renderer/Attribute.cpp
renderer/ConstantBufferMetaData.cpp
Expand Down
44 changes: 40 additions & 4 deletions source/client/app/Minecraft.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
#include "client/player/input/Multitouch.hpp"

#include "world/tile/SandTile.hpp"
#include "world/tile/BedTile.hpp"

#include "client/renderer/GrassColor.hpp"
#include "client/renderer/FoliageColor.hpp"
Expand Down Expand Up @@ -150,11 +151,33 @@ void Minecraft::_levelGenerated()
void Minecraft::_resetPlayer(Player* player)
{
m_pLevel->validateSpawn();

TilePos spawnPos;

if (player->m_bHasRespawnPos)
{
spawnPos = player->getRespawnPosition();

if (m_pLevel->getTile(spawnPos) == Tile::bed->m_ID)
{
TilePos safePos = BedTile::getRespawnTilePos(m_pLevel, spawnPos, 0);
if (safePos == spawnPos)
safePos = safePos.above();

player->reset();
player->moveTo(Vec3(safePos.x + 0.5f, float(safePos.y), safePos.z + 0.5f));
player->resetPos(true);
return;
}

// If bed was destroyed, clear the respawn position and fall through to world spawn
player->setRespawnPos(TilePos(-1, -1, -1));
}

spawnPos = m_pLevel->getSharedSpawnPos();
player->reset();

TilePos pos = m_pLevel->getSharedSpawnPos();
player->setPos(pos);
player->resetPos();
player->moveTo(Vec3(spawnPos.x + 0.5f, float(spawnPos.y), spawnPos.z + 0.5f));
player->resetPos(true);
}

GameMode* Minecraft::_createGameMode(GameType gameType, Level& level)
Expand Down Expand Up @@ -465,6 +488,12 @@ void Minecraft::handleBuildAction(const BuildActionIntention& action)
if (item.isEmpty() || !item.getTile())
return;

// Don't send PlaceBlockPacket if we just interacted with a bed
// The bed interaction is handled via UseItemPacket
TileID interactedTile = m_pLevel->getTile(m_hitResult.m_tilePos);
if (interactedTile == Tile::bed->m_ID)
return;

TilePos tp(m_hitResult.m_tilePos);

Facing::Name hitSide = m_hitResult.m_hitSide;
Expand Down Expand Up @@ -1122,6 +1151,13 @@ bool Minecraft::pauseGame()
{
if (isGamePaused() || m_pScreen) return false;

// If player is sleeping, wake them up instead of pausing
if (m_pLocalPlayer && m_pLocalPlayer->isSleeping())
{
m_pLocalPlayer->stopSleepInBed(false, true, true);
return true;
}

if (!isOnline())
{
// Actually pause the game, because fuck bedrock edition
Expand Down
24 changes: 24 additions & 0 deletions source/client/multiplayer/MultiplayerLocalPlayer.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#include "MultiplayerLocalPlayer.hpp"
#include "network/RakNetInstance.hpp"
#include "network/packets/AnimatePacket.hpp"
#include "network/packets/MovePlayerPacket.hpp"
#include "world/level/Level.hpp"

MultiplayerLocalPlayer::MultiplayerLocalPlayer(Minecraft* pMinecraft, Level* pLevel, User* pUser, GameType gameType, int dimensionId)
Expand Down Expand Up @@ -85,3 +87,25 @@ void MultiplayerLocalPlayer::hurtTo(int newHealth)
m_flashOnSetHealth = true;
}
}

Player::BedSleepingProblem MultiplayerLocalPlayer::startSleepInBed(const TilePos& pos)
{
// Client players receive sleep command from server via InteractionPacket
// Just apply the sleep state locally - position will be set by MovePlayerPacket
return Player::startSleepInBed(pos);
}

void MultiplayerLocalPlayer::stopSleepInBed(bool resetCounter, bool update, bool setSpawn)
{
Player::stopSleepInBed(resetCounter, update, setSpawn);

// Send wake notification to server
if (m_pLevel && m_pLevel->m_pRakNetInstance)
{
m_pLevel->m_pRakNetInstance->send(new AnimatePacket(m_EntityID, AnimatePacket::WAKE_UP));

// Also send position update so server knows where we are after waking
m_pLevel->m_pRakNetInstance->send(new MovePlayerPacket(m_EntityID,
Vec3(m_pos.x, m_pos.y - m_heightOffset, m_pos.z), m_rot));
}
}
3 changes: 3 additions & 0 deletions source/client/multiplayer/MultiplayerLocalPlayer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ class MultiplayerLocalPlayer : public LocalPlayer
void heal(int health) override;
//void drop() override;
void hurtTo(int newHealth) override;

BedSleepingProblem startSleepInBed(const TilePos& pos) override;
void stopSleepInBed(bool resetCounter, bool update, bool setSpawn) override;

private:
bool m_flashOnSetHealth;
Expand Down
Loading
Loading