Skip to content

Commit

Permalink
server block data
Browse files Browse the repository at this point in the history
  • Loading branch information
BuckarooBanzay committed Mar 7, 2023
1 parent d140813 commit 5448f70
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
2 changes: 2 additions & 0 deletions webapp/src/command/ServerCommand.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { ServerAccessDenied } from "./server/ServerAccessDenied"
import { ServerAnnounceMedia } from "./server/ServerAnnounceMedia"
import { ServerAuthAccept } from "./server/ServerAuthAccept"
import { ServerBlockData } from "./server/ServerBlockData"
import { ServerHello } from "./server/ServerHello"
import { ServerMedia } from "./server/ServerMedia"
import { ServerNodeDefinitions } from "./server/ServerNodeDefinitions"
Expand All @@ -19,6 +20,7 @@ export function getServerCommand(commandId: number): ServerCommand | null {
case 0x3A: return new ServerNodeDefinitions
case 0x3C: return new ServerAnnounceMedia
case 0x38: return new ServerMedia
case 0x20: return new ServerBlockData
}
return null
}
14 changes: 14 additions & 0 deletions webapp/src/command/server/ServerBlockData.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { Pos } from "../../util/pos";
import { ServerCommand } from "../ServerCommand";

export class ServerBlockData implements ServerCommand {

pos!: Pos
data!: Uint8Array

unmarshalPacket(dv: DataView): void {
this.pos = new Pos(dv.getInt16(0), dv.getInt16(2), dv.getInt16(4))
this.data = new Uint8Array(dv.buffer.slice(dv.byteOffset+6))
}

}
8 changes: 8 additions & 0 deletions webapp/src/util/pos.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@

export class Pos {
constructor(public x: number, public y: number, public z: number) {}

toString(): string {
return `${this.x}/${this.y}/${this.z}`;
}
}

0 comments on commit 5448f70

Please sign in to comment.