aboutsummaryrefslogtreecommitdiff
path: root/Minecraft.World/PlayerInputPacket.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Minecraft.World/PlayerInputPacket.cpp')
-rw-r--r--Minecraft.World/PlayerInputPacket.cpp87
1 files changed, 87 insertions, 0 deletions
diff --git a/Minecraft.World/PlayerInputPacket.cpp b/Minecraft.World/PlayerInputPacket.cpp
new file mode 100644
index 00000000..6dd6fcae
--- /dev/null
+++ b/Minecraft.World/PlayerInputPacket.cpp
@@ -0,0 +1,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;
+}