Proper cutting board
This commit is contained in:
@@ -55,6 +55,7 @@ export interface BlockJson {
|
||||
place_in?: string[];
|
||||
states?: BlockStateDefinition[];
|
||||
components?: Record<string, unknown>;
|
||||
item_display?: { surface: number };
|
||||
}
|
||||
|
||||
export interface OreJson {
|
||||
@@ -202,6 +203,7 @@ export function block_to_json(block: BlockRegistry, has_item: boolean): BlockJso
|
||||
if (block.place_in) json.place_in = block.place_in;
|
||||
if (block.states) json.states = block.states;
|
||||
if (block.components) json.components = block.components;
|
||||
if (block.item_display) json.item_display = block.item_display;
|
||||
return json;
|
||||
}
|
||||
|
||||
@@ -233,6 +235,7 @@ export function block_from_json(json: BlockJson): { block: BlockRegistry; has_it
|
||||
if (json.place_in) block.place_in = json.place_in;
|
||||
if (json.states) block.states = json.states;
|
||||
if (json.components) block.components = json.components;
|
||||
if (json.item_display) block.item_display = json.item_display;
|
||||
return { block, has_item: json.item ?? true };
|
||||
}
|
||||
|
||||
@@ -436,6 +439,12 @@ export function validate_block(json: unknown): Problems {
|
||||
}
|
||||
}
|
||||
if (json.drops !== undefined) problems.push(...validate_id(json.drops, "drops"));
|
||||
if (json.item_display !== undefined) {
|
||||
const surface = is_object(json.item_display) ? json.item_display.surface : undefined;
|
||||
if (typeof surface !== "number" || surface < 0 || surface > 16) {
|
||||
problems.push("item_display.surface must be the height in pixels items lie on, from 0 to 16");
|
||||
}
|
||||
}
|
||||
for (const key of ["place_on", "place_in"]) {
|
||||
const list = json[key];
|
||||
if (list === undefined) continue;
|
||||
|
||||
Reference in New Issue
Block a user