aboutsummaryrefslogtreecommitdiff
path: root/Minecraft.World/SetScorePacket.cpp
diff options
context:
space:
mode:
authorLoki Rautio <lokirautio@gmail.com>2026-03-04 03:56:03 -0600
committerLoki Rautio <lokirautio@gmail.com>2026-03-04 03:56:03 -0600
commit42aec6dac53dffa6afe072560a7e1d4986112538 (patch)
tree0836426857391df1b6a83f6368a183f83ec9b104 /Minecraft.World/SetScorePacket.cpp
parentc9d58eeac7c72f0b3038e084667b4d89a6249fce (diff)
parentef9b6fd500dfabd9463267b0dd9e29577eea8a2b (diff)
Merge branch 'main' into pr/win64-world-saves
# Conflicts: # Minecraft.Client/MinecraftServer.cpp # README.md
Diffstat (limited to 'Minecraft.World/SetScorePacket.cpp')
-rw-r--r--Minecraft.World/SetScorePacket.cpp63
1 files changed, 63 insertions, 0 deletions
diff --git a/Minecraft.World/SetScorePacket.cpp b/Minecraft.World/SetScorePacket.cpp
new file mode 100644
index 00000000..75887eb5
--- /dev/null
+++ b/Minecraft.World/SetScorePacket.cpp
@@ -0,0 +1,63 @@
+#include "stdafx.h"
+#include "net.minecraft.world.entity.player.h"
+#include "net.minecraft.world.scores.h"
+#include "PacketListener.h"
+#include "SetScorePacket.h"
+
+SetScorePacket::SetScorePacket()
+{
+ owner = L"";
+ objectiveName = L"";
+ score = 0;
+ method = 0;
+}
+
+SetScorePacket::SetScorePacket(Score *score, int method)
+{
+ owner = score->getOwner();
+ objectiveName = score->getObjective()->getName();
+ this->score = score->getScore();
+ this->method = method;
+}
+
+SetScorePacket::SetScorePacket(const wstring &owner)
+{
+ this->owner = owner;
+ objectiveName = L"";
+ score = 0;
+ method = METHOD_REMOVE;
+}
+
+void SetScorePacket::read(DataInputStream *dis)
+{
+ owner = readUtf(dis, Player::MAX_NAME_LENGTH);
+ method = dis->readByte();
+
+ if (method != METHOD_REMOVE)
+ {
+ objectiveName = readUtf(dis, Objective::MAX_NAME_LENGTH);
+ score = dis->readInt();
+ }
+}
+
+void SetScorePacket::write(DataOutputStream *dos)
+{
+ writeUtf(owner, dos);
+ dos->writeByte(method);
+
+ if (method != METHOD_REMOVE)
+ {
+ writeUtf(objectiveName, dos);
+ dos->writeInt(score);
+ }
+}
+
+void SetScorePacket::handle(PacketListener *listener)
+{
+ listener->handleSetScore(shared_from_this());
+}
+
+int SetScorePacket::getEstimatedSize()
+{
+ return 2 + (owner.empty() ? 0 : owner.length()) + 2 + (objectiveName.empty() ? 0 : objectiveName.length()) + 4 + 1;
+} \ No newline at end of file