blob: 6dd6fcaece3cb51506fef4af2753c91f19f9120b (
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
|
#include "stdafx.h"
#include <iostream>
#include "InputOutputStream.h"
#include "PacketListener.h"
#include "PlayerInputPacket.h"
PlayerInputPacket::PlayerInputPacket()
{
xa = 0.0f;
ya = 0.0f;
isJumpingVar = false;
isSneakingVar = false;
xRot = 0.0f;
yRot = 0.0f;
}
PlayerInputPacket::PlayerInputPacket(float xa, float ya, bool isJumpingVar, bool isSneakingVar, float xRot, float yRot)
{
this->xa = xa;
this->ya = ya;
this->isJumpingVar = isJumpingVar;
this->isSneakingVar = isSneakingVar;
this->xRot = xRot;
this->yRot = yRot;
}
void PlayerInputPacket::read(DataInputStream *dis) //throws IOException
{
xa = dis->readFloat();
ya = dis->readFloat();
xRot = dis->readFloat();
yRot = dis->readFloat();
isJumpingVar = dis->readBoolean();
isSneakingVar = dis->readBoolean();
}
void PlayerInputPacket::write(DataOutputStream *dos) //throws IOException
{
dos->writeFloat(xa);
dos->writeFloat(ya);
dos->writeFloat(xRot);
dos->writeFloat(yRot);
dos->writeBoolean(isJumpingVar);
dos->writeBoolean(isSneakingVar);
}
void PlayerInputPacket::handle(PacketListener *listener)
{
listener->handlePlayerInput(shared_from_this());
}
int PlayerInputPacket::getEstimatedSize()
{
return 18;
}
float PlayerInputPacket::getXa()
{
return xa;
}
float PlayerInputPacket::getXRot()
{
return xRot;
}
float PlayerInputPacket::getYa()
{
return ya;
}
float PlayerInputPacket::getYRot()
{
return yRot;
}
bool PlayerInputPacket::isJumping()
{
return isJumpingVar;
}
bool PlayerInputPacket::isSneaking()
{
return isSneakingVar;
}
|