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