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/PlayerCommandPacket.cpp | 51 +++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 Minecraft.World/PlayerCommandPacket.cpp (limited to 'Minecraft.World/PlayerCommandPacket.cpp') diff --git a/Minecraft.World/PlayerCommandPacket.cpp b/Minecraft.World/PlayerCommandPacket.cpp new file mode 100644 index 00000000..6aecc0e6 --- /dev/null +++ b/Minecraft.World/PlayerCommandPacket.cpp @@ -0,0 +1,51 @@ +#include "stdafx.h" +#include +#include "InputOutputStream.h" +#include "PacketListener.h" +#include "net.minecraft.world.entity.h" +#include "PlayerCommandPacket.h" + + + +const int PlayerCommandPacket::START_SNEAKING = 1; +const int PlayerCommandPacket::STOP_SNEAKING = 2; +const int PlayerCommandPacket::STOP_SLEEPING = 3; +const int PlayerCommandPacket::START_SPRINTING = 4; +const int PlayerCommandPacket::STOP_SPRINTING = 5; +const int PlayerCommandPacket::START_IDLEANIM = 6; +const int PlayerCommandPacket::STOP_IDLEANIM = 7; + + +PlayerCommandPacket::PlayerCommandPacket() +{ + id = -1; + action = 0; +} + +PlayerCommandPacket::PlayerCommandPacket(shared_ptr e, int action) +{ + id = e->entityId; + this->action = action; +} + +void PlayerCommandPacket::read(DataInputStream *dis) //throws IOException +{ + id = dis->readInt(); + action = dis->readByte(); +} + +void PlayerCommandPacket::write(DataOutputStream *dos) //throws IOException +{ + dos->writeInt(id); + dos->writeByte(action); +} + +void PlayerCommandPacket::handle(PacketListener *listener) +{ + listener->handlePlayerCommand(shared_from_this()); +} + +int PlayerCommandPacket::getEstimatedSize() +{ + return 5; +} -- cgit v1.2.3