MCServer/src/packet/impl/player/PacketPositionLook.ts
2023-12-10 21:40:40 +03:00

36 lines
1.1 KiB
TypeScript

import {Packet} from "../../Packet";
import {PacketEnum} from "../../../utils/PacketEnum";
import {createWriter, Endian, IReader} from "bufferstuff";
import {Player} from "../../../Player";
export class PacketKick extends Packet {
constructor() {
super({
packetID: PacketEnum.PositionLook
})
}
readData(reader: IReader, player: Player) {
player.xPosition = reader.readDouble();
player.yPosition = reader.readDouble();
player.stance = reader.readDouble();
player.zPosition = reader.readDouble();
player.yaw = reader.readFloat();
player.pitch = reader.readFloat();
player.onGround = reader.readBool();
}
writeData() {
const player: Player = this.options.player;
return createWriter(Endian.BE).writeUByte(this.options.packetID)
.writeDouble(player.xPosition)
.writeDouble(player.stance)
.writeDouble(player.yPosition)
.writeDouble(player.zPosition)
.writeLong(player.yaw)
.writeLong(player.pitch)
.writeBool(player.onGround)
.toBuffer();
}
}