Cog wheels

This commit is contained in:
2026-10-15 12:01:46 -03:00
parent a0596ed0ef
commit 74c315bdfc
14 changed files with 331 additions and 88 deletions
+3 -2
View File
@@ -67,13 +67,13 @@ export class BlockRules {
// the block's value with the states a player looking at yaw and pitch placing it gets: its defaults facing them
// (default_placement_value), then what its rules' state_for_placement say. states that don't exist or don't fit are
// left alone
// left alone. undefined when a rule says it can't go there
placement_value(
block: BlockRegistry,
yaw: number,
pitch: number,
where: Omit<BlockPlacement, "facing" | "looking">,
): number {
): number | undefined {
let value = default_placement_value(block, yaw);
const placement: BlockPlacement = {
...where,
@@ -87,6 +87,7 @@ export class BlockRules {
`${id} state_for_placement`,
() => rules.state_for_placement!(placement, params),
);
if (states === false) return undefined;
for (const [name, state] of Object.entries(states ?? {})) {
const known = block.states?.find((s) => s.name === name);
if (known && Number.isInteger(state) && state >= 0 && state < 2 ** known.bits) {