aboutsummaryrefslogtreecommitdiff
path: root/Minecraft.World/PlayerCommandPacket.cpp
diff options
context:
space:
mode:
authordaoge_cmd <3523206925@qq.com>2026-03-01 12:16:08 +0800
committerdaoge_cmd <3523206925@qq.com>2026-03-01 12:16:08 +0800
commitb691c43c44ff180d10e7d4a9afc83b98551ff586 (patch)
tree3e9849222cbc6ba49f2f1fc6e5fe7179632c7390 /Minecraft.World/PlayerCommandPacket.cpp
parentdef8cb415354ac390b7e89052a50605285f1aca9 (diff)
Initial commit
Diffstat (limited to 'Minecraft.World/PlayerCommandPacket.cpp')
-rw-r--r--Minecraft.World/PlayerCommandPacket.cpp51
1 files changed, 51 insertions, 0 deletions
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 <iostream>
+#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<Entity> 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;
+}