Export schematics
This commit is contained in:
+8
-1
@@ -109,6 +109,8 @@ export async function test_game(
|
||||
const closed = new Set<number>();
|
||||
// what host.download gives back, by url. other urls fail
|
||||
const downloads = new Map<string, Uint8Array>();
|
||||
// what host.write_schematic was given, by the path it answered with
|
||||
const schematics = new Map<string, Uint8Array>();
|
||||
const host = {
|
||||
// chunks come out decoded, as { type: "level_chunk", x, z, blocks, biomes }
|
||||
send: (conn: number, data: string | Uint8Array) => {
|
||||
@@ -124,6 +126,11 @@ export async function test_game(
|
||||
const bytes = downloads.get(url);
|
||||
return bytes ? Promise.resolve(bytes) : Promise.reject(new Error("Couldn't download it"));
|
||||
},
|
||||
write_schematic(bytes: Uint8Array) {
|
||||
const path = `memory/schematic_${schematics.size + 1}.cbsm`;
|
||||
schematics.set(path, bytes);
|
||||
return Promise.resolve(path);
|
||||
},
|
||||
};
|
||||
const chunks = new MemoryChunks();
|
||||
if (save) chunks.add(save.chunks);
|
||||
@@ -157,7 +164,7 @@ export async function test_game(
|
||||
send(conn, { type: "ready" });
|
||||
return take(conn).find((m) => m.type === "join");
|
||||
};
|
||||
return { game, take, send, join, closed, downloads };
|
||||
return { game, take, send, join, closed, downloads, schematics };
|
||||
}
|
||||
|
||||
// the block id and state bits at x, y, z in the chunks among messages, read the way a client does with the table
|
||||
|
||||
Reference in New Issue
Block a user