aboutsummaryrefslogtreecommitdiff
path: root/Minecraft.World/UpdateAttributesPacket.h
blob: 77ba08be56ad32f3b4edeec18c4d70175bed9f89 (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
#pragma once

#include "Packet.h"

class AttributeModifier;
class AttributeInstance;

class UpdateAttributesPacket : public Packet, public enable_shared_from_this<UpdateAttributesPacket>
{
public:
	class AttributeSnapshot
	{
	private:
		eATTRIBUTE_ID id;
		double base;
		unordered_set<AttributeModifier *> modifiers;

	public:
		AttributeSnapshot(eATTRIBUTE_ID id, double base, unordered_set<AttributeModifier *> *modifiers);
		~AttributeSnapshot();

		eATTRIBUTE_ID getId();
		double getBase();
		unordered_set<AttributeModifier *> *getModifiers();
	};

private:
	int entityId;
	unordered_set<AttributeSnapshot *> attributes;

public:
	UpdateAttributesPacket();
	UpdateAttributesPacket(int entityId, unordered_set<AttributeInstance *> *values);
	~UpdateAttributesPacket();

	void read(DataInputStream *dis);
	void write(DataOutputStream *dos);
	void handle(PacketListener *listener);
	int getEstimatedSize();
	int getEntityId();
	unordered_set<AttributeSnapshot *> getValues();

public:
	static shared_ptr<Packet> create() { return shared_ptr<Packet>(new UpdateAttributesPacket()); }
	virtual int getId() { return 44; }
};