2023-06-22 12:43:28 +01:00
|
|
|
import { createWriter, IReader, Endian } from "bufferstuff";
|
2023-04-10 14:42:14 +01:00
|
|
|
import { IPacket } from "./IPacket";
|
2023-05-02 10:24:48 +01:00
|
|
|
import { Packet } from "../enums/Packet";
|
2023-04-10 14:42:14 +01:00
|
|
|
|
|
|
|
export class PacketPlayerDigging implements IPacket {
|
2023-04-10 21:52:30 +01:00
|
|
|
public packetId = Packet.PlayerDigging;
|
2023-04-10 14:42:14 +01:00
|
|
|
public status:number;
|
|
|
|
public x:number;
|
|
|
|
public y:number;
|
|
|
|
public z:number;
|
|
|
|
public face:number;
|
|
|
|
|
|
|
|
public constructor(status?:number, x?:number, y?:number, z?:number, face?:number) {
|
|
|
|
if (typeof(status) == "number" && typeof(x) === "number" && typeof(y) === "number" && typeof(z) === "number" && typeof(face) === "number") {
|
|
|
|
this.status = status;
|
|
|
|
this.x = x;
|
|
|
|
this.y = y;
|
|
|
|
this.z = z;
|
|
|
|
this.face = face;
|
|
|
|
} else {
|
|
|
|
this.status = Number.MIN_VALUE;
|
|
|
|
this.x = Number.MIN_VALUE;
|
|
|
|
this.y = Number.MIN_VALUE;
|
|
|
|
this.z = Number.MIN_VALUE;
|
|
|
|
this.face = Number.MIN_VALUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-05-02 10:24:48 +01:00
|
|
|
public readData(reader:IReader) {
|
2023-04-10 14:42:14 +01:00
|
|
|
this.status = reader.readByte();
|
|
|
|
this.x = reader.readInt();
|
|
|
|
this.y = reader.readByte();
|
|
|
|
this.z = reader.readInt();
|
|
|
|
this.face = reader.readByte();
|
|
|
|
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public writeData() {
|
2023-05-02 10:24:48 +01:00
|
|
|
return createWriter(Endian.BE, 12).writeUByte(this.packetId).writeByte(this.status).writeInt(this.x).writeByte(this.y).writeInt(this.z).writeByte(this.face).toBuffer();
|
2023-04-10 14:42:14 +01:00
|
|
|
}
|
|
|
|
}
|