aboutsummaryrefslogtreecommitdiff
path: root/Minecraft.World/SetCreativeModeSlotPacket.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/SetCreativeModeSlotPacket.cpp
parentdef8cb415354ac390b7e89052a50605285f1aca9 (diff)
Initial commit
Diffstat (limited to 'Minecraft.World/SetCreativeModeSlotPacket.cpp')
-rw-r--r--Minecraft.World/SetCreativeModeSlotPacket.cpp42
1 files changed, 42 insertions, 0 deletions
diff --git a/Minecraft.World/SetCreativeModeSlotPacket.cpp b/Minecraft.World/SetCreativeModeSlotPacket.cpp
new file mode 100644
index 00000000..17e36b37
--- /dev/null
+++ b/Minecraft.World/SetCreativeModeSlotPacket.cpp
@@ -0,0 +1,42 @@
+#include "stdafx.h"
+#include "InputOutputStream.h"
+#include "PacketListener.h"
+#include "SetCreativeModeSlotPacket.h"
+
+
+
+SetCreativeModeSlotPacket::SetCreativeModeSlotPacket()
+{
+ this->slotNum = 0;
+ this->item = nullptr;
+}
+
+SetCreativeModeSlotPacket::SetCreativeModeSlotPacket(int slotNum, shared_ptr<ItemInstance> item)
+{
+ this->slotNum = slotNum;
+ // 4J - take copy of item as we want our packets to have full ownership of any referenced data
+ this->item = item ? item->copy() : shared_ptr<ItemInstance>();
+}
+
+void SetCreativeModeSlotPacket::handle(PacketListener *listener)
+{
+ listener->handleSetCreativeModeSlot(shared_from_this());
+}
+
+void SetCreativeModeSlotPacket::read(DataInputStream *dis)
+{
+ slotNum = dis->readShort();
+ item = readItem(dis);
+}
+
+void SetCreativeModeSlotPacket::write(DataOutputStream *dos)
+{
+ dos->writeShort(slotNum);
+ writeItem(item, dos);
+
+}
+
+int SetCreativeModeSlotPacket::getEstimatedSize()
+{
+ return 8;
+} \ No newline at end of file