2023-11-05 10:55:49 +00:00
|
|
|
import { createWriter, IReader, Endian } from "bufferstuff";
|
2024-10-26 14:24:38 +01:00
|
|
|
import IPacket from "./IPacket";
|
|
|
|
import Packet from "../enums/Packet";
|
2023-11-05 10:55:49 +00:00
|
|
|
|
2024-10-26 14:24:38 +01:00
|
|
|
export default class PacketDestroyEntity implements IPacket {
|
2023-11-05 10:55:49 +00:00
|
|
|
public packetId = Packet.DestroyEntity;
|
|
|
|
public entityId:number;
|
|
|
|
|
|
|
|
public constructor(entityId?:number) {
|
|
|
|
if (typeof(entityId) === "number") {
|
|
|
|
this.entityId = entityId;
|
|
|
|
} else {
|
|
|
|
this.entityId = Number.MIN_VALUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public readData(reader:IReader) {
|
|
|
|
this.entityId = reader.readInt();
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public writeData() {
|
|
|
|
return createWriter(Endian.BE, 5).writeUByte(this.packetId).writeInt(this.entityId).toBuffer();
|
|
|
|
}
|
|
|
|
}
|