Fix bug with fences

This commit is contained in:
2026-10-11 16:52:55 -03:00
parent cd943246d0
commit c3bc1b3501
2 changed files with 29 additions and 13 deletions
+15
View File
@@ -92,6 +92,21 @@ Deno.test("falling more than 3 blocks hurts, 1 per block after that, and water b
assertEquals(t.player.health, MAX_HEALTH);
});
Deno.test("landing on a fence ends a fall, so jumping on one and stepping off doesn't hurt", async () => {
const t = await setup();
// a fence's top is 1.5 blocks up, so standing on it isn't at a whole block
t.game.set_block(0, 100, 0, "bworld:oak_fence");
const at = (x: number, y: number) => t.send(1, { type: "move", x, y, z: 0.5, yaw: 0, pitch: 0 });
at(0.5, 101.5);
for (let jump = 0; jump < 4; jump++) {
for (const y of [102, 102.5, 102.75, 102.5, 102, 101.5]) at(0.5, y);
}
// off it, onto the stone
at(1.5, 101.5);
for (const y of [101, 100.5, 100]) at(1.5, y);
assertEquals(t.player.health, MAX_HEALTH);
});
Deno.test("health and hunger are sent to the player when they change, and saved", async () => {
const t = await setup();
t.take(1);