Lava
This commit is contained in:
@@ -310,3 +310,18 @@ Deno.test("a bucket picks up a water source but not flowing water, and a water b
|
||||
assertEquals(t.game.world.get_block_id(-2, 100, 0), "bworld:water");
|
||||
assertEquals(t.game.world.get_block_value(-2, 100, 0) >>> 16, 0);
|
||||
});
|
||||
|
||||
Deno.test("a bucket picks up a lava source too, and a lava bucket puts one back", async () => {
|
||||
const t = await setup([["bworld:bucket", 1]]);
|
||||
const held = () => t.game.players()[0].held_item?.type_id;
|
||||
t.game.set_block(1, 100, 0, "bworld:lava");
|
||||
|
||||
t.send(1, { type: "use_block", x: 1, y: 100, z: 0, face: "top" });
|
||||
assertEquals(held(), "bworld:lava_bucket");
|
||||
assertEquals(t.game.world.get_block_id(1, 100, 0), "bworld:air");
|
||||
|
||||
t.send(1, { type: "use_block", x: -2, y: 99, z: 0, face: "top" });
|
||||
assertEquals(held(), "bworld:bucket");
|
||||
assertEquals(t.game.world.get_block_id(-2, 100, 0), "bworld:lava");
|
||||
assertEquals(t.game.world.get_block_value(-2, 100, 0) >>> 16, 0);
|
||||
});
|
||||
|
||||
@@ -50,6 +50,35 @@ Deno.test("water flows out from a source one block a step, lower each block, up
|
||||
assertEquals(game.liquids.pending, 0);
|
||||
});
|
||||
|
||||
// lava's level there, undefined for no lava
|
||||
function lava_level(game: Game, x: number, y: number, z: number) {
|
||||
if (game.world.get_block_id(x, y, z) !== "bworld:lava") return undefined;
|
||||
const lava = EverythingRegistry.get<BlockRegistry>("blocks", "bworld:lava")!;
|
||||
return get_state_value(game.world.get_block_value(x, y, z), lava, "level");
|
||||
}
|
||||
|
||||
Deno.test("lava flows 3 blocks from a source, a step every 30 ticks, and two sources don't make another", async () => {
|
||||
const { game } = await test_game("mods");
|
||||
floor(game, 10);
|
||||
game.set_block(0, Y, 0, "bworld:lava");
|
||||
ticks(game, 29);
|
||||
assertEquals(lava_level(game, 1, Y, 0), undefined);
|
||||
ticks(game, 1);
|
||||
assertEquals(lava_level(game, 1, Y, 0), 1);
|
||||
ticks(game, 200);
|
||||
for (let x = 0; x <= 3; x++) assertEquals(lava_level(game, x, Y, 0), x, `at x ${x}`);
|
||||
assertEquals(lava_level(game, 4, Y, 0), undefined);
|
||||
|
||||
// a spot between two sources stays flowing, unlike water
|
||||
game.set_block(0, Y, 0, "bworld:stone");
|
||||
ticks(game, 200);
|
||||
game.set_block(5, Y, 5, "bworld:lava");
|
||||
game.set_block(7, Y, 5, "bworld:lava");
|
||||
ticks(game, 200);
|
||||
assertEquals(lava_level(game, 6, Y, 5), 1);
|
||||
assertEquals(EverythingRegistry.get<BlockRegistry>("blocks", "bworld:lava")!.light_emission, 15);
|
||||
});
|
||||
|
||||
Deno.test("water falls off an edge and spreads again where it lands", async () => {
|
||||
const { game } = await test_game("mods");
|
||||
// a ledge one block wide, and a floor 3 below
|
||||
|
||||
Reference in New Issue
Block a user