Fluid containers
This commit is contained in:
+25
-2
@@ -10,8 +10,10 @@ import {
|
||||
type BlockStateDefinition,
|
||||
FLUID_DEFAULTS,
|
||||
FLUID_LEVEL,
|
||||
type FluidContainerProperties,
|
||||
type FluidProperties,
|
||||
type FoodProperties,
|
||||
type ItemLayer,
|
||||
type ItemRegistry,
|
||||
MAX_FLUID_RANGE,
|
||||
RENDER_LAYERS,
|
||||
@@ -58,6 +60,10 @@ type BlockTextures = BlockRegistry["textures"];
|
||||
|
||||
// how far a model turns
|
||||
const right_angle = z.literal([0, 90, 180, 270]);
|
||||
|
||||
// what a block's tint draws its textures in, see TintColor
|
||||
const tint_color = z.custom<TintColor>(is_tint_color, 'must be "grass", "foliage", "water" or a color like "#80a755"');
|
||||
|
||||
// a texture id, or texture variables mapped to ids
|
||||
const textures = z.union([id, z.record(z.string(), id)], "must be a texture id or { variable: texture id }");
|
||||
const stack = z.object({ id, count: z.int().min(1) });
|
||||
@@ -168,7 +174,7 @@ const block_fields = z.object({
|
||||
render_layer: z.enum(RENDER_LAYERS).optional(),
|
||||
cull_same: z.boolean().optional(),
|
||||
tint: z.object({
|
||||
color: z.custom<TintColor>(is_tint_color, 'must be "grass", "foliage", "water" or a color like "#80a755"'),
|
||||
color: tint_color,
|
||||
// texture variables, like ["top"]
|
||||
textures: z.array(z.string()).optional(),
|
||||
}).optional(),
|
||||
@@ -368,6 +374,8 @@ export interface ItemJson {
|
||||
worn?: WornProperties;
|
||||
// see ItemRegistry.targets_fluids
|
||||
targets_fluids?: boolean;
|
||||
fluid_container?: FluidContainerProperties;
|
||||
layers?: ItemLayer[];
|
||||
name?: string;
|
||||
lore?: string;
|
||||
components?: Record<string, unknown>;
|
||||
@@ -401,6 +409,17 @@ const item_schema: z.ZodType<ItemJson> = z.object({
|
||||
slim_texture: id.optional(),
|
||||
}, "must be { model, texture }, an entity model and a texture").optional(),
|
||||
targets_fluids: z.boolean().optional(),
|
||||
fluid_container: z.strictObject({
|
||||
capacity: z.int().min(1),
|
||||
full_max_stack: z.int().min(1).optional(),
|
||||
}).optional(),
|
||||
layers: z.array(z.strictObject({
|
||||
texture: id,
|
||||
tint: z.custom<ItemLayer["tint"]>(
|
||||
(value) => value === "fluid" || is_tint_color(value),
|
||||
'must be "fluid", "grass", "foliage", "water" or a color like "#80a755"',
|
||||
).optional(),
|
||||
})).optional(),
|
||||
name: text.optional(),
|
||||
lore: text.optional(),
|
||||
components: json_object.optional(),
|
||||
@@ -463,7 +482,7 @@ const fluid_schema = z.object({
|
||||
id,
|
||||
// what players see, from the id when not set like an item's
|
||||
name: text.optional(),
|
||||
// for whatever shows it, like a container's tinted overlay
|
||||
// for whatever shows it, like a layer tinted "fluid" on a full container
|
||||
color,
|
||||
});
|
||||
|
||||
@@ -746,6 +765,8 @@ export function item_to_json(id: string, item: ItemRegistry): ItemJson {
|
||||
if (item.food !== undefined) json.food = item.food;
|
||||
if (item.worn !== undefined) json.worn = item.worn;
|
||||
if (item.targets_fluids !== undefined) json.targets_fluids = item.targets_fluids;
|
||||
if (item.fluid_container !== undefined) json.fluid_container = item.fluid_container;
|
||||
if (item.layers !== undefined) json.layers = item.layers;
|
||||
if (item.name !== undefined) json.name = item.name;
|
||||
if (item.lore !== undefined) json.lore = item.lore;
|
||||
if (item.components) json.components = item.components;
|
||||
@@ -774,6 +795,8 @@ function item_fields(json: ItemJson): Partial<ItemRegistry> {
|
||||
if (json.food !== undefined) item.food = json.food;
|
||||
if (json.worn !== undefined) item.worn = json.worn;
|
||||
if (json.targets_fluids !== undefined) item.targets_fluids = json.targets_fluids;
|
||||
if (json.fluid_container !== undefined) item.fluid_container = json.fluid_container;
|
||||
if (json.layers !== undefined) item.layers = json.layers;
|
||||
if (json.name !== undefined) item.name = json.name;
|
||||
if (json.lore !== undefined) item.lore = json.lore;
|
||||
if (json.components) item.components = json.components;
|
||||
|
||||
Reference in New Issue
Block a user