aboutsummaryrefslogtreecommitdiff
path: root/Minecraft.World/SetEquippedItemPacket.cpp
blob: ac9d22b26ef27d4cea1fc18d4565f411e89d87a6 (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
66
67
68
69
#include "stdafx.h"
#include <iostream>
#include "InputOutputStream.h"
#include "net.minecraft.world.item.h"
#include "PacketListener.h"
#include "SetEquippedItemPacket.h"



SetEquippedItemPacket::SetEquippedItemPacket()
{
	entity = 0;
	slot = 0;
	item = nullptr;
}

SetEquippedItemPacket::SetEquippedItemPacket(int entity, int slot, shared_ptr<ItemInstance> item) 
{
	this->entity = entity;
	this->slot = slot;

	// 4J Stu - Brought forward change from 1.3 to fix #64688 - Customer Encountered: TU7: Content: Art: Aura of enchanted item is not displayed for other players in online game
	this->item = item == nullptr ? nullptr : item->copy();
}

void SetEquippedItemPacket::read(DataInputStream *dis) //throws IOException 
{
	entity = dis->readInt();
	slot = dis->readShort();

	// 4J Stu - Brought forward change from 1.3 to fix #64688 - Customer Encountered: TU7: Content: Art: Aura of enchanted item is not displayed for other players in online game
	item = readItem(dis);
}

void SetEquippedItemPacket::write(DataOutputStream *dos) //throws IOException 
{
	dos->writeInt(entity);
	dos->writeShort(slot);

	// 4J Stu - Brought forward change from 1.3 to fix #64688 - Customer Encountered: TU7: Content: Art: Aura of enchanted item is not displayed for other players in online game
	writeItem(item, dos);
}

void SetEquippedItemPacket::handle(PacketListener *listener) 
{
	listener->handleSetEquippedItem(shared_from_this());
}

int SetEquippedItemPacket::getEstimatedSize()
{
	return 4 + 2 * 2;
}

// 4J Stu - Brought forward from 1.3 to fix #64688 - Customer Encountered: TU7: Content: Art: Aura of enchanted item is not displayed for other players in online game
shared_ptr<ItemInstance> SetEquippedItemPacket::getItem()
{
	return item;
}

bool SetEquippedItemPacket::canBeInvalidated()
{
	return true;
}

bool SetEquippedItemPacket::isInvalidatedBy(shared_ptr<Packet> packet)
{
	shared_ptr<SetEquippedItemPacket> target = dynamic_pointer_cast<SetEquippedItemPacket>(packet);
	return target->entity == entity && target->slot == slot;
}