-
Notifications
You must be signed in to change notification settings - Fork 4
/
use-item-packet.ts
50 lines (45 loc) · 1.2 KB
/
use-item-packet.ts
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
import { Writer } from '../../writer';
import { Reader } from '../../reader';
import { PacketType } from '../../packet-type';
import { Packet } from '../../packet';
import { SlotObjectData } from '../../data/slot-object-data';
import { WorldPosData } from '../../data/world-pos-data';
/**
* Sent to use an item, such as an ability or consumable.
*/
export class UseItemPacket implements Packet {
type = PacketType.USEITEM;
propagate = true;
//#region packet-specific members
/**
* The current client time.
*/
time: number;
/**
* The slot of the item being used.
*/
slotObject: SlotObjectData;
/**
* The position at which the item was used.
*/
itemUsePos: WorldPosData;
/**
* The type of item usage.
*/
useType: number;
//#endregion
write(writer: Writer): void {
writer.writeInt32(this.time);
this.slotObject.write(writer);
this.itemUsePos.write(writer);
writer.writeByte(this.useType);
}
read(reader: Reader): void {
this.time = reader.readInt32();
this.slotObject = new SlotObjectData();
this.slotObject.read(reader);
this.itemUsePos = new WorldPosData();
this.itemUsePos.read(reader);
this.useType = reader.readByte();
}
}