Curios slots rendering !
This commit is contained in:
@@ -9,6 +9,7 @@ import {
|
||||
RENDER_LAYERS,
|
||||
type RenderLayer,
|
||||
type ToolProperties,
|
||||
type WornProperties,
|
||||
} from "./everything_registry.ts";
|
||||
import { type BlockVariant, MODEL_FACES, type ModelFace } from "./block_models.ts";
|
||||
import { expand_items, list_matches } from "./tags.ts";
|
||||
@@ -101,6 +102,8 @@ export interface ItemJson {
|
||||
places?: string;
|
||||
max_stack?: number;
|
||||
food?: FoodProperties;
|
||||
// how it looks worn on a player
|
||||
worn?: WornProperties;
|
||||
name?: string;
|
||||
lore?: string;
|
||||
components?: Record<string, unknown>;
|
||||
@@ -309,6 +312,7 @@ export function item_to_json(id: string, item: ItemRegistry): ItemJson {
|
||||
if (item.block_id !== undefined) json.places = item.block_id;
|
||||
if (item.max_stack !== undefined) json.max_stack = item.max_stack;
|
||||
if (item.food !== undefined) json.food = item.food;
|
||||
if (item.worn !== undefined) json.worn = item.worn;
|
||||
if (item.name !== undefined) json.name = item.name;
|
||||
if (item.lore !== undefined) json.lore = item.lore;
|
||||
if (item.components) json.components = item.components;
|
||||
@@ -322,6 +326,7 @@ export function item_from_json(json: ItemJson): ItemRegistry {
|
||||
if (json.places !== undefined) item.block_id = json.places;
|
||||
if (json.max_stack !== undefined) item.max_stack = json.max_stack;
|
||||
if (json.food !== undefined) item.food = json.food;
|
||||
if (json.worn !== undefined) item.worn = json.worn;
|
||||
if (json.name !== undefined) item.name = json.name;
|
||||
if (json.lore !== undefined) item.lore = json.lore;
|
||||
if (json.components) item.components = json.components;
|
||||
@@ -646,6 +651,22 @@ export function validate_item(json: unknown): Problems {
|
||||
if (food.returns !== undefined) problems.push(...validate_id(food.returns, "food.returns"));
|
||||
}
|
||||
}
|
||||
if (json.worn !== undefined) {
|
||||
const worn = json.worn;
|
||||
if (!is_object(worn)) {
|
||||
problems.push("worn must be { model, texture }, an entity model and a texture");
|
||||
} else {
|
||||
problems.push(...validate_id(worn.model, "worn.model"), ...validate_id(worn.texture, "worn.texture"));
|
||||
for (const field of ["slim_model", "slim_texture"]) {
|
||||
if (worn[field] !== undefined) problems.push(...validate_id(worn[field], `worn.${field}`));
|
||||
}
|
||||
for (const field of Object.keys(worn)) {
|
||||
if (!["model", "texture", "slim_model", "slim_texture"].includes(field)) {
|
||||
problems.push(`worn.${field} isn't a field of worn`);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return problems;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user