summaryrefslogtreecommitdiffstats
path: root/src/Packet.hpp
diff options
context:
space:
mode:
authorElisey Puzko <puzko.e02@gmail.com>2018-02-22 20:07:08 +0100
committerElisey Puzko <puzko.e02@gmail.com>2018-02-22 20:07:08 +0100
commit228423d91518d0b8bd1c4bf047f3d378567e00f9 (patch)
treee05f4d5ddb11794bb4eb8691e8970d063599e669 /src/Packet.hpp
parentNew event: SelectedBlockChanged (diff)
downloadAltCraft-228423d91518d0b8bd1c4bf047f3d378567e00f9.tar
AltCraft-228423d91518d0b8bd1c4bf047f3d378567e00f9.tar.gz
AltCraft-228423d91518d0b8bd1c4bf047f3d378567e00f9.tar.bz2
AltCraft-228423d91518d0b8bd1c4bf047f3d378567e00f9.tar.lz
AltCraft-228423d91518d0b8bd1c4bf047f3d378567e00f9.tar.xz
AltCraft-228423d91518d0b8bd1c4bf047f3d378567e00f9.tar.zst
AltCraft-228423d91518d0b8bd1c4bf047f3d378567e00f9.zip
Diffstat (limited to '')
-rw-r--r--src/Packet.hpp910
1 files changed, 471 insertions, 439 deletions
diff --git a/src/Packet.hpp b/src/Packet.hpp
index 1920ea6..7b18ce1 100644
--- a/src/Packet.hpp
+++ b/src/Packet.hpp
@@ -3,520 +3,520 @@
#include "Stream.hpp"
enum PacketNameLoginSB {
- LoginStart = 0x00,
- EncryptionResponse = 0x01,
+ LoginStart = 0x00,
+ EncryptionResponse = 0x01,
};
enum PacketNamePlaySB {
- TeleportConfirm = 0x00,
- TabCompleteSB,
- ChatMessageSB,
- ClientStatus,
- ClientSettings,
- ConfirmTransactionSB,
- EnchantItem,
- ClickWindow,
- CloseWindowSB,
- PluginMessageSB,
- UseEntity,
- KeepAliveSB,
- Player,
- PlayerPosition,
- PlayerPositionAndLookSB,
- PlayerLook,
- VehicleMoveSB,
- SteerBoat,
+ TeleportConfirm = 0x00,
+ TabCompleteSB,
+ ChatMessageSB,
+ ClientStatus,
+ ClientSettings,
+ ConfirmTransactionSB,
+ EnchantItem,
+ ClickWindow,
+ CloseWindowSB,
+ PluginMessageSB,
+ UseEntity,
+ KeepAliveSB,
+ Player,
+ PlayerPosition,
+ PlayerPositionAndLookSB,
+ PlayerLook,
+ VehicleMoveSB,
+ SteerBoat,
CraftRecipeRequest,
- PlayerAbilitiesSB,
- PlayerDigging,
- EntityAction,
- SteerVehicle,
- CraftingBookData,
- ResourcePackStatus,
- AdvancementTab,
- HeldItemChangeSB,
- CreativeInventoryAction,
- UpdateSign,
- AnimationSB,
- Spectate,
- PlayerBlockPlacement,
- UseItem,
+ PlayerAbilitiesSB,
+ PlayerDigging,
+ EntityAction,
+ SteerVehicle,
+ CraftingBookData,
+ ResourcePackStatus,
+ AdvancementTab,
+ HeldItemChangeSB,
+ CreativeInventoryAction,
+ UpdateSign,
+ AnimationSB,
+ Spectate,
+ PlayerBlockPlacement,
+ UseItem,
};
enum PacketNameHandshakingCB {
- Handshake = 0x00,
+ Handshake = 0x00,
};
enum PacketNameLoginCB {
- Disconnect = 0x00,
- EncryptionRequest = 0x01,
- LoginSuccess = 0x02,
- SetCompression = 0x03,
+ Disconnect = 0x00,
+ EncryptionRequest = 0x01,
+ LoginSuccess = 0x02,
+ SetCompression = 0x03,
};
enum PacketNamePlayCB {
- SpawnObject = 0x00,
- SpawnExperienceOrb,
- SpawnGlobalEntity,
- SpawnMob,
- SpawnPainting,
- SpawnPlayer,
- AnimationCB,
- Statistics,
- BlockBreakAnimation,
- UpdateBlockEntity,
- BlockAction,
- BlockChange,
- BossBar,
- ServerDifficulty,
- TabCompleteCB,
- ChatMessageCB,
- MultiBlockChange,
- ConfirmTransactionCB,
- CloseWindowCB,
- OpenWindow,
- WindowItems,
- WindowProperty,
- SetSlot,
- SetCooldown,
- PluginMessageCB,
- NamedSoundEffect,
- DisconnectPlay,
- EntityStatus,
- Explosion,
- UnloadChunk,
- ChangeGameState,
- KeepAliveCB,
- ChunkData,
- Effect,
- Particle,
- JoinGame,
- Map,
- EntityRelativeMove,
- EntityLookAndRelativeMove,
- EntityLook,
- EntityCB,
- VehicleMove,
- OpenSignEditor,
+ SpawnObject = 0x00,
+ SpawnExperienceOrb,
+ SpawnGlobalEntity,
+ SpawnMob,
+ SpawnPainting,
+ SpawnPlayer,
+ AnimationCB,
+ Statistics,
+ BlockBreakAnimation,
+ UpdateBlockEntity,
+ BlockAction,
+ BlockChange,
+ BossBar,
+ ServerDifficulty,
+ TabCompleteCB,
+ ChatMessageCB,
+ MultiBlockChange,
+ ConfirmTransactionCB,
+ CloseWindowCB,
+ OpenWindow,
+ WindowItems,
+ WindowProperty,
+ SetSlot,
+ SetCooldown,
+ PluginMessageCB,
+ NamedSoundEffect,
+ DisconnectPlay,
+ EntityStatus,
+ Explosion,
+ UnloadChunk,
+ ChangeGameState,
+ KeepAliveCB,
+ ChunkData,
+ Effect,
+ Particle,
+ JoinGame,
+ Map,
+ EntityRelativeMove,
+ EntityLookAndRelativeMove,
+ EntityLook,
+ EntityCB,
+ VehicleMove,
+ OpenSignEditor,
CraftRecipeResponse,
- PlayerAbilitiesCB,
- CombatEvent,
- PlayerListItem,
- PlayerPositionAndLookCB,
- UseBed,
- UnlockRecipes,
- DestroyEntities,
- RemoveEntityEffect,
- ResourcePackSend,
- Respawn,
- EntityHeadLook,
- SelectAdvancementTab,
- WorldBorder,
- Camera,
- HeldItemChangeCB,
- DisplayScoreboard,
- EntityMetadata,
- AttachEntity,
- EntityVelocity,
- EntityEquipment,
- SetExperience,
- UpdateHealth,
- ScoreboardObjective,
- SetPassengers,
- Teams,
- UpdateScore,
- SpawnPosition,
- TimeUpdate,
- Title,
- SoundEffect,
- PlayerListHeaderAndFooter,
- CollectItem,
- EntityTeleport,
- Advancements,
- EntityProperties,
- EntityEffect,
+ PlayerAbilitiesCB,
+ CombatEvent,
+ PlayerListItem,
+ PlayerPositionAndLookCB,
+ UseBed,
+ UnlockRecipes,
+ DestroyEntities,
+ RemoveEntityEffect,
+ ResourcePackSend,
+ Respawn,
+ EntityHeadLook,
+ SelectAdvancementTab,
+ WorldBorder,
+ Camera,
+ HeldItemChangeCB,
+ DisplayScoreboard,
+ EntityMetadata,
+ AttachEntity,
+ EntityVelocity,
+ EntityEquipment,
+ SetExperience,
+ UpdateHealth,
+ ScoreboardObjective,
+ SetPassengers,
+ Teams,
+ UpdateScore,
+ SpawnPosition,
+ TimeUpdate,
+ Title,
+ SoundEffect,
+ PlayerListHeaderAndFooter,
+ CollectItem,
+ EntityTeleport,
+ Advancements,
+ EntityProperties,
+ EntityEffect,
};
struct Packet {
- virtual ~Packet() = default;
- virtual void ToStream(StreamOutput *stream) = 0;
- virtual void FromStream(StreamInput *stream) = 0;
- virtual int GetPacketId() = 0;
+ virtual ~Packet() = default;
+ virtual void ToStream(StreamOutput *stream) = 0;
+ virtual void FromStream(StreamInput *stream) = 0;
+ virtual int GetPacketId() = 0;
};
struct PacketHandshake : Packet {
- void ToStream(StreamOutput *stream) override {
- stream->WriteVarInt(protocolVersion);
- stream->WriteString(serverAddress);
- stream->WriteUShort(serverPort);
- stream->WriteVarInt(nextState);
- }
-
- void FromStream(StreamInput *stream) override {
- protocolVersion = stream->ReadVarInt();
- serverAddress = stream->ReadString();
- serverPort = stream->ReadUShort();
- nextState = stream->ReadVarInt();
- }
-
- int GetPacketId() override {
- return PacketNameHandshakingCB::Handshake;
- }
-
- int protocolVersion;
- std::string serverAddress;
- unsigned short serverPort;
- int nextState;
+ void ToStream(StreamOutput *stream) override {
+ stream->WriteVarInt(protocolVersion);
+ stream->WriteString(serverAddress);
+ stream->WriteUShort(serverPort);
+ stream->WriteVarInt(nextState);
+ }
+
+ void FromStream(StreamInput *stream) override {
+ protocolVersion = stream->ReadVarInt();
+ serverAddress = stream->ReadString();
+ serverPort = stream->ReadUShort();
+ nextState = stream->ReadVarInt();
+ }
+
+ int GetPacketId() override {
+ return PacketNameHandshakingCB::Handshake;
+ }
+
+ int protocolVersion;
+ std::string serverAddress;
+ unsigned short serverPort;
+ int nextState;
};
struct PacketLoginStart : Packet {
- void ToStream(StreamOutput *stream) override {
- stream->WriteString(Username);
- }
+ void ToStream(StreamOutput *stream) override {
+ stream->WriteString(Username);
+ }
- void FromStream(StreamInput *stream) override {
- Username = stream->ReadString();
- }
+ void FromStream(StreamInput *stream) override {
+ Username = stream->ReadString();
+ }
- int GetPacketId() override {
- return PacketNameLoginSB::LoginStart;
- }
+ int GetPacketId() override {
+ return PacketNameLoginSB::LoginStart;
+ }
- std::string Username;
+ std::string Username;
};
struct PacketLoginSuccess : Packet {
- void ToStream(StreamOutput *stream) override {
- stream->WriteString(Uuid);
- stream->WriteString(Username);
- }
-
- void FromStream(StreamInput *stream) override {
- Uuid = stream->ReadString();
- Username = stream->ReadString();
- }
-
- int GetPacketId() override {
- return PacketNameLoginCB::LoginSuccess;
- }
-
- std::string Uuid;
- std::string Username;
+ void ToStream(StreamOutput *stream) override {
+ stream->WriteString(Uuid);
+ stream->WriteString(Username);
+ }
+
+ void FromStream(StreamInput *stream) override {
+ Uuid = stream->ReadString();
+ Username = stream->ReadString();
+ }
+
+ int GetPacketId() override {
+ return PacketNameLoginCB::LoginSuccess;
+ }
+
+ std::string Uuid;
+ std::string Username;
};
struct PacketJoinGame : Packet {
- void ToStream(StreamOutput *stream) override {
- stream->WriteInt(EntityId);
- stream->WriteUByte(Gamemode);
- stream->WriteInt(Dimension);
- stream->WriteUByte(Difficulty);
- stream->WriteUByte(MaxPlayers);
- stream->WriteString(LevelType);
- stream->WriteBool(ReducedDebugInfo);
- }
-
- void FromStream(StreamInput *stream) override {
- EntityId = stream->ReadInt();
- Gamemode = stream->ReadUByte();
- Dimension = stream->ReadInt();
- Difficulty = stream->ReadUByte();
- MaxPlayers = stream->ReadUByte();
- LevelType = stream->ReadString();
- ReducedDebugInfo = stream->ReadBool();
- }
-
- int GetPacketId() override {
- return PacketNamePlayCB::JoinGame;
- }
-
- int EntityId;
- unsigned char Gamemode;
- int Dimension;
- unsigned char Difficulty;
- unsigned char MaxPlayers;
- std::string LevelType;
- bool ReducedDebugInfo;
+ void ToStream(StreamOutput *stream) override {
+ stream->WriteInt(EntityId);
+ stream->WriteUByte(Gamemode);
+ stream->WriteInt(Dimension);
+ stream->WriteUByte(Difficulty);
+ stream->WriteUByte(MaxPlayers);
+ stream->WriteString(LevelType);
+ stream->WriteBool(ReducedDebugInfo);
+ }
+
+ void FromStream(StreamInput *stream) override {
+ EntityId = stream->ReadInt();
+ Gamemode = stream->ReadUByte();
+ Dimension = stream->ReadInt();
+ Difficulty = stream->ReadUByte();
+ MaxPlayers = stream->ReadUByte();
+ LevelType = stream->ReadString();
+ ReducedDebugInfo = stream->ReadBool();
+ }
+
+ int GetPacketId() override {
+ return PacketNamePlayCB::JoinGame;
+ }
+
+ int EntityId;
+ unsigned char Gamemode;
+ int Dimension;
+ unsigned char Difficulty;
+ unsigned char MaxPlayers;
+ std::string LevelType;
+ bool ReducedDebugInfo;
};
struct PacketDisconnectPlay : Packet {
- void ToStream(StreamOutput *stream) override {
- stream->WriteString(Reason); //TODO: Implement chat-wrapper
- }
+ void ToStream(StreamOutput *stream) override {
+ stream->WriteString(Reason); //TODO: Implement chat-wrapper
+ }
- void FromStream(StreamInput *stream) override {
- Reason = stream->ReadChat().text;
- }
+ void FromStream(StreamInput *stream) override {
+ Reason = stream->ReadChat().text;
+ }
- int GetPacketId() override {
- return PacketNamePlayCB::DisconnectPlay;
- }
+ int GetPacketId() override {
+ return PacketNamePlayCB::DisconnectPlay;
+ }
- std::string Reason;
+ std::string Reason;
};
struct PacketSpawnPosition : Packet {
- void ToStream(StreamOutput *stream) override {
- stream->WritePosition(Location);
- }
+ void ToStream(StreamOutput *stream) override {
+ stream->WritePosition(Location);
+ }
- void FromStream(StreamInput *stream) override {
- Location = stream->ReadPosition();
- }
+ void FromStream(StreamInput *stream) override {
+ Location = stream->ReadPosition();
+ }
- int GetPacketId() override {
- return PacketNamePlayCB::SpawnPosition;
- }
+ int GetPacketId() override {
+ return PacketNamePlayCB::SpawnPosition;
+ }
- Vector Location;
+ Vector Location;
};
struct PacketKeepAliveCB : Packet {
- void ToStream(StreamOutput *stream) override {
- stream->WriteLong(KeepAliveId);
- }
+ void ToStream(StreamOutput *stream) override {
+ stream->WriteLong(KeepAliveId);
+ }
- void FromStream(StreamInput *stream) override {
- KeepAliveId = stream->ReadLong();
- }
+ void FromStream(StreamInput *stream) override {
+ KeepAliveId = stream->ReadLong();
+ }
- int GetPacketId() override {
- return PacketNamePlayCB::KeepAliveCB;
- }
+ int GetPacketId() override {
+ return PacketNamePlayCB::KeepAliveCB;
+ }
- long long KeepAliveId;
+ long long KeepAliveId;
};
struct PacketKeepAliveSB : Packet {
- void ToStream(StreamOutput *stream) override {
- stream->WriteLong(KeepAliveId);
- }
+ void ToStream(StreamOutput *stream) override {
+ stream->WriteLong(KeepAliveId);
+ }
- void FromStream(StreamInput *stream) override {
- KeepAliveId = stream->ReadLong();
- }
+ void FromStream(StreamInput *stream) override {
+ KeepAliveId = stream->ReadLong();
+ }
- int GetPacketId() override {
- return PacketNamePlaySB::KeepAliveSB;
- }
+ int GetPacketId() override {
+ return PacketNamePlaySB::KeepAliveSB;
+ }
- long long KeepAliveId;
+ long long KeepAliveId;
- PacketKeepAliveSB(int KeepAliveId) : KeepAliveId(KeepAliveId) {}
+ PacketKeepAliveSB(int KeepAliveId) : KeepAliveId(KeepAliveId) {}
};
struct PacketPlayerPositionAndLookCB : Packet {
- void ToStream(StreamOutput *stream) override {
- stream->WriteDouble(X);
- stream->WriteDouble(Y);
- stream->WriteDouble(Z);
- stream->WriteFloat(Yaw);
- stream->WriteFloat(Pitch);
- stream->WriteUByte(Flags);
- stream->WriteVarInt(TeleportId);
- }
-
- void FromStream(StreamInput *stream) override {
- X = stream->ReadDouble();
- Y = stream->ReadDouble();
- Z = stream->ReadDouble();
- Yaw = stream->ReadFloat();
- Pitch = stream->ReadFloat();
- Flags = stream->ReadUByte();
- TeleportId = stream->ReadVarInt();
- }
-
- int GetPacketId() override {
- return PacketNamePlayCB::PlayerPositionAndLookCB;
- }
-
- double X;
- double Y;
- double Z;
- float Yaw;
- float Pitch;
- unsigned char Flags;
- int TeleportId;
+ void ToStream(StreamOutput *stream) override {
+ stream->WriteDouble(X);
+ stream->WriteDouble(Y);
+ stream->WriteDouble(Z);
+ stream->WriteFloat(Yaw);
+ stream->WriteFloat(Pitch);
+ stream->WriteUByte(Flags);
+ stream->WriteVarInt(TeleportId);
+ }
+
+ void FromStream(StreamInput *stream) override {
+ X = stream->ReadDouble();
+ Y = stream->ReadDouble();
+ Z = stream->ReadDouble();
+ Yaw = stream->ReadFloat();
+ Pitch = stream->ReadFloat();
+ Flags = stream->ReadUByte();
+ TeleportId = stream->ReadVarInt();
+ }
+
+ int GetPacketId() override {
+ return PacketNamePlayCB::PlayerPositionAndLookCB;
+ }
+
+ double X;
+ double Y;
+ double Z;
+ float Yaw;
+ float Pitch;
+ unsigned char Flags;
+ int TeleportId;
};
struct PacketTeleportConfirm : Packet {
- void ToStream(StreamOutput *stream) override {
- stream->WriteVarInt(TeleportId);
- }
+ void ToStream(StreamOutput *stream) override {
+ stream->WriteVarInt(TeleportId);
+ }
- void FromStream(StreamInput *stream) override {
- TeleportId = stream->ReadVarInt();
- }
+ void FromStream(StreamInput *stream) override {
+ TeleportId = stream->ReadVarInt();
+ }
- int GetPacketId() override {
- return PacketNamePlaySB::TeleportConfirm;
- }
+ int GetPacketId() override {
+ return PacketNamePlaySB::TeleportConfirm;
+ }
- int TeleportId;
+ int TeleportId;
- PacketTeleportConfirm(int TeleportId) : TeleportId(TeleportId) {}
+ PacketTeleportConfirm(int TeleportId) : TeleportId(TeleportId) {}
};
struct PacketClientStatus : Packet {
- void ToStream(StreamOutput *stream) override {
- stream->WriteVarInt(ActionId);
- }
+ void ToStream(StreamOutput *stream) override {
+ stream->WriteVarInt(ActionId);
+ }
- void FromStream(StreamInput *stream) override {
- ActionId = stream->ReadVarInt();
- }
+ void FromStream(StreamInput *stream) override {
+ ActionId = stream->ReadVarInt();
+ }
- int GetPacketId() override {
- return PacketNamePlaySB::ClientStatus;
- }
+ int GetPacketId() override {
+ return PacketNamePlaySB::ClientStatus;
+ }
- int ActionId;
+ int ActionId;
- PacketClientStatus(int ActionId) : ActionId(ActionId) {}
+ PacketClientStatus(int ActionId) : ActionId(ActionId) {}
};
struct PacketPlayerPositionAndLookSB : Packet {
- void ToStream(StreamOutput *stream) override {
- stream->WriteDouble(X);
- stream->WriteDouble(FeetY);
- stream->WriteDouble(Z);
- stream->WriteFloat(Yaw);
- stream->WriteFloat(Pitch);
- stream->WriteBool(OnGround);
- }
-
- void FromStream(StreamInput *stream) override {
- X = stream->ReadDouble();
- FeetY = stream->ReadDouble();
- Z = stream->ReadDouble();
- Yaw = stream->ReadFloat();
- Pitch = stream->ReadFloat();
- OnGround = stream->ReadBool();
- }
-
- int GetPacketId() override {
- return PacketNamePlaySB::PlayerPositionAndLookSB;
- }
-
-
- double X;
- double FeetY;
- double Z;
- float Yaw;
- float Pitch;
- bool OnGround;
-
- PacketPlayerPositionAndLookSB(double X, double FeetY, double Z,
- float Yaw, float Pitch, bool OnGround) : X(X), FeetY(FeetY), Z(Z), Yaw(Yaw),
- Pitch(Pitch), OnGround(OnGround) {}
+ void ToStream(StreamOutput *stream) override {
+ stream->WriteDouble(X);
+ stream->WriteDouble(FeetY);
+ stream->WriteDouble(Z);
+ stream->WriteFloat(Yaw);
+ stream->WriteFloat(Pitch);
+ stream->WriteBool(OnGround);
+ }
+
+ void FromStream(StreamInput *stream) override {
+ X = stream->ReadDouble();
+ FeetY = stream->ReadDouble();
+ Z = stream->ReadDouble();
+ Yaw = stream->ReadFloat();
+ Pitch = stream->ReadFloat();
+ OnGround = stream->ReadBool();
+ }
+
+ int GetPacketId() override {
+ return PacketNamePlaySB::PlayerPositionAndLookSB;
+ }
+
+
+ double X;
+ double FeetY;
+ double Z;
+ float Yaw;
+ float Pitch;
+ bool OnGround;
+
+ PacketPlayerPositionAndLookSB(double X, double FeetY, double Z,
+ float Yaw, float Pitch, bool OnGround) : X(X), FeetY(FeetY), Z(Z), Yaw(Yaw),
+ Pitch(Pitch), OnGround(OnGround) {}
};
struct PacketChunkData : Packet {
- void ToStream(StreamOutput *stream) override {
- stream->WriteInt(ChunkX);
- stream->WriteInt(ChunkZ);
- stream->WriteBool(GroundUpContinuous);
- stream->WriteInt(PrimaryBitMask);
- stream->WriteVarInt(Data.size());
- stream->WriteByteArray(Data);
- stream->WriteVarInt(BlockEntities.size());
- //LOG(FATAL) << "Serializing unimplemented packet";
- }
-
- void FromStream(StreamInput *stream) override {
- ChunkX = stream->ReadInt();
- ChunkZ = stream->ReadInt();
- GroundUpContinuous = stream->ReadBool();
- PrimaryBitMask = stream->ReadVarInt();
- int Size = stream->ReadVarInt();
- Data = stream->ReadByteArray(Size);
- int NumberOfBlockEntities = stream->ReadVarInt(); //TODO: Need NBT
- for (int i = 0; i < NumberOfBlockEntities; i++) {
- //BlockEntities[i] = stream->ReadNbt();
- }
- }
-
- int GetPacketId() override {
- return PacketNamePlayCB::ChunkData;
- }
-
- int ChunkX;
- int ChunkZ;
- bool GroundUpContinuous;
- int PrimaryBitMask;
- //int Size;
- std::vector<unsigned char> Data;
- //int NumberOfBlockEntities;
- std::vector<int> BlockEntities; //TODO: Replace int with NbtTag and implement NbtTree
+ void ToStream(StreamOutput *stream) override {
+ stream->WriteInt(ChunkX);
+ stream->WriteInt(ChunkZ);
+ stream->WriteBool(GroundUpContinuous);
+ stream->WriteInt(PrimaryBitMask);
+ stream->WriteVarInt(Data.size());
+ stream->WriteByteArray(Data);
+ stream->WriteVarInt(BlockEntities.size());
+ //LOG(FATAL) << "Serializing unimplemented packet";
+ }
+
+ void FromStream(StreamInput *stream) override {
+ ChunkX = stream->ReadInt();
+ ChunkZ = stream->ReadInt();
+ GroundUpContinuous = stream->ReadBool();
+ PrimaryBitMask = stream->ReadVarInt();
+ int Size = stream->ReadVarInt();
+ Data = stream->ReadByteArray(Size);
+ int NumberOfBlockEntities = stream->ReadVarInt(); //TODO: Need NBT
+ for (int i = 0; i < NumberOfBlockEntities; i++) {
+ //BlockEntities[i] = stream->ReadNbt();
+ }
+ }
+
+ int GetPacketId() override {
+ return PacketNamePlayCB::ChunkData;
+ }
+
+ int ChunkX;
+ int ChunkZ;
+ bool GroundUpContinuous;
+ int PrimaryBitMask;
+ //int Size;
+ std::vector<unsigned char> Data;
+ //int NumberOfBlockEntities;
+ std::vector<int> BlockEntities; //TODO: Replace int with NbtTag and implement NbtTree
};
struct PacketPlayerPosition : Packet {
- void ToStream(StreamOutput *stream) override {
- stream->WriteDouble(X);
- stream->WriteDouble(FeetY);
- stream->WriteDouble(Z);
- stream->WriteBool(OnGround);
- }
-
- void FromStream(StreamInput *stream) override {
- X = stream->ReadDouble();
- FeetY = stream->ReadDouble();
- Z = stream->ReadDouble();
- OnGround = stream->ReadBool();
- }
-
- int GetPacketId() override {
- return PacketNamePlaySB::PlayerPosition;
- }
-
- double X;
- double FeetY;
- double Z;
- bool OnGround;
-
- PacketPlayerPosition(double X, double Y, double Z, bool ground) : X(X), FeetY(Y), Z(Z), OnGround(ground) {}
+ void ToStream(StreamOutput *stream) override {
+ stream->WriteDouble(X);
+ stream->WriteDouble(FeetY);
+ stream->WriteDouble(Z);
+ stream->WriteBool(OnGround);
+ }
+
+ void FromStream(StreamInput *stream) override {
+ X = stream->ReadDouble();
+ FeetY = stream->ReadDouble();
+ Z = stream->ReadDouble();
+ OnGround = stream->ReadBool();
+ }
+
+ int GetPacketId() override {
+ return PacketNamePlaySB::PlayerPosition;
+ }
+
+ double X;
+ double FeetY;
+ double Z;
+ bool OnGround;
+
+ PacketPlayerPosition(double X, double Y, double Z, bool ground) : X(X), FeetY(Y), Z(Z), OnGround(ground) {}
};
struct PacketPlayerLook : Packet {
- void ToStream(StreamOutput *stream) override {
- stream->WriteFloat(Yaw);
- stream->WriteFloat(Pitch);
- stream->WriteBool(OnGround);
- }
-
- void FromStream(StreamInput *stream) override {
- Yaw = stream->ReadFloat();
- Pitch = stream->ReadFloat();
- OnGround = stream->ReadBool();
- }
-
- int GetPacketId() override {
- return PacketNamePlaySB::PlayerLook;
- }
-
- float Yaw;
- float Pitch;
- bool OnGround;
-
- PacketPlayerLook(float Yaw, float Pitch, bool ground) : Yaw(Yaw), Pitch(Pitch), OnGround(ground) {}
+ void ToStream(StreamOutput *stream) override {
+ stream->WriteFloat(Yaw);
+ stream->WriteFloat(Pitch);
+ stream->WriteBool(OnGround);
+ }
+
+ void FromStream(StreamInput *stream) override {
+ Yaw = stream->ReadFloat();
+ Pitch = stream->ReadFloat();
+ OnGround = stream->ReadBool();
+ }
+
+ int GetPacketId() override {
+ return PacketNamePlaySB::PlayerLook;
+ }
+
+ float Yaw;
+ float Pitch;
+ bool OnGround;
+
+ PacketPlayerLook(float Yaw, float Pitch, bool ground) : Yaw(Yaw), Pitch(Pitch), OnGround(ground) {}
};
struct PacketUpdateHealth : Packet {
- void ToStream(StreamOutput *stream) override {
- stream->WriteFloat(Health);
- stream->WriteVarInt(Food);
- stream->WriteFloat(FoodSaturation);
- }
-
- void FromStream(StreamInput *stream) override {
- Health = stream->ReadFloat();
- Food = stream->ReadVarInt();
- FoodSaturation = stream->ReadFloat();
- }
-
- int GetPacketId() override {
- return PacketNamePlayCB::UpdateHealth;
- }
-
- float Health;
- int Food;
- float FoodSaturation;
+ void ToStream(StreamOutput *stream) override {
+ stream->WriteFloat(Health);
+ stream->WriteVarInt(Food);
+ stream->WriteFloat(FoodSaturation);
+ }
+
+ void FromStream(StreamInput *stream) override {
+ Health = stream->ReadFloat();
+ Food = stream->ReadVarInt();
+ FoodSaturation = stream->ReadFloat();
+ }
+
+ int GetPacketId() override {
+ return PacketNamePlayCB::UpdateHealth;
+ }
+
+ float Health;
+ int Food;
+ float FoodSaturation;
};
struct PacketSpawnObject : Packet {
@@ -1095,23 +1095,55 @@ struct PacketChatMessageSB : Packet {
};
struct PacketPlayerDigging : Packet {
- void ToStream(StreamOutput *stream) override {
+ void ToStream(StreamOutput *stream) override {
stream->WriteVarInt(Status);
stream->WritePosition(Location);
stream->WriteByte(Face);
- }
+ }
- void FromStream(StreamInput *stream) override {
+ void FromStream(StreamInput *stream) override {
- }
+ }
- int GetPacketId() override {
- return PacketNamePlaySB::PlayerDigging;
- }
+ int GetPacketId() override {
+ return PacketNamePlaySB::PlayerDigging;
+ }
+
+ int Status;
+ Vector Location;
+ signed char Face;
+
+ PacketPlayerDigging(int status, const Vector& location, signed char face) : Status(status),Location(location),Face(face) {};
+};
+
+struct PacketPlayerBlockPlacement : Packet {
+ void ToStream(StreamOutput *stream) override {
+ stream->WritePosition(location);
+ stream->WriteByte(face);
+ stream->WriteByte(hand);
+ stream->WriteFloat(cursorPositionX);
+ stream->WriteFloat(cursorPositionY);
+ stream->WriteFloat(cursorPositionZ);
+ }
+
+ void FromStream(StreamInput *stream) override {
+
+ }
+
+ int GetPacketId() override {
+ return PacketNamePlaySB::PlayerBlockPlacement;
+ }
- int Status;
- Vector Location;
- signed char Face;
+ PacketPlayerBlockPlacement(
+ const Vector& location, signed char face, unsigned char hand,
+ float cursorPositionX, float cursorPositionY, float cursorPositionZ)
+ : location(location), face(face), hand(hand), cursorPositionX(cursorPositionX),
+ cursorPositionY(cursorPositionY), cursorPositionZ(cursorPositionZ) {};
- PacketPlayerDigging(int status, const Vector& location, signed char face) : Status(status),Location(location),Face(face) {};
+ Vector location;
+ signed char face;
+ unsigned char hand;
+ float cursorPositionX;
+ float cursorPositionY;
+ float cursorPositionZ;
}; \ No newline at end of file