-
Notifications
You must be signed in to change notification settings - Fork 75
Feature: Add Beds with Sleeping Functionality #272
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
BrentDaMage
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few minor things. Also, Visual Studio project files don't seem to be updated. I can fix this though.
…er interactions and sleeping state synchronization
… clarity and consistency
|
@BrentDaMage I've made changes based upon your requests. Based on your feedback I've changed the way the sleeping state is synchronized (now via P.S I'm on macOS so I can't generate the Visual Studio project files. |
| } | ||
| } | ||
|
|
||
| void ClientSideNetworkHandler::handle(const RakNet::RakNetGUID& rakGuid, InteractionPacket* pkt) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We cannot do InteractionPacket, this breaks compatibility with actual Pocket Edition/Bedrock. Also, couldn't we just handle this the same way we handle every other block interaction received by the server?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My bad, I forgot that networking-wise we should follow MCPE standards. As far as I'm aware, other blocks like doors handle block interactions via UpdateBlockPacket, but I don't think this is suitable for beds. If not InteractionPacket, then why not UseItemPacket? Would that not be compatible?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the server receives interactions from clients via UseItemPacket, then that's what we should use.
|
|
||
| void ServerSideNetworkHandler::handle(const RakNet::RakNetGUID& guid, InteractionPacket* packet) | ||
| { | ||
| // InteractionPacket is broadcast-only, used to synchronize actions like sleeping |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We shouldn't even need to have InteractionPacket, if its sole purpose is to animate the player on the client-side, just use SynchedEntityData.
Overview
This PR implements a complete bed system with sleeping mechanics and full multiplayer support. Players can now place beds, sleep through the night, and have their sleeping state synchronized across clients.
Demo
Additions
Core Bed System
BedTileclass with directional placement logic (head/foot sections)BedItemfor placing beds based on player facing directionBedSleepingProblemenum for sleep validation (daytime checks, distance validation, dimension restrictions)SHAPE_BEDrender shape and texture constantsPlayer Sleeping State
m_bSleeping,m_sleepTimer,m_bedSleepPosPlayer::sleep()andPlayer::wake()methodsLevel::updateSleeping()to advance time when all players are asleepRendering
tesselateBedInWorld()with proper UV rotation and wood underside renderingsetupPosition()andsetupRotations()inHumanoidMobRendererfor sleeping player posesMultiplayer Support
WAKEandSLEEPactions toAnimatePacketServerPlayer,LocalPlayer, andMultiplayerLocalPlayerClientSideNetworkHandlerChanges
Tile::initTiles()andItem::initItems()NetEventCallbackandMinecraft::_resetPlayer()Attribution
The following implementations were referenced from Wilyicaro/PEtoLE:
getTexture()direction mapping,neighborChanged()logic,use()interaction,setBedOccupied(),getRespawnTilePos()sleep()/wake()implementations,updateSleepingPos(),getBedSleepRot(), sleeping position calculationstesselateBedInWorld()with UV rotation and face direction handlingheadBlockToFootBlockMap,hiddenFace,hiddenFaceIndex,bedDirectionGoing Forward
BedSleepingProblemcases displayed to player