mirror of
https://github.com/smartcmd/MinecraftConsoles.git
synced 2026-05-23 04:03:50 +00:00
add PlayerBedEnterEvent and PlayerBedLeaveEvent + 2 new HumanEntity funcs
This commit is contained in:
parent
6847af62e1
commit
9cbc9aca28
7 changed files with 165 additions and 6 deletions
|
|
@ -1046,6 +1046,10 @@ void ServerPlayer::take(shared_ptr<Entity> e, int orgCount)
|
|||
|
||||
Player::BedSleepingResult ServerPlayer::startSleepInBed(int x, int y, int z, bool bTestUse)
|
||||
{
|
||||
#if defined(_WINDOWS64) && defined(MINECRAFT_SERVER_BUILD)
|
||||
if (!bTestUse && FourKitBridge::FireBedEnter(entityId, dimension, x, y, z))
|
||||
return OTHER_PROBLEM;
|
||||
#endif
|
||||
BedSleepingResult result = Player::startSleepInBed(x, y, z, bTestUse);
|
||||
if (result == OK)
|
||||
{
|
||||
|
|
@ -1059,12 +1063,22 @@ Player::BedSleepingResult ServerPlayer::startSleepInBed(int x, int y, int z, boo
|
|||
|
||||
void ServerPlayer::stopSleepInBed(bool forcefulWakeUp, bool updateLevelList, bool saveRespawnPoint)
|
||||
{
|
||||
#if defined(_WINDOWS64) && defined(MINECRAFT_SERVER_BUILD)
|
||||
int bedX = bedPosition ? bedPosition->x : 0;
|
||||
int bedY = bedPosition ? bedPosition->y : 0;
|
||||
int bedZ = bedPosition ? bedPosition->z : 0;
|
||||
bool wasSleeping = isSleeping();
|
||||
#endif
|
||||
if (isSleeping())
|
||||
{
|
||||
getLevel()->getTracker()->broadcastAndSend(shared_from_this(), std::make_shared<AnimatePacket>(shared_from_this(), AnimatePacket::WAKE_UP));
|
||||
}
|
||||
Player::stopSleepInBed(forcefulWakeUp, updateLevelList, saveRespawnPoint);
|
||||
if (connection != nullptr) connection->teleport(x, y, z, yRot, xRot);
|
||||
#if defined(_WINDOWS64) && defined(MINECRAFT_SERVER_BUILD)
|
||||
if (wasSleeping)
|
||||
FourKitBridge::FireBedLeave(entityId, dimension, bedX, bedY, bedZ);
|
||||
#endif
|
||||
}
|
||||
|
||||
void ServerPlayer::ride(shared_ptr<Entity> e)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue