Fluid rendering in graphics

This commit is contained in:
2026-10-28 11:49:56 -03:00
parent 8fc08ab41e
commit bcd0690ef5
7 changed files with 59 additions and 20 deletions
+3
View File
@@ -127,6 +127,9 @@ interface Graphics {
direction?: "right" | "up",
): void;
item(id: string, x: number, y: number, count?: number): void; // an item as a slot shows it
// a fluid as a slot shows it, like { id: "bworld:juice", data: { item: "bworld:apple" } }. filled is how much of
// the slot it fills from the bottom up, 0 to 1, like a tank's amount / capacity
fluid(fluid: FluidVariant, x: number, y: number, filled?: number): void;
clip(x: number, y: number, w: number, h: number, draw: () => void): void; // only draws inside the box
button(label: string, x: number, y: number, w: number, h: number): boolean; // true the frame it's clicked
+8 -8
View File
@@ -23,17 +23,17 @@ here has no block, so it can't be placed.
}
```
| Field | Required | What it does |
| ----------------- | -------- | ----------------------------------------------------------------------------------------------------------------------------- |
| `id` | yes | The fluid's id, in the mod's [namespace](../concepts/registries.md#identifiers). |
| `name` | no | What players see. `copper_tools:maple_syrup` is "Maple Syrup" when not set, like an item's. |
| `color` | yes | Its color, like `"#a0522d"`, for whatever shows it. |
| `texture` | no | What a [box of it](../blocks/visuals.md#fluids) is drawn with, tinted by its color, like NeoForge's still texture. See below. |
| `base_sell_value` | no | What 1000 mB is worth sold in a [container](#containers), a whole number of 0 or more. None when not set. |
| Field | Required | What it does |
| ----------------- | -------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `id` | yes | The fluid's id, in the mod's [namespace](../concepts/registries.md#identifiers). |
| `name` | no | What players see. `copper_tools:maple_syrup` is "Maple Syrup" when not set, like an item's. |
| `color` | yes | Its color, like `"#a0522d"`, for whatever shows it. |
| `texture` | no | What a [box of it](../blocks/visuals.md#fluids) and [a slot of it](../gui/index.md#graphics) are drawn with, tinted by its color, like NeoForge's still texture. See below. |
| `base_sell_value` | no | What 1000 mB is worth sold in a [container](#containers), a whole number of 0 or more. None when not set. |
Like a fluid container's layer, the texture is multiplied by the fluid's color, so a light gray one comes out in the
fluid's own color, and its alpha is how much shows through. The base game's `bworld:water_still` is such a texture,
animated, and any fluid can use it. Without one, a box of the fluid is drawn with the missing texture.
animated, and any fluid can use it. Without one, the fluid is drawn with the missing texture.
## Fluids With Data