mc-beta-server/server/packets/EntityStatus.ts

30 lines
826 B
TypeScript
Raw Normal View History

2023-08-20 01:17:37 +01:00
import { createWriter, IReader, Endian } from "bufferstuff";
import IPacket from "./IPacket";
import Packet from "../enums/Packet";
2023-08-20 01:17:37 +01:00
export default class PacketEntityStatus implements IPacket {
2023-08-20 01:17:37 +01:00
public packetId = Packet.EntityStatus;
public entityId:number;
public status:number;
public constructor(entityId?:number, status?:number) {
if (typeof(entityId) == "number" && typeof(status) === "number") {
this.entityId = entityId;
this.status = status;
} else {
this.entityId = Number.MIN_VALUE;
this.status = Number.MIN_VALUE;
}
}
public readData(reader:IReader) {
this.entityId = reader.readInt();
this.status = reader.readByte();
return this;
}
public writeData() {
return createWriter(Endian.BE, 6).writeUByte(this.packetId).writeInt(this.entityId).writeByte(this.status).toBuffer();
}
}