-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathhello.ts
More file actions
30 lines (25 loc) · 864 Bytes
/
hello.ts
File metadata and controls
30 lines (25 loc) · 864 Bytes
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
import { PacketReader, PacketWriter } from '@lilithmod/unborn-mcproto'
export interface ClientboundHelloPacket {
environment: number
}
/**
* Reads a clientbound hello packet from a buffer.
* @param buffer A buffer containing the packet data.
* @returns The parsed ClientboundHelloPacket
*/
export function read(buffer: Buffer): ClientboundHelloPacket {
const reader = new PacketReader(buffer)
const environmentId = reader.readVarInt()
const packet: ClientboundHelloPacket = {
environment: environmentId
}
return packet
}
/**
* Writes a clientbound hello packet to a new buffer.
* @param packet The packet to write.
* @returns A buffer containing the packet data.
*/
export function write(packet: ClientboundHelloPacket): Buffer {
return new PacketWriter(packet.environment).buffer
}