aboutsummaryrefslogtreecommitdiff
path: root/Minecraft.World/SetTimePacket.cpp
blob: 5936255c08a1314e9051ef935dc002680ed2e5ee (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
#include "stdafx.h"
#include <iostream>
#include "InputOutputStream.h"
#include "PacketListener.h"
#include "SetTimePacket.h"

SetTimePacket::SetTimePacket() 
{
	gameTime = 0;
	dayTime = 0;
}

SetTimePacket::SetTimePacket(__int64 gameTime, __int64 dayTime, bool tickDayTime)
{
	this->gameTime = gameTime;
	this->dayTime = dayTime;

	// 4J: We send daylight cycle rule with host options so don't need this
	/*if (!tickDayTime)
	{
		this->dayTime = -this->dayTime;
		if (this->dayTime == 0)
		{
			this->dayTime = -1;
		}
	}*/
}

void SetTimePacket::read(DataInputStream *dis) //throws IOException
{
	gameTime = dis->readLong();
	dayTime = dis->readLong();
}

void SetTimePacket::write(DataOutputStream *dos) //throws IOException 
{
	dos->writeLong(gameTime);
	dos->writeLong(dayTime);
}

void SetTimePacket::handle(PacketListener *listener)
{
	listener->handleSetTime(shared_from_this());
}

int SetTimePacket::getEstimatedSize()
{
	return 16;
}

bool SetTimePacket::canBeInvalidated()
{
	return true;
}

bool SetTimePacket::isInvalidatedBy(shared_ptr<Packet> packet)
{
	return true;
}

bool SetTimePacket::isAync()
{
	return true;
}