Files
MinecraftConsoles/Minecraft.World/SetTimePacket.cpp

64 lines
1.1 KiB
C++
Raw Permalink Normal View History

2026-03-01 12:16:08 +08:00
#include "stdafx.h"
#include <iostream>
#include "InputOutputStream.h"
#include "PacketListener.h"
#include "SetTimePacket.h"
SetTimePacket::SetTimePacket()
2026-03-01 12:16:08 +08:00
{
gameTime = 0;
dayTime = 0;
2026-03-01 12:16:08 +08:00
}
SetTimePacket::SetTimePacket(__int64 gameTime, __int64 dayTime, bool tickDayTime)
2026-03-01 12:16:08 +08:00
{
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;
}
}*/
2026-03-01 12:16:08 +08:00
}
void SetTimePacket::read(DataInputStream *dis) //throws IOException
{
gameTime = dis->readLong();
dayTime = dis->readLong();
2026-03-01 12:16:08 +08:00
}
void SetTimePacket::write(DataOutputStream *dos) //throws IOException
2026-03-01 12:16:08 +08:00
{
dos->writeLong(gameTime);
dos->writeLong(dayTime);
2026-03-01 12:16:08 +08:00
}
void SetTimePacket::handle(PacketListener *listener)
{
listener->handleSetTime(shared_from_this());
}
int SetTimePacket::getEstimatedSize()
{
return 16;
2026-03-01 12:16:08 +08:00
}
bool SetTimePacket::canBeInvalidated()
{
return true;
}
bool SetTimePacket::isInvalidatedBy(shared_ptr<Packet> packet)
2026-03-01 12:16:08 +08:00
{
return true;
}
bool SetTimePacket::isAync()
{
return true;
}