aboutsummaryrefslogtreecommitdiff
path: root/Minecraft.World/UpdateGameRuleProgressPacket.cpp
diff options
context:
space:
mode:
authordaoge_cmd <3523206925@qq.com>2026-03-01 12:16:08 +0800
committerdaoge_cmd <3523206925@qq.com>2026-03-01 12:16:08 +0800
commitb691c43c44ff180d10e7d4a9afc83b98551ff586 (patch)
tree3e9849222cbc6ba49f2f1fc6e5fe7179632c7390 /Minecraft.World/UpdateGameRuleProgressPacket.cpp
parentdef8cb415354ac390b7e89052a50605285f1aca9 (diff)
Initial commit
Diffstat (limited to 'Minecraft.World/UpdateGameRuleProgressPacket.cpp')
-rw-r--r--Minecraft.World/UpdateGameRuleProgressPacket.cpp75
1 files changed, 75 insertions, 0 deletions
diff --git a/Minecraft.World/UpdateGameRuleProgressPacket.cpp b/Minecraft.World/UpdateGameRuleProgressPacket.cpp
new file mode 100644
index 00000000..9459ed2b
--- /dev/null
+++ b/Minecraft.World/UpdateGameRuleProgressPacket.cpp
@@ -0,0 +1,75 @@
+#include "stdafx.h"
+#include "InputOutputStream.h"
+#include "PacketListener.h"
+#include "UpdateGameRuleProgressPacket.h"
+
+
+
+UpdateGameRuleProgressPacket::UpdateGameRuleProgressPacket()
+{
+ m_messageId = L"";
+ m_icon = -1;
+ m_auxValue = 0;
+ m_definitionType = ConsoleGameRules::eGameRuleType_LevelRules;
+ m_dataTag = 0;
+}
+
+UpdateGameRuleProgressPacket::UpdateGameRuleProgressPacket(ConsoleGameRules::EGameRuleType definitionType, const wstring &messageId, int icon, int auxValue, int dataTag, void *data, int dataLength)
+{
+ m_definitionType = definitionType;
+ m_messageId = messageId;
+ m_icon = icon;
+ m_auxValue = auxValue;
+ m_dataTag = dataTag;
+
+ if(dataLength > 0)
+ {
+ m_data = byteArray(dataLength);
+ memcpy(m_data.data,data,dataLength);
+ }
+ else
+ {
+ m_data = byteArray();
+ }
+}
+
+void UpdateGameRuleProgressPacket::read(DataInputStream *dis) //throws IOException
+{
+ m_definitionType = (ConsoleGameRules::EGameRuleType)dis->readInt();
+ m_messageId = readUtf(dis,64);
+ m_icon = dis->readInt();
+ m_auxValue = dis->readByte();
+ m_dataTag = dis->readInt();
+ int dataLength = dis->readInt();
+
+ if(dataLength > 0)
+ {
+ m_data = byteArray(dataLength);
+ dis->readFully(m_data);
+ }
+ else
+ {
+ m_data = byteArray();
+ }
+}
+
+void UpdateGameRuleProgressPacket::write(DataOutputStream *dos) //throws IOException
+{
+ dos->writeInt(m_definitionType);
+ writeUtf(m_messageId,dos);
+ dos->writeInt(m_icon);
+ dos->writeByte(m_auxValue);
+ dos->writeInt(m_dataTag);
+ dos->writeInt(m_data.length);
+ dos->write(m_data);
+}
+
+void UpdateGameRuleProgressPacket::handle(PacketListener *listener)
+{
+ listener->handleUpdateGameRuleProgressPacket(shared_from_this());
+}
+
+int UpdateGameRuleProgressPacket::getEstimatedSize()
+{
+ return (int)m_messageId.length() + 4 + m_data.length;
+} \ No newline at end of file