mc-beta-server/server/Packets/Packet.js

21 lines
365 B
JavaScript
Raw Normal View History

2021-08-12 04:58:56 +01:00
const bufferStuff = require("../bufferStuff.js");
2021-08-11 15:05:14 +01:00
module.exports = class {
2021-08-12 04:58:56 +01:00
constructor(packetID = 0x00) {
this.id = packetID;
this.writer = null;
2021-08-11 15:05:14 +01:00
}
2021-08-12 04:58:56 +01:00
writePacket() {
this.writer = new bufferStuff.Writer();
2021-08-11 15:05:14 +01:00
2021-08-12 04:58:56 +01:00
this.writer.writeByte(this.id);
return this.writer;
2021-08-11 15:05:14 +01:00
}
2021-08-12 04:58:56 +01:00
toBuffer() {
return this.writer == null ? Buffer.alloc(0) : this.writer.buffer;
2021-08-11 15:05:14 +01:00
}
}