Send chunks to players connected to server

This commit is contained in:
2026-09-28 11:14:40 -03:00
parent 677ad8115a
commit ded9a7e5d0
26 changed files with 920 additions and 357 deletions
+5 -1
View File
@@ -1,6 +1,7 @@
import { Container, Cursor, ItemData, ItemStack } from "$/common/inventory.ts";
import { PlayerInfo, ScreenLayout } from "$/common/protocol.ts";
import { type SavedVitals, Vitals } from "./vitals.ts";
import { PlayerChunks } from "./player_chunks.ts";
export const INVENTORY_SIZE = 9 * 4;
export const CRAFTING_SIZE = 10;
@@ -64,10 +65,13 @@ export class ServerPlayer {
// last json sent for each synced thing, so only changes get sent
sent = new Map<string, string>();
// the chunks their client has and still needs
chunks: PlayerChunks;
constructor(conn: number, name: string) {
constructor(conn: number, name: string, view_distance: number) {
this.conn = conn;
this.name = name;
this.chunks = new PlayerChunks(view_distance);
}
get held_item(): ItemStack | undefined {