2023-10-29 05:08:26 +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-10-29 05:08:26 +00:00
|
|
|
|
2024-10-26 14:24:38 +01:00
|
|
|
export default class PacketHoldingChange implements IPacket {
|
2023-10-29 05:08:26 +00:00
|
|
|
public packetId = Packet.HoldingChange;
|
|
|
|
public slotId:number;
|
|
|
|
|
|
|
|
public constructor(slotId?:number) {
|
|
|
|
if (typeof(slotId) === "number") {
|
|
|
|
this.slotId = slotId;
|
|
|
|
} else {
|
|
|
|
this.slotId = Number.MIN_VALUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public readData(reader:IReader) {
|
|
|
|
this.slotId = reader.readShort();
|
|
|
|
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public writeData() {
|
|
|
|
return createWriter(Endian.BE, 3).writeUByte(this.packetId).writeShort(this.slotId).toBuffer();
|
|
|
|
}
|
|
|
|
}
|