Skip blocks that don't exist on schematics
This commit is contained in:
+15
-1
@@ -123,10 +123,16 @@ export function server(ctx: ServerContext) {
|
||||
entities: [{ p: [1.5, 1, 0.5], id: "bworld:chicken", data: { rotation: [-Math.PI / 2, 0] } }],
|
||||
});
|
||||
try {
|
||||
ctx.schematics.register("testmod:broken", { size: [1, 1, 1], palette: [{ id: "testmod:nothing" }], blocks: [{ i: 0, p: [0, 0, 0] }], entities: [] });
|
||||
ctx.schematics.register("testmod:broken", { size: [1, 1, 1], palette: [], blocks: [], entities: [{ p: [0.5, 0, 0.5], id: "testmod:nothing", data: {} }] });
|
||||
} catch (e) {
|
||||
ctx.storage.set("broken", (e as Error).message);
|
||||
}
|
||||
ctx.schematics.register("testmod:partial", {
|
||||
size: [1, 2, 1],
|
||||
palette: [{ id: "testmod:nothing" }, { id: "bworld:oak_planks" }],
|
||||
blocks: [{ i: 0, p: [0, 0, 0] }, { i: 1, p: [0, 1, 0] }],
|
||||
entities: [],
|
||||
});
|
||||
// the file's is registered before scripts run
|
||||
try {
|
||||
ctx.schematics.register("testmod:post", { size: [1, 1, 1], palette: [], blocks: [], entities: [] });
|
||||
@@ -245,6 +251,14 @@ Deno.test("a schematic is checked when it's registered, and a placement before a
|
||||
assertEquals(t.game.world.get_block_id(0, 100, 0), "cubi:air");
|
||||
});
|
||||
|
||||
Deno.test("blocks that aren't registered are left out of a schematic, and the rest is placed", async () => {
|
||||
const t = await place_setup();
|
||||
t.game.set_block(5, 100, 5, "bworld:stone");
|
||||
t.schematics.place("testmod:partial", { position: { x: 5, y: 100, z: 5 } });
|
||||
assertEquals(t.game.world.get_block_id(5, 100, 5), "bworld:stone");
|
||||
assertEquals(t.game.world.get_block_id(5, 101, 5), "bworld:oak_planks");
|
||||
});
|
||||
|
||||
Deno.test("get gives a copy of a registered schematic with its id, a file's or a script's", async () => {
|
||||
const t = await place_setup();
|
||||
const hut = t.schematics.get("testmod:hut")!;
|
||||
|
||||
Reference in New Issue
Block a user