42 lines
No EOL
1.2 KiB
TypeScript
42 lines
No EOL
1.2 KiB
TypeScript
import { Reader, Writer } from "../../bufferStuff";
|
|
import { Packets } from "../enums/Packets";
|
|
import { IPacket } from "./IPacket";
|
|
|
|
export class PacketPlayerDigging implements IPacket {
|
|
public packetId = Packets.PlayerDigging;
|
|
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;
|
|
}
|
|
}
|
|
|
|
public readData(reader:Reader) {
|
|
this.status = reader.readByte();
|
|
this.x = reader.readInt();
|
|
this.y = reader.readByte();
|
|
this.z = reader.readInt();
|
|
this.face = reader.readByte();
|
|
|
|
return this;
|
|
}
|
|
|
|
public writeData() {
|
|
return new Writer(12).writeUByte(this.packetId).writeByte(this.status).writeInt(this.x).writeByte(this.y).writeInt(this.z).writeByte(this.face).toBuffer();
|
|
}
|
|
} |