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/ContainerSetContentPacket.cpp | |
| parent | def8cb415354ac390b7e89052a50605285f1aca9 (diff) | |
Initial commit
Diffstat (limited to 'Minecraft.World/ContainerSetContentPacket.cpp')
| -rw-r--r-- | Minecraft.World/ContainerSetContentPacket.cpp | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/Minecraft.World/ContainerSetContentPacket.cpp b/Minecraft.World/ContainerSetContentPacket.cpp new file mode 100644 index 00000000..13cfebd7 --- /dev/null +++ b/Minecraft.World/ContainerSetContentPacket.cpp @@ -0,0 +1,60 @@ +#include "stdafx.h" +#include <iostream> +#include "InputOutputStream.h" +#include "net.minecraft.world.item.h" +#include "PacketListener.h" +#include "ContainerSetContentPacket.h" + + + +ContainerSetContentPacket::~ContainerSetContentPacket() +{ + delete[] items.data; +} + +ContainerSetContentPacket::ContainerSetContentPacket() +{ + containerId = 0; +} + +ContainerSetContentPacket::ContainerSetContentPacket(int containerId, vector<shared_ptr<ItemInstance> > *newItems) +{ + this->containerId = containerId; + items = ItemInstanceArray((int)newItems->size()); + for (unsigned int i = 0; i < items.length; i++) + { + shared_ptr<ItemInstance> item = newItems->at(i); + items[i] = item == NULL ? nullptr : item->copy(); + } +} + +void ContainerSetContentPacket::read(DataInputStream *dis) //throws IOException +{ + containerId = dis->readByte(); + int count = dis->readShort(); + items = ItemInstanceArray(count); + for (int i = 0; i < count; i++) + { + items[i] = readItem(dis); + } +} + +void ContainerSetContentPacket::write(DataOutputStream *dos) //throws IOException +{ + dos->writeByte(containerId); + dos->writeShort(items.length); + for (unsigned int i = 0; i < items.length; i++) + { + writeItem(items[i], dos); + } +} + +void ContainerSetContentPacket::handle(PacketListener *listener) +{ + listener->handleContainerContent(shared_from_this()); +} + +int ContainerSetContentPacket::getEstimatedSize() +{ + return 3 + items.length * 5; +} |
