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 "net.minecraft.world.entity.h"
5#include "PacketListener.h"
6#include "TeleportEntityPacket.h"
7
8
9
10TeleportEntityPacket::TeleportEntityPacket()
11{
12 id = -1;
13 x = 0;
14 y = 0;
15 z = 0;
16 yRot = 0;
17 xRot = 0;
18}
19
20TeleportEntityPacket::TeleportEntityPacket(shared_ptr<Entity> e)
21{
22 id = e->entityId;
23 x = Mth::floor(e->x * 32);
24 y = Mth::floor(e->y * 32);
25 z = Mth::floor(e->z * 32);
26 yRot = (byte) (e->yRot * 256 / 360);
27 xRot = (byte) (e->xRot * 256 / 360);
28}
29
30TeleportEntityPacket::TeleportEntityPacket(int id, int x, int y, int z, byte yRot, byte xRot)
31{
32 this->id = id;
33 this->x = x;
34 this->y = y;
35 this->z = z;
36 this->yRot = yRot;
37 this->xRot = xRot;
38}
39
40void TeleportEntityPacket::read(DataInputStream *dis) //throws IOException
41{
42 id = dis->readShort();
43#ifdef _LARGE_WORLDS
44 x = dis->readInt();
45 y = dis->readInt();
46 z = dis->readInt();
47#else
48 x = dis->readShort();
49 y = dis->readShort();
50 z = dis->readShort();
51#endif
52 yRot = dis->readByte();
53 xRot = dis->readByte();
54}
55
56void TeleportEntityPacket::write(DataOutputStream *dos) //throws IOException
57{
58 dos->writeShort(id);
59#ifdef _LARGE_WORLDS
60 dos->writeInt(x);
61 dos->writeInt(y);
62 dos->writeInt(z);
63#else
64 dos->writeShort(x);
65 dos->writeShort(y);
66 dos->writeShort(z);
67#endif
68 dos->write(yRot);
69 dos->write(xRot);
70}
71
72void TeleportEntityPacket::handle(PacketListener *listener)
73{
74 listener->handleTeleportEntity(shared_from_this());
75}
76
77int TeleportEntityPacket::getEstimatedSize()
78{
79 return 2 + 2 + 2 + 2 + 1 + 1;
80}
81
82bool TeleportEntityPacket::canBeInvalidated()
83{
84 return true;
85}
86
87bool TeleportEntityPacket::isInvalidatedBy(shared_ptr<Packet> packet)
88{
89 shared_ptr<TeleportEntityPacket> target = dynamic_pointer_cast<TeleportEntityPacket>(packet);
90 return target->id == id;
91}