blob: 72e34c803aff431a10c52ee04a28d4e94e32f51f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
#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;
const int PlayerCommandPacket::RIDING_JUMP = 8;
const int PlayerCommandPacket::OPEN_INVENTORY = 9;
PlayerCommandPacket::PlayerCommandPacket()
{
id = -1;
action = 0;
data = 0;
}
PlayerCommandPacket::PlayerCommandPacket(shared_ptr<Entity> e, int action)
{
id = e->entityId;
this->action = action;
this->data = 0;
}
PlayerCommandPacket::PlayerCommandPacket(shared_ptr<Entity> e, int action, int data)
{
id = e->entityId;
this->action = action;
this->data = data;
}
void PlayerCommandPacket::read(DataInputStream *dis) //throws IOException
{
id = dis->readInt();
action = dis->readByte();
data = dis->readInt();
}
void PlayerCommandPacket::write(DataOutputStream *dos) //throws IOException
{
dos->writeInt(id);
dos->writeByte(action);
dos->writeInt(data);
}
void PlayerCommandPacket::handle(PacketListener *listener)
{
listener->handlePlayerCommand(shared_from_this());
}
int PlayerCommandPacket::getEstimatedSize()
{
return 9;
}
|