blob: 9d688f7436d1faed85ce40dea5d17d4ed8882e6d (
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
|
#include "stdafx.h"
#include <exception>
#include <iostream>
#include "InputOutputStream.h"
#include "net.minecraft.world.entity.h"
#include "net.minecraft.world.entity.global.h"
#include "PacketListener.h"
#include "AddGlobalEntityPacket.h"
const int AddGlobalEntityPacket::LIGHTNING = 1;
AddGlobalEntityPacket::AddGlobalEntityPacket()
{
id = -1;
x = 0;
y = 0;
x = 0;
type = 0;
}
AddGlobalEntityPacket::AddGlobalEntityPacket(shared_ptr<Entity> e)
{
id = e->entityId;
x = Mth::floor(e->x * 32);
y = Mth::floor(e->y * 32);
z = Mth::floor(e->z * 32);
if ( e->instanceof(eTYPE_LIGHTNINGBOLT) )
{
type = LIGHTNING;
}
else
{
type = 0;
}
}
void AddGlobalEntityPacket::read(DataInputStream *dis) // throws IOException
{
id = dis->readInt();
type = dis->readByte();
x = dis->readInt();
y = dis->readInt();
z = dis->readInt();
}
void AddGlobalEntityPacket::write(DataOutputStream *dos) // throws IOException
{
dos->writeInt(id);
dos->writeByte(type);
dos->writeInt(x);
dos->writeInt(y);
dos->writeInt(z);
}
void AddGlobalEntityPacket::handle(PacketListener *listener)
{
listener->handleAddGlobalEntity(shared_from_this());
}
int AddGlobalEntityPacket::getEstimatedSize()
{
return 17;
}
|