aboutsummaryrefslogtreecommitdiff
path: root/Minecraft.World/SetObjectivePacket.cpp
blob: 7e65696780eeaa8ad65610fc525f6176f22fb112 (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
#include "stdafx.h"
#include "net.minecraft.world.scores.h"
#include "PacketListener.h"
#include "SetObjectivePacket.h"

SetObjectivePacket::SetObjectivePacket()
{
	objectiveName = L"";
	displayName = L"";
	method = 0;
}

SetObjectivePacket::SetObjectivePacket(Objective *objective, int method)
{
	objectiveName = objective->getName();
	displayName = objective->getDisplayName();
	this->method = method;
}

void SetObjectivePacket::read(DataInputStream *dis)
{
	objectiveName = readUtf(dis, Objective::MAX_NAME_LENGTH);
	displayName = readUtf(dis, Objective::MAX_DISPLAY_NAME_LENGTH);
	method = dis->readByte();
}

void SetObjectivePacket::write(DataOutputStream *dos)
{
	writeUtf(objectiveName, dos);
	writeUtf(displayName, dos);
	dos->writeByte(method);
}

void SetObjectivePacket::handle(PacketListener *listener)
{
	listener->handleAddObjective(shared_from_this());
}

int SetObjectivePacket::getEstimatedSize()
{
	return 2 + objectiveName.length() + 2 + displayName.length() + 1;
}