blob: 7274152e8d41569e855f306f3333fe34821c2e60 (
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
|
#include "stdafx.h"
#include "net.minecraft.world.effect.h"
#include "InputOutputStream.h"
#include "PacketListener.h"
#include "UpdateMobEffectPacket.h"
UpdateMobEffectPacket::UpdateMobEffectPacket()
{
this->entityId = 0;
this->effectId = 0;
this->effectAmplifier = 0;
this->effectDurationTicks = 0;
}
UpdateMobEffectPacket::UpdateMobEffectPacket(int entityId, MobEffectInstance *effect)
{
this->entityId = entityId;
this->effectId = (BYTE) (effect->getId() & 0xff);
this->effectAmplifier = (char) (effect->getAmplifier() & 0xff);
this->effectDurationTicks = (short) effect->getDuration();
}
void UpdateMobEffectPacket::read(DataInputStream *dis)
{
entityId = dis->readInt();
effectId = dis->readByte();
effectAmplifier = dis->readByte();
effectDurationTicks = dis->readShort();
}
void UpdateMobEffectPacket::write(DataOutputStream *dos)
{
dos->writeInt(entityId);
dos->writeByte(effectId);
dos->writeByte(effectAmplifier);
dos->writeShort(effectDurationTicks);
}
void UpdateMobEffectPacket::handle(PacketListener *listener)
{
listener->handleUpdateMobEffect(shared_from_this());
}
int UpdateMobEffectPacket::getEstimatedSize()
{
return 8;
}
bool UpdateMobEffectPacket::canBeInvalidated()
{
return true;
}
bool UpdateMobEffectPacket::isInvalidatedBy(std::shared_ptr<Packet> packet)
{
std::shared_ptr<UpdateMobEffectPacket> target = dynamic_pointer_cast<UpdateMobEffectPacket>(packet);
return target->entityId == entityId && target->effectId == effectId;
}
|