diff options
| author | daoge_cmd <3523206925@qq.com> | 2026-03-01 12:16:08 +0800 |
|---|---|---|
| committer | daoge_cmd <3523206925@qq.com> | 2026-03-01 12:16:08 +0800 |
| commit | b691c43c44ff180d10e7d4a9afc83b98551ff586 (patch) | |
| tree | 3e9849222cbc6ba49f2f1fc6e5fe7179632c7390 /Minecraft.World/InteractPacket.cpp | |
| parent | def8cb415354ac390b7e89052a50605285f1aca9 (diff) | |
Initial commit
Diffstat (limited to 'Minecraft.World/InteractPacket.cpp')
| -rw-r--r-- | Minecraft.World/InteractPacket.cpp | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/Minecraft.World/InteractPacket.cpp b/Minecraft.World/InteractPacket.cpp new file mode 100644 index 00000000..fadeee30 --- /dev/null +++ b/Minecraft.World/InteractPacket.cpp @@ -0,0 +1,48 @@ +#include "stdafx.h" +#include <iostream> +#include "InputOutputStream.h" +#include "PacketListener.h" +#include "InteractPacket.h" + + + +const int InteractPacket::INTERACT = 0; +const int InteractPacket::ATTACK = 1; + +InteractPacket::InteractPacket() +{ + source = 0; + target = 0; + action = 0; +} + +InteractPacket::InteractPacket(int source, int target, int action) +{ + this->source = source; + this->target = target; + this->action = action; +} + +void InteractPacket::read(DataInputStream *dis) //throws IOException +{ + source = dis->readInt(); + target = dis->readInt(); + action = dis->readByte(); +} + +void InteractPacket::write(DataOutputStream *dos) // throws IOException +{ + dos->writeInt(source); + dos->writeInt(target); + dos->writeByte(action); +} + +void InteractPacket::handle(PacketListener *listener) +{ + listener->handleInteract(shared_from_this()); +} + +int InteractPacket::getEstimatedSize() +{ + return 9; +} |
