Add a bunch of crops and farmer's delight crops
This commit is contained in:
+9
-4
@@ -50,6 +50,7 @@ export interface BlockJson {
|
||||
interactive?: boolean;
|
||||
replaceable?: boolean;
|
||||
place_on?: string[];
|
||||
place_in?: string[];
|
||||
states?: BlockStateDefinition[];
|
||||
components?: Record<string, unknown>;
|
||||
}
|
||||
@@ -124,6 +125,7 @@ export function block_to_json(block: BlockRegistry, has_item: boolean): BlockJso
|
||||
if (block.interactive) json.interactive = true;
|
||||
if (block.replaceable) json.replaceable = true;
|
||||
if (block.place_on) json.place_on = block.place_on;
|
||||
if (block.place_in) json.place_in = block.place_in;
|
||||
if (block.states) json.states = block.states;
|
||||
if (block.components) json.components = block.components;
|
||||
return json;
|
||||
@@ -153,6 +155,7 @@ export function block_from_json(json: BlockJson): { block: BlockRegistry; has_it
|
||||
if (json.interactive) block.interactive = true;
|
||||
if (json.replaceable) block.replaceable = true;
|
||||
if (json.place_on) block.place_on = json.place_on;
|
||||
if (json.place_in) block.place_in = json.place_in;
|
||||
if (json.states) block.states = json.states;
|
||||
if (json.components) block.components = json.components;
|
||||
return { block, has_item: json.item ?? true };
|
||||
@@ -344,11 +347,13 @@ export function validate_block(json: unknown): Problems {
|
||||
}
|
||||
}
|
||||
if (json.drops !== undefined) problems.push(...validate_id(json.drops, "drops"));
|
||||
if (json.place_on !== undefined) {
|
||||
if (!Array.isArray(json.place_on) || json.place_on.length === 0) {
|
||||
problems.push("place_on must be a list of block ids");
|
||||
for (const key of ["place_on", "place_in"]) {
|
||||
const list = json[key];
|
||||
if (list === undefined) continue;
|
||||
if (!Array.isArray(list) || list.length === 0) {
|
||||
problems.push(`${key} must be a list of block ids`);
|
||||
} else {
|
||||
for (const id of json.place_on) problems.push(...validate_id(id, "place_on"));
|
||||
for (const id of list) problems.push(...validate_id(id, key));
|
||||
}
|
||||
}
|
||||
if (json.states !== undefined) {
|
||||
|
||||
Reference in New Issue
Block a user