Lava
This commit is contained in:
@@ -0,0 +1,16 @@
|
|||||||
|
{
|
||||||
|
"format_version": 1,
|
||||||
|
"block": {
|
||||||
|
"id": "bworld:lava",
|
||||||
|
"textures": { "still": "bworld:lava_still", "flowing": "bworld:lava_flow" },
|
||||||
|
"render_layer": "cutout",
|
||||||
|
"light_emission": 15,
|
||||||
|
"item": false,
|
||||||
|
"liquid": { "range": 3, "ticks": 30, "renewable": false },
|
||||||
|
"components": {
|
||||||
|
"bworld:bucketable": {
|
||||||
|
"into": "bworld:lava_bucket"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
{
|
||||||
|
"format_version": 1,
|
||||||
|
"item": {
|
||||||
|
"id": "bworld:lava_bucket",
|
||||||
|
"texture": "bworld:lava_bucket",
|
||||||
|
"max_stack": 1,
|
||||||
|
"places": "bworld:lava",
|
||||||
|
"base_sell_value": 180,
|
||||||
|
"components": {
|
||||||
|
"bworld:filled_bucket": {
|
||||||
|
"empty": "bworld:bucket"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 6.1 KiB |
@@ -0,0 +1,24 @@
|
|||||||
|
{
|
||||||
|
"animation": {
|
||||||
|
"frametime": 2,
|
||||||
|
|
||||||
|
"frames": [
|
||||||
|
0,
|
||||||
|
1,
|
||||||
|
2,
|
||||||
|
3,
|
||||||
|
4,
|
||||||
|
5,
|
||||||
|
6,
|
||||||
|
7,
|
||||||
|
8,
|
||||||
|
9,
|
||||||
|
10,
|
||||||
|
11,
|
||||||
|
12,
|
||||||
|
13,
|
||||||
|
14,
|
||||||
|
15
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 1.4 KiB |
@@ -0,0 +1,24 @@
|
|||||||
|
{
|
||||||
|
"animation": {
|
||||||
|
"frametime": 4,
|
||||||
|
|
||||||
|
"frames": [
|
||||||
|
0,
|
||||||
|
1,
|
||||||
|
2,
|
||||||
|
3,
|
||||||
|
4,
|
||||||
|
5,
|
||||||
|
6,
|
||||||
|
7,
|
||||||
|
8,
|
||||||
|
9,
|
||||||
|
10,
|
||||||
|
11,
|
||||||
|
12,
|
||||||
|
13,
|
||||||
|
14,
|
||||||
|
15
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 3.0 KiB |
@@ -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_id(-2, 100, 0), "bworld:water");
|
||||||
assertEquals(t.game.world.get_block_value(-2, 100, 0) >>> 16, 0);
|
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);
|
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 () => {
|
Deno.test("water falls off an edge and spreads again where it lands", async () => {
|
||||||
const { game } = await test_game("mods");
|
const { game } = await test_game("mods");
|
||||||
// a ledge one block wide, and a floor 3 below
|
// a ledge one block wide, and a floor 3 below
|
||||||
|
|||||||
Reference in New Issue
Block a user