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
+2
View File
@@ -168,6 +168,8 @@ ctx.items.mod(id); // the name of the mod that added it
ctx.items.components(id); // its components and their params, like the server's, to show what they mean
ctx.blocks.exists(id);
ctx.blocks.components(id); // the same for a block, like what a crab pot catches with each bait
ctx.fluids.ids(); // every fluid, in load order
ctx.fluids.mod(id); // the name of the mod that added it
ctx.fluids.name(fluid); // and color, exists and same, see ../resources/fluids.md#using-fluids
ctx.loot.table(id); // a loot table file's JSON, or undefined. tables server scripts make aren't here
ctx.recipes.list(type?); // every recipe as its JSON, including mods' own types
+5
View File
@@ -98,12 +98,17 @@ Server and client scripts have `ctx.fluids`, which goes through the rules:
```ts
const birch = { id: "copper_tools:syrup", data: { tree: "bworld:birch_log" } };
ctx.fluids.ids(); // every fluid's id in load order, like ["bworld:juice", "copper_tools:syrup"]
ctx.fluids.exists("copper_tools:syrup"); // true
ctx.fluids.name(birch); // "Birch Log Syrup"
ctx.fluids.color(birch); // "#d9a441"
ctx.fluids.same(birch, { id: "copper_tools:syrup" }); // false, the data is different
```
`ids` gives each fluid once, without data, so a fluid that's many things by its data, like syrup from each tree, is only
there as plain `copper_tools:syrup`. Client scripts also have `ctx.fluids.mod(id)`, the name of the mod that added it,
like `ctx.items.mod`.
## Containers
An item with `fluid_container` holds one fluid, full or empty, like a bucket or a bottle: