More fluid apis

This commit is contained in:
2026-10-28 13:04:24 -03:00
parent 1539cf6933
commit 3cc33ea10c
7 changed files with 36 additions and 4 deletions
+1
View File
@@ -47,6 +47,7 @@ export class FluidRules {
// ctx.fluids for server and client scripts
api(): FluidApi {
return {
ids: () => EverythingRegistry.entries("fluids").map(([id]) => id),
exists: (id) => EverythingRegistry.get("fluids", id) !== undefined,
name: (fluid) => this.name(fluid),
color: (fluid) => this.color(fluid),
+4 -1
View File
@@ -71,7 +71,10 @@ export interface ClientContext {
solid(id: Id): boolean;
};
// every fluid, named and colored by its rules, see docs/modding/resources/fluids.md
fluids: FluidApi;
fluids: FluidApi & {
// the mod that registered it, like ctx.items.mod
mod(id: Id): string;
};
// the mods' loot table files (see docs/modding/resources/loot_tables.md), to show what they give. tables server
// scripts make with ctx.loot.register_table aren't here
loot: {
+2
View File
@@ -26,6 +26,8 @@ export interface FluidVariant {
// ctx.fluids in server and client scripts: every fluid any mod defines, the same on the server and every client
export interface FluidApi {
// every fluid's id, in load order, like ctx.items.ids. each without data, which a fluid like juice has many of
ids(): Id[];
exists(id: Id): boolean;
// what players see, from the fluid's rules for its data, or else its json
name(fluid: FluidVariant): string;