2023-04-08 20:52:47 +01:00
|
|
|
import { Reader, Writer } from "../../bufferStuff";
|
|
|
|
import { Packets } from "../enums/Packets";
|
|
|
|
import { IPacket } from "./IPacket";
|
|
|
|
|
|
|
|
export class PacketPlayer implements IPacket {
|
|
|
|
public packetId = Packets.Player;
|
|
|
|
public onGround:boolean;
|
|
|
|
|
2023-04-09 04:19:10 +01:00
|
|
|
public constructor(onGround?:boolean) {
|
|
|
|
if (typeof(onGround) === "boolean") {
|
|
|
|
this.onGround = onGround;
|
|
|
|
} else {
|
|
|
|
this.onGround = false;
|
|
|
|
}
|
2023-04-08 20:52:47 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public readData(reader:Reader) {
|
|
|
|
this.onGround = reader.readBool();
|
|
|
|
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public writeData() {
|
|
|
|
return new Writer(2).writeUByte(this.packetId).writeBool(this.onGround).toBuffer();
|
|
|
|
}
|
|
|
|
}
|