diff options
| author | daoge_cmd <3523206925@qq.com> | 2026-03-01 12:16:08 +0800 |
|---|---|---|
| committer | daoge_cmd <3523206925@qq.com> | 2026-03-01 12:16:08 +0800 |
| commit | b691c43c44ff180d10e7d4a9afc83b98551ff586 (patch) | |
| tree | 3e9849222cbc6ba49f2f1fc6e5fe7179632c7390 /Minecraft.World/SetHealthPacket.cpp | |
| parent | def8cb415354ac390b7e89052a50605285f1aca9 (diff) | |
Initial commit
Diffstat (limited to 'Minecraft.World/SetHealthPacket.cpp')
| -rw-r--r-- | Minecraft.World/SetHealthPacket.cpp | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/Minecraft.World/SetHealthPacket.cpp b/Minecraft.World/SetHealthPacket.cpp new file mode 100644 index 00000000..55d7ccc3 --- /dev/null +++ b/Minecraft.World/SetHealthPacket.cpp @@ -0,0 +1,66 @@ +#include "stdafx.h" +#include <iostream> +#include "InputOutputStream.h" +#include "PacketListener.h" +#include "SetHealthPacket.h" + + + +SetHealthPacket::SetHealthPacket() +{ + this->health = 0; + this->food = 0; + this->saturation = 0; + + this->damageSource = eTelemetryChallenges_Unknown; +} + +SetHealthPacket::SetHealthPacket(int health, int food, float saturation, ETelemetryChallenges damageSource) +{ + 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 +{ + health = dis->readShort(); + food = dis->readShort(); + saturation = dis->readFloat(); + // exhaustion = dis.readFloat(); + + damageSource = (ETelemetryChallenges)dis->readByte(); +} + +void SetHealthPacket::write(DataOutputStream *dos) //throws IOException +{ + dos->writeShort(health); + dos->writeShort(food); + dos->writeFloat(saturation); + // dos.writeFloat(exhaustion); + + dos->writeByte(damageSource); +} + +void SetHealthPacket::handle(PacketListener *listener) +{ + listener->handleSetHealth(shared_from_this()); +} + +int SetHealthPacket::getEstimatedSize() +{ + return 9; +} + +bool SetHealthPacket::canBeInvalidated() +{ + return true; +} + +bool SetHealthPacket::isInvalidatedBy(shared_ptr<Packet> packet) +{ + return true; +}
\ No newline at end of file |
