diff options
author | LaG1924 <12997935+LaG1924@users.noreply.github.com> | 2017-04-15 12:17:53 +0200 |
---|---|---|
committer | LaG1924 <12997935+LaG1924@users.noreply.github.com> | 2017-04-15 12:17:53 +0200 |
commit | 2ee0f834487cfe4b6bd9424ca2715685a8db16e4 (patch) | |
tree | 6867718d6bfcd42f6a82c86dd8f149d6ea6cab68 /PacketBuilder.cpp | |
download | AltCraft-2ee0f834487cfe4b6bd9424ca2715685a8db16e4.tar AltCraft-2ee0f834487cfe4b6bd9424ca2715685a8db16e4.tar.gz AltCraft-2ee0f834487cfe4b6bd9424ca2715685a8db16e4.tar.bz2 AltCraft-2ee0f834487cfe4b6bd9424ca2715685a8db16e4.tar.lz AltCraft-2ee0f834487cfe4b6bd9424ca2715685a8db16e4.tar.xz AltCraft-2ee0f834487cfe4b6bd9424ca2715685a8db16e4.tar.zst AltCraft-2ee0f834487cfe4b6bd9424ca2715685a8db16e4.zip |
Diffstat (limited to 'PacketBuilder.cpp')
-rw-r--r-- | PacketBuilder.cpp | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/PacketBuilder.cpp b/PacketBuilder.cpp new file mode 100644 index 0000000..4083ea3 --- /dev/null +++ b/PacketBuilder.cpp @@ -0,0 +1,65 @@ +#include "PacketBuilder.hpp" + +Packet PacketBuilder::CHandshaking0x00(int protocolVerison, std::string address, unsigned short port, int nextState) { + Packet handshakePacket(0); + Field fProtocol; + fProtocol.SetVarInt(protocolVerison); + Field fAddress; + fAddress.SetString(address); + Field fPort; + fPort.SetUShort(port); + Field fNextState; + fNextState.SetVarInt(nextState); + handshakePacket.AddField(fProtocol); + handshakePacket.AddField(fAddress); + handshakePacket.AddField(fPort); + handshakePacket.AddField(fNextState); + return handshakePacket; +} + +Packet PacketBuilder::CPlay0x0B(int keepAliveId) { + Packet keepAlivePacket(0x0B); + Field fKeepAlive; + fKeepAlive.SetVarInt(keepAliveId); + keepAlivePacket.AddField(fKeepAlive); + return keepAlivePacket; +} + +Packet PacketBuilder::CPlay0x03(int actionId) { + Packet clientStatusPacket(0x03); + Field fActionId; + fActionId.SetVarInt(actionId); + clientStatusPacket.AddField(fActionId); + return clientStatusPacket; +} + +Packet PacketBuilder::CPlay0x00(int teleportId) { + Packet teleportConfirmPacket(0x00); + Field fTeleportId; + fTeleportId.SetVarInt(teleportId); + teleportConfirmPacket.AddField(fTeleportId); + return teleportConfirmPacket; +} + +Packet PacketBuilder::CPlay0x0D(double x, double y, double z, float yaw, float pitch, bool onGround) { + Packet playerPositionAndLookPacket(0x0D); + Field fX; + Field fY; + Field fZ; + Field fYaw; + Field fPitch; + Field fOnGround; + fX.SetDouble(x); + fY.SetDouble(y); + fZ.SetDouble(z); + fYaw.SetFloat(yaw); + fPitch.SetFloat(pitch); + fOnGround.SetBool(onGround); + playerPositionAndLookPacket.AddField(fX); + playerPositionAndLookPacket.AddField(fY); + playerPositionAndLookPacket.AddField(fZ); + playerPositionAndLookPacket.AddField(fYaw); + playerPositionAndLookPacket.AddField(fPitch); + playerPositionAndLookPacket.AddField(fOnGround); + return playerPositionAndLookPacket; +} |