From b691c43c44ff180d10e7d4a9afc83b98551ff586 Mon Sep 17 00:00:00 2001 From: daoge_cmd <3523206925@qq.com> Date: Sun, 1 Mar 2026 12:16:08 +0800 Subject: Initial commit --- Minecraft.World/InteractPacket.cpp | 48 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 Minecraft.World/InteractPacket.cpp (limited to 'Minecraft.World/InteractPacket.cpp') 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 +#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; +} -- cgit v1.2.3