aboutsummaryrefslogtreecommitdiff
path: root/Minecraft.World/SetEntityDataPacket.cpp
blob: a49ba9d9096a2ff6fcf9916bae788c945cae42eb (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
#include "stdafx.h"
#include <iostream>
#include "InputOutputStream.h"
#include "net.minecraft.world.entity.h"
#include "PacketListener.h"
#include "SetEntityDataPacket.h"



SetEntityDataPacket::SetEntityDataPacket() 
{
	id = -1;
	packedItems = nullptr;
}

SetEntityDataPacket::~SetEntityDataPacket()
{
	delete packedItems;
}

SetEntityDataPacket::SetEntityDataPacket(int id, shared_ptr<SynchedEntityData> entityData, bool notJustDirty) 
{
	this->id = id;
	if(notJustDirty)
	{
		this->packedItems = entityData->getAll();
	}
	else
	{
		this->packedItems = entityData->packDirty();
	}
}

void SetEntityDataPacket::read(DataInputStream *dis) //throws IOException
{
	id = dis->readInt();
	packedItems = SynchedEntityData::unpack(dis);
}

void SetEntityDataPacket::write(DataOutputStream *dos) //throws IOException 
{
	dos->writeInt(id);
	SynchedEntityData::pack(packedItems, dos);
}

void SetEntityDataPacket::handle(PacketListener *listener)
{
	listener->handleSetEntityData(shared_from_this());
}

int SetEntityDataPacket::getEstimatedSize() 
{
	return 5;
}

vector<shared_ptr<SynchedEntityData::DataItem> > *SetEntityDataPacket::getUnpackedData()
{
	return packedItems;
}