Fluid and item visuals

This commit is contained in:
2026-10-25 18:46:48 -03:00
parent 08df7f1b6b
commit 233c518def
15 changed files with 549 additions and 122 deletions
+13 -1
View File
@@ -2,7 +2,7 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
// what client scripts get, see docs/modding/gui/index.md
import type { FluidApi, Id, ItemStack, KeyCode, ModInfo, Position, Season, TagApi } from "./shared.ts";
import type { FluidApi, FluidVariant, Id, ItemStack, KeyCode, ModInfo, Position, Season, TagApi } from "./shared.ts";
import type { LootTableJson } from "../loot.ts";
export type {
@@ -132,6 +132,11 @@ export interface Instances {
transformed(model?: ModelRef): TransformedInstance;
// turning at a steady speed worked out from the time, so it never needs anything per frame
rotating(model?: ModelRef): RotatingInstance;
// one of an item, whatever the stack's count: the size it's drawn on the ground, with its middle at the middle of
// the block, placed by a matrix like a transformed model. like a block entity renderer drawing an item
item(stack: ItemStack): TransformedInstance;
// a box of a fluid, its texture tinted in its color, see FluidInstance. it shows what's behind it
fluid(fluid: FluidVariant): FluidInstance;
}
export interface Instance {
@@ -145,6 +150,13 @@ export interface TransformedInstance extends Instance {
set_transform(matrix: ArrayLike<number>): void;
}
// nothing is drawn until set_box is called
export interface FluidInstance extends Instance {
// from one corner to the other, in pixels like a model's elements: 0 to 16 across the block, past it for a box that
// reaches into the blocks around, like a tank's. the texture is cut to fit, never stretched
set_box(from: [number, number, number], to: [number, number, number]): void;
}
export interface RotatingInstance extends Instance {
// turns around axis through the middle of the block, counterclockwise seen from the axis's positive end when rpm
// is positive, at time * rpm * 0.3 + offset degrees. still when not set
+1
View File
@@ -490,6 +490,7 @@ export function check_references(mods: LoadedMod[], engine_textures: Iterable<st
if ((fluid_owners.get(json.id)?.length ?? 0) > 1) {
errors.push(`${file}: fluid ${json.id} is also defined by ${fluid_owners.get(json.id)!.join(", ")}`);
}
if (json.texture !== undefined) uses(file, json.texture, "texture");
}
for (const { file, json } of mod.spawns) {
check_namespace(file, json.entity);
+2
View File
@@ -484,6 +484,8 @@ const fluid_schema = z.object({
name: text.optional(),
// for whatever shows it, like a layer tinted "fluid" on a full container
color,
// what a box of it is drawn with, tinted by its color, like neoforge's still texture. engine:missing when not set
texture: z.string().optional(),
});
export type FluidJson = z.infer<typeof fluid_schema>;