Add a bunch of crops and farmer's delight crops

This commit is contained in:
2026-09-26 21:35:17 -03:00
parent 8d9c85d379
commit 7e5bcaa239
77 changed files with 980 additions and 81 deletions
+25
View File
@@ -123,6 +123,31 @@ export function can_stand_on(block: BlockRegistry | undefined, below: string): b
return !block?.place_on || block.place_on.includes(below);
}
// where a block placed by clicking a face of another goes: into the clicked block when it can be replaced (like water),
// like minecraft, otherwise next to it
export function placement_target(
x: number,
y: number,
z: number,
offset: { x: number; y: number; z: number },
clicked: BlockRegistry | undefined,
) {
return clicked?.replaceable ? { x, y, z } : { x: x + offset.x, y: y + offset.y, z: z + offset.z };
}
// whether a player can place block where current is now, with below under it. current is undefined for air
export function can_place(
block: BlockRegistry | undefined,
current: BlockRegistry | undefined,
below: string,
): boolean {
if (!block) return false;
const into = current?.id ?? "bworld:air";
const replaceable = !current || current.replaceable === true;
const in_ok = block.place_in ? block.place_in.includes(into) : replaceable;
return in_ok && can_stand_on(block, below);
}
// numeric so looking chunks up doesnt allocate a string every time, fine for |x|, |z| < 32768
export function chunk_key(x: number, z: number) {
return (x + 32768) * 65536 + (z + 32768);