Files

66 lines
1.3 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 "SetHealthPacket.h"
SetHealthPacket::SetHealthPacket()
{
this->health = 0.0f;
2026-03-01 12:16:08 +08:00
this->food = 0;
this->saturation = 0;
this->damageSource = eTelemetryChallenges_Unknown;
}
SetHealthPacket::SetHealthPacket(float health, int food, float saturation, ETelemetryChallenges damageSource)
2026-03-01 12:16:08 +08:00
{
this->health = health;
this->food = food;
this->saturation = saturation;
// this.exhaustion = exhaustion; // 4J - Original comment
this->damageSource = damageSource;
}
void SetHealthPacket::read(DataInputStream *dis) //throws IOException
2026-03-01 12:16:08 +08:00
{
health = dis->readFloat();
2026-03-01 12:16:08 +08:00
food = dis->readShort();
saturation = dis->readFloat();
// exhaustion = dis.readFloat();
damageSource = (ETelemetryChallenges)dis->readByte();
}
void SetHealthPacket::write(DataOutputStream *dos) //throws IOException
2026-03-01 12:16:08 +08:00
{
dos->writeFloat(health);
2026-03-01 12:16:08 +08:00
dos->writeShort(food);
dos->writeFloat(saturation);
// dos.writeFloat(exhaustion);
dos->writeByte(damageSource);
}
void SetHealthPacket::handle(PacketListener *listener)
2026-03-01 12:16:08 +08:00
{
listener->handleSetHealth(shared_from_this());
}
int SetHealthPacket::getEstimatedSize()
{
return 11;
2026-03-01 12:16:08 +08:00
}
bool SetHealthPacket::canBeInvalidated()
{
return true;
}
bool SetHealthPacket::isInvalidatedBy(shared_ptr<Packet> packet)
2026-03-01 12:16:08 +08:00
{
return true;
}