Verdigris working !
This commit is contained in:
+6
-3
@@ -105,9 +105,12 @@ export function get_state_value(value: number, block_info: BlockRegistry, name:
|
||||
|
||||
// every state of a block value by name, like { age: 7 }
|
||||
export function block_states(value: number, block_info: BlockRegistry): Record<string, number> {
|
||||
return Object.fromEntries(
|
||||
(block_info.states ?? []).map((s) => [s.name, get_state_value(value, block_info, s.name)!]),
|
||||
);
|
||||
if (!block_info.states) return {};
|
||||
if (!block_info.compiled_states) compile_block_states(block_info);
|
||||
const state_bits = value >>> STATE_SHIFT;
|
||||
const states: Record<string, number> = {};
|
||||
for (const s of block_info.compiled_states!) states[s.name] = (state_bits & s.mask) >>> s.shift;
|
||||
return states;
|
||||
}
|
||||
|
||||
export function set_state_value(value: number, block_info: BlockRegistry, name: string, new_value: number) {
|
||||
|
||||
Reference in New Issue
Block a user