Files
MinecraftConsoles/Minecraft.World/PlayerInfoPacket.cpp
ModMaker101 a9be52c41a Project modernization (#630)
* Fixed boats falling and a TP glitch #266

* Replaced every C-style cast with C++ ones

* Replaced every C-style cast with C++ ones

* Fixed boats falling and a TP glitch #266

* Updated NULL to nullptr and fixing some type issues

* Modernized and fixed a few bugs

- Replaced most instances of `NULL` with `nullptr`.
- Replaced most `shared_ptr(new ...)` with `make_shared`.
- Removed the `nullptr` macro as it was interfering with the actual nullptr keyword in some instances.

* Fixing more conflicts

* Replace int loops with size_t and start work on overrides
2026-03-08 09:56:03 +07:00

61 lines
1.6 KiB
C++

#include "stdafx.h"
#include "net.minecraft.world.entity.player.h"
#include "..\Minecraft.Client\ServerPlayer.h"
#include "..\Minecraft.Client\PlayerConnection.h"
#include <qnet.h>
#include "PacketListener.h"
#include "InputOutputStream.h"
#include "PlayerInfoPacket.h"
PlayerInfoPacket::PlayerInfoPacket()
{
m_networkSmallId = 0;
m_playerColourIndex = -1;
m_playerPrivileges = 0;
m_entityId = -1;
}
PlayerInfoPacket::PlayerInfoPacket(BYTE networkSmallId, short playerColourIndex, unsigned int playerPrivileges)
{
m_networkSmallId = networkSmallId;
m_playerColourIndex = playerColourIndex;
m_playerPrivileges = playerPrivileges;
m_entityId = -1;
}
PlayerInfoPacket::PlayerInfoPacket(shared_ptr<ServerPlayer> player)
{
m_networkSmallId = 0;
if(player->connection != nullptr && player->connection->getNetworkPlayer() != nullptr) m_networkSmallId = player->connection->getNetworkPlayer()->GetSmallId();
m_playerColourIndex = player->getPlayerIndex();
m_playerPrivileges = player->getAllPlayerGamePrivileges();
m_entityId = player->entityId;
}
void PlayerInfoPacket::read(DataInputStream *dis)
{
m_networkSmallId = dis->readByte();
m_playerColourIndex = dis->readShort();
m_playerPrivileges = dis->readInt();
m_entityId = dis->readInt();
}
void PlayerInfoPacket::write(DataOutputStream *dos)
{
dos->writeByte(m_networkSmallId);
dos->writeShort(m_playerColourIndex);
dos->writeInt(m_playerPrivileges);
dos->writeInt(m_entityId);
}
void PlayerInfoPacket::handle(PacketListener *listener)
{
listener->handlePlayerInfo(shared_from_this());
}
int PlayerInfoPacket::getEstimatedSize()
{
return 2 + 2 + 4 + 4;
}