Trapdoors

This commit is contained in:
2026-10-03 17:52:58 -03:00
parent 91655c28c5
commit 63e6248f9f
35 changed files with 927 additions and 23 deletions
+6 -1
View File
@@ -81,6 +81,8 @@ export interface BlockHitResult {
z: number;
block: number;
face: Faces;
// where the view went into the block, 0 to 1 on each axis
hit: [number, number, number];
}
const NEIGHBOR_OFFSETS = [[-1, 0], [1, 0], [0, -1], [0, 1]] as const;
@@ -707,7 +709,10 @@ export class ClientLevel {
: hit.axis === 1
? (hit.sign > 0 ? "bottom" : "top")
: (hit.sign > 0 ? "north" : "south");
return { x: bx, y: by, z: bz, face, block };
const at = [0, 1, 2].map((axis) =>
Math.min(Math.max(origin[axis] + direction[axis] * hit.distance - [bx, by, bz][axis], 0), 1)
);
return { x: bx, y: by, z: bz, face, block, hit: [at[0], at[1], at[2]] };
}
return undefined;