the game where you go into mines and start crafting! but for consoles (forked directly from smartcmd's github)
1#include "stdafx.h"
2#include <iostream>
3#include "InputOutputStream.h"
4#include "PacketListener.h"
5#include "net.minecraft.world.entity.h"
6#include "PlayerCommandPacket.h"
7
8
9
10const int PlayerCommandPacket::START_SNEAKING = 1;
11const int PlayerCommandPacket::STOP_SNEAKING = 2;
12const int PlayerCommandPacket::STOP_SLEEPING = 3;
13const int PlayerCommandPacket::START_SPRINTING = 4;
14const int PlayerCommandPacket::STOP_SPRINTING = 5;
15const int PlayerCommandPacket::START_IDLEANIM = 6;
16const int PlayerCommandPacket::STOP_IDLEANIM = 7;
17const int PlayerCommandPacket::RIDING_JUMP = 8;
18const int PlayerCommandPacket::OPEN_INVENTORY = 9;
19
20
21PlayerCommandPacket::PlayerCommandPacket()
22{
23 id = -1;
24 action = 0;
25 data = 0;
26}
27
28PlayerCommandPacket::PlayerCommandPacket(shared_ptr<Entity> e, int action)
29{
30 id = e->entityId;
31 this->action = action;
32 this->data = 0;
33}
34
35PlayerCommandPacket::PlayerCommandPacket(shared_ptr<Entity> e, int action, int data)
36{
37 id = e->entityId;
38 this->action = action;
39 this->data = data;
40}
41
42void PlayerCommandPacket::read(DataInputStream *dis) //throws IOException
43{
44 id = dis->readInt();
45 action = dis->readByte();
46 data = dis->readInt();
47}
48
49void PlayerCommandPacket::write(DataOutputStream *dos) //throws IOException
50{
51 dos->writeInt(id);
52 dos->writeByte(action);
53 dos->writeInt(data);
54}
55
56void PlayerCommandPacket::handle(PacketListener *listener)
57{
58 listener->handlePlayerCommand(shared_from_this());
59}
60
61int PlayerCommandPacket::getEstimatedSize()
62{
63 return 9;
64}