Change how ticking works a little

This commit is contained in:
2026-10-10 20:11:03 -03:00
parent f4cf1d8fa8
commit be05f70fb5
6 changed files with 96 additions and 15 deletions
+19
View File
@@ -331,3 +331,22 @@ Deno.test("a pumpkin plant becomes a pumpkin the morning it's grown, and a melon
assertEquals(slices.map((item) => item.id), ["bworld:melon_slice"]);
assert(slices[0].count >= 3 && slices[0].count <= 7);
});
Deno.test("blocks without data run on_new_day near players, once a morning", async () => {
const t = await setup();
// a cactus without data, like one world generation made
t.game.set_block(0, 100, 0, "bworld:sand");
t.game.set_block(0, 101, 0, "bworld:cactus");
t.game.world.remove_tile(0, 101, 0);
t.next_morning();
assertEquals(t.game.world.get_block_id(0, 102, 0), "bworld:cactus", "grew a block");
assertEquals(t.game.world.get_block_id(0, 103, 0), "bworld:air", "the new block waits for tomorrow");
// far from every player, in a chunk that isn't kept, nothing runs
const far = 16 * 40;
t.game.set_block(far, 100, 0, "bworld:sand");
t.game.set_block(far, 101, 0, "bworld:cactus");
t.game.world.remove_tile(far, 101, 0);
t.next_morning();
assertEquals(t.game.world.get_block_id(far, 102, 0), "bworld:air");
});