blob: a97121831fcab75e197381f9f8cf2f9e31cdf8e0 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
#include "stdafx.h"
#include <iostream>
#include "InputOutputStream.h"
#include "net.minecraft.world.item.h"
#include "PacketListener.h"
#include "ContainerClickPacket.h"
ContainerClickPacket::~ContainerClickPacket()
{
}
ContainerClickPacket::ContainerClickPacket()
{
containerId = 0;
slotNum = 0;
buttonNum = 0;
uid = 0;
item = nullptr;
clickType = 0;
}
ContainerClickPacket::ContainerClickPacket(int containerId, int slotNum, int buttonNum, int clickType, shared_ptr<ItemInstance> item, short uid)
{
this->containerId = containerId;
this->slotNum = slotNum;
this->buttonNum = buttonNum;
this->uid = uid;
this->clickType = clickType;
// 4J - make a copy of the relevant bits of this item, as we want our packets to have full ownership of any data they reference
this->item = item ? item->copy() : nullptr;
}
void ContainerClickPacket::handle(PacketListener *listener)
{
listener->handleContainerClick(shared_from_this());
}
void ContainerClickPacket::read(DataInputStream *dis) //throws IOException
{
containerId = dis->readByte();
slotNum = dis->readShort();
buttonNum = dis->readByte();
uid = dis->readShort();
clickType = dis->readByte();
item = readItem(dis);
}
void ContainerClickPacket::write(DataOutputStream *dos) // throws IOException
{
dos->writeByte(containerId);
dos->writeShort(slotNum);
dos->writeByte(buttonNum);
dos->writeShort(uid);
dos->writeByte(clickType);
writeItem(item, dos);
}
int ContainerClickPacket::getEstimatedSize()
{
return 4 + 4 + 2 + 1;
}
|