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/ContainerSetSlotPacket.cpp | |
| parent | def8cb415354ac390b7e89052a50605285f1aca9 (diff) | |
Initial commit
Diffstat (limited to 'Minecraft.World/ContainerSetSlotPacket.cpp')
| -rw-r--r-- | Minecraft.World/ContainerSetSlotPacket.cpp | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/Minecraft.World/ContainerSetSlotPacket.cpp b/Minecraft.World/ContainerSetSlotPacket.cpp new file mode 100644 index 00000000..42892f3c --- /dev/null +++ b/Minecraft.World/ContainerSetSlotPacket.cpp @@ -0,0 +1,53 @@ +#include "stdafx.h" +#include <iostream> +#include "InputOutputStream.h" +#include "net.minecraft.world.item.h" +#include "PacketListener.h" +#include "ContainerSetSlotPacket.h" + + + +const int ContainerSetSlotPacket::CONTAINER = 0; +const int ContainerSetSlotPacket::WORKBENCH = 1; +const int ContainerSetSlotPacket::FURNACE = 2; + +ContainerSetSlotPacket::ContainerSetSlotPacket() +{ + containerId = 0; + slot = 0; + item = nullptr; +} + +ContainerSetSlotPacket::ContainerSetSlotPacket(int containerId, int slot, shared_ptr<ItemInstance> item) +{ + this->containerId = containerId; + this->slot = slot; + this->item = item == NULL ? item : item->copy(); +} + +void ContainerSetSlotPacket::handle(PacketListener *listener) +{ + listener->handleContainerSetSlot(shared_from_this()); +} + +void ContainerSetSlotPacket::read(DataInputStream *dis) //throws IOException +{ + // 4J Stu - TU-1 hotfix + // Fix for #13142 - Holding down the A button on the furnace ingredient slot causes the UI to display incorrect item counts + BYTE byteId = dis->readByte(); + containerId = *(char *)&byteId; + slot = dis->readShort(); + item = readItem(dis); +} + +void ContainerSetSlotPacket::write(DataOutputStream *dos) //throws IOException +{ + dos->writeByte(containerId); + dos->writeShort(slot); + writeItem(item, dos); +} + +int ContainerSetSlotPacket::getEstimatedSize() +{ + return 3 + 5; +} |
