World fluids
Fluids you can pour into the world: buckets, flow, textures, physics, mixing, effects, and the settings behind them.
A fluid can leave its tanks and pipes: poured from a bucket, it flows, swims and looks like its own liquid, with its own textures, fog, physics and effects. Players need no mod: the look comes from MachineEngine's resource pack.
Since 0.2.0
World fluids came in MachineEngine 0.2.0. They work on every supported version, 1.20.6 to 26.3, Paper and Folia.
Making a fluid placeable
Any fluid resource type can be placeable. Add a fluid: section to its
definition (see Resources):
resource-types:
mypack:fluid/oil:
category: machineengine:fluid
color: '#2A2238'
fluid:
world: placeable
look:
texture:
{source: recolor, pattern: lava, from: '#0A080E', to: '#4E3E60'}
opacity: 0.96
fog: '#0B0806'
physics:
viscosity:
{speed: 0.5, gravity: 1.6, jump: 0.5, damping: 0.35, entity-drag: 0.3}
spread: {ticks: 15, range: 5}
infinite-source: false
mixing:
- {with: water, result: stop}
- {with: lava, result: block, block: minecraft:obsidian}
effects:
- {type: potion, effect: minecraft:slowness}Only world: placeable is needed: everything else defaults to water. A fluid
without textures is the water texture in its menu color. Unknown fields are
refused at startup with their path, so typos show in /machineengine report.
| Field | Default | Meaning |
|---|---|---|
world | none | none: tanks and pipes only. placeable: it can be in the world. |
bucket | auto | auto: a water bucket named after the fluid. none: no bucket. Or a CraftEngine item key, such as mypack:oil_bucket. |
look | water | Textures, tint, opacity, glow, fog (below). |
physics | water | How it moves things and flows (below). |
mixing | stop | What happens where it flows into another fluid (below). |
effects | none | What it does to whoever is inside (below). |
Look
| Field | Default | Meaning |
|---|---|---|
texture | water's | Still and flowing texture at once. |
still | water's | The still texture. |
flow | water's | The flowing texture. |
tint | menu color, or white with a texture | Color multiplied over the texture, '#RRGGBB'. |
opacity | 0.7 | 0 (invisible) to 1 (opaque). |
glow | 0 | 0 to 1: how much it ignores darkness. 1 is fully lit, like a light source. |
fog | the tint | Underwater fog color, '#RRGGBB'. |
frame-time | 2 | Ticks per animation frame. |
A texture is a resource pack key, such as mypack:block/oil_still, or a map
with a source:
| Source | Fields | Draws |
|---|---|---|
file | texture | A texture of the CraftEngine resource packs (same as a key). |
vanilla | texture (default block/water_still) | A vanilla texture, such as block/lava_still. |
recolor | pattern, from, to | A vanilla fluid pattern (water, lava) recolored from dark to light. |
crystals | color, sparkle | Drawn, twinkling crystals. |
bubbles | color, bubble | Drawn, rising bubbles. |
Fluids that look the same share one look on the client, so 22 placeable fluids with 22 different looks fit, and more if some look alike.
Physics
| Field | Default | Meaning |
|---|---|---|
viscosity.speed | 1 | Walking and swimming speed multiplier. |
viscosity.gravity | 1 | Gravity multiplier inside. |
viscosity.jump | 1 | Jump strength multiplier. |
viscosity.swim | 0 | 0 to 1: swims faster than water (1.21+). |
viscosity.damping | 0 | 0 to 0.9: speed players lose inside, for thick fluids. |
viscosity.entity-drag | 0 | 0 to 0.9: speed mobs, items and boats lose inside. |
spread.ticks | 5 | Ticks per flowing step, 5 (water's) or slower. |
spread.range | 7 | Blocks it flows from a source on flat ground, 1 to 7. |
infinite-source | true | Two of its sources make a new one, like water. |
mixed-source | none | What a source formed between it and another fluid becomes: none (stays flowing) or water. |
Gravity and jump need 1.20.5 or later. Players' speed, gravity and jump are
attributes their client predicts, so they feel smooth; damping is applied by
the server and can stutter a little.
Mixing
Rules for where it flows into another fluid. The first rule that matches decides; without one, both stop where they meet.
with | Matches |
|---|---|
water, lava | That vanilla fluid |
any | Any other fluid |
'#mypack:hot_fluids' | A resource tag |
mypack:fluid/acid | One fluid |
result | Fields | Does |
|---|---|---|
stop | Both stop. | |
flow | It replaces the fluid there. | |
block | block | The block becomes this block, like lava meeting water. |
fluid | fluid | The block becomes a source of this placeable fluid. |
Effects
Effects run every 10 ticks on whoever is inside.
type | Fields | Does |
|---|---|---|
potion | effect, amplifier: 0 | Keeps a potion effect on while inside. |
damage | amount: 1, every: 20 | Damage every every ticks. |
fire | ticks: 60 | Sets on fire. |
freeze | ticks: 140 | Freezes, like powder snow. |
Mobs and items feel effects and drag too, unless entity-effects is off.
Changing a fluid without a restart: fluids.yml
plugins/MachineEngine/fluids.yml overrides any placeable fluid, including
those of addons such as Mekanized. On first start it lists every placeable fluid
with its current values, ready to copy. Write only the fields to change:
fluids:
mekanized:fluid/brine:
look: {tint: '#E8DDB5', opacity: 0.8}
physics:
viscosity: {speed: 0.8}/machineengine reload fluids applies it:
| What | Applies |
|---|---|
physics, mixing, effects | At once |
look (textures, tint, opacity, glow…) | After the pack is rebuilt |
look.fog | After players rejoin |
world and bucket can't be changed there: set them in the definition and
restart.
The resource pack
MachineEngine writes the fluids' textures and a patched water shader into
CraftEngine/resources/machineengine/resourcepack, so CraftEngine sends them
with its pack. It builds them from the official Minecraft client jar, which it
downloads from Mojang once and keeps in plugins/MachineEngine/cache.
After changing looks, rebuild and resend the pack:
/machineengine reload fluids
/ce reload packPlayers' renderers
| Renderer | Sees |
|---|---|
| Vanilla | Every fluid with its own look. |
| Sodium 0.9 and later (Minecraft 26.2+) | The same: MachineEngine ships a patched Sodium shader too. |
| Older Sodium, OptiFine, shader packs | Water, with fluids in their code color (with textures: tint). |
textures: auto (the default) picks the texture grid on 26.2 and later, where
Sodium reads the pack's shader, and tint only before, so nobody sees the grid.
Settings
Under world-fluids: in config.yml. Restart marks settings that need one;
pack marks those that apply after the pack is rebuilt.
| Setting | Default | Effect |
|---|---|---|
enabled | true | Placeable fluids in the world. Off: fluids only live in tanks and pipes. Restart. |
uniform-water | true | Every biome's water gets the neutral color for players (swamps and oceans lose their tint). Needed for more than 6 fluid looks. Restart, then players rejoin. |
neutral-color | '#3F76E4' | That neutral water color. Restart, then players rejoin. |
neutral-rings | 6 | Without uniform-water only: 4-block areas around a fluid that get the neutral color. Restart. |
shader | true | Draw fluids with their own look. Off: fluids are water tinted with a code color. Pack. |
sodium | true | Also for players using Sodium 0.9+. Pack. |
sodium-jar | download | Where Sodium's shader comes from: the newest Sodium from Modrinth, or the path of a Sodium jar. |
textures | auto | grid: fluids can have their own textures. tint: each fluid is the water texture in its color. auto: grid from 26.2. Pack. |
bucket-textures | true | A texture for each fluid's bucket item: the vanilla water bucket in the fluid's color. Pack. |
water-models | true | With the grid, packs' models that draw vanilla water (menu fluid bars) use an untouched copy. Pack. |
edge | soft | Where a fluid meets water: soft (fades) or sharp (a line). Pack. |
conflict | stop | stop: a fluid and plain water never share a 4-block color area. allow: they may, and the fluid fades into the water around it. |
fluid-gap | 2 | 4-block areas kept between two different fluids (2 is about 8 blocks). |
padding | 1 | 4-block areas around a fluid, where no water is, that get its color: cleaner shores. |
dispersion | 2 | With conflict: allow: areas where a fluid fades into plain water. |
client-jar | download | Where vanilla's textures and shaders come from: the official client jar, or the path of one. |
texture-grid | 8 | Most fluid textures per side of the grid: 8 holds 63 textures, 16 holds 255. |
update-delay | 10 | Ticks a changed chunk waits before its colors are sent (changes in between go together). |
entity-effects | true | Effects and drag on mobs and items too (players always). Restart. |
entity-ticks | 4 | Ticks between two scans for mobs and items in fluids. Restart. |
debug-colors | false | Shows how the shader reads each water face (below). Pack. |
Commands
All need machineengine.admin. Except info, they act on what you look at and
are for players only.
| Command | Does |
|---|---|
/machineengine fluid info | Fluids, looks, updates sent; and for the block you look at, its fluid and color area. |
/machineengine fluid show <fluid> [radius] | Particles at your feet: green where the fluid may go, red where it may not. show off stops it. |
/machineengine fluid fill <fluid|water> [max] | The water you look at, and the water joined to it (up to max, 4000), becomes the fluid (or plain water). |
/machineengine fluid bucket <fluid> | Gives you the fluid's bucket. |
/machineengine fluid clear | Turns every placeable fluid of your world back into plain water. |
/machineengine reload fluids | Reloads fluids.yml and rebuilds the pack. |
How it works, and its limits
A placed fluid is vanilla water underneath: it flows, swims and drowns like water, and MachineEngine remembers which water blocks hold which fluid (saved in the chunk). Players see the difference because MachineEngine colors that water with a code, and the resource pack's shader turns each code into its fluid's look.
The client colors water by 4-block areas (biome cells) and blends the areas around each block. That sets the rules:
- Two different fluids keep a gap (
fluid-gap). Blended together, two codes are no fluid at all, so the blocks between them would show plain water. Placing a fluid too close to another is refused, andfluid showtells you where it may go. - A fluid and plain water don't share an area under
conflict: stop: a fluid stops where plain water uses the area, and the other way round. - Biome Blend (Video Settings) spreads colors a few blocks. With Sodium,
each corner also blends the blocks around it, so the tip of a fluid pointing
at another pool may fade a little.
fluid-gap: 3removes that. Very wide Biome Blend (15×15) needs a wider gap.
Troubleshooting
A fluid shows as water
Set debug-colors: true, then /machineengine reload config,
/machineengine reload fluids and /ce reload pack. Water faces show what the
shader read:
| Color | Meaning |
|---|---|
| Green | The fluid, drawn fully. |
| Yellow | The fluid, fading into water. |
| Orange | Water with no fluid found: two fluids' colors mixed (too close, see fluid-gap). |
| Magenta | Plain water. |
| Looks like water | The shader did not run: an old Sodium, OptiFine or a shader pack. |
/machineengine fluid info, looking at the block, tells you what the server
sent for it and the 8 blocks around. Set debug-colors back to false and
rebuild the pack when you are done.
Players see a grid on all water
Their renderer does not read the pack's shader (Sodium before 0.9, OptiFine, a
shader pack). Use textures: tint, or keep auto on versions before 26.2.
The pack is not built
The first build downloads the client jar from Mojang (and Sodium from Modrinth).
Without internet access, set client-jar (and sodium-jar) to the path of a
jar. The console tells you what was written.
For developers
The same fluids can be made in code:
FluidType.builder(key).placeable()…build() from
fr.robie.machineengine.api.resource.fluid. WorldFluids
(fr.robie.machineengine.api.paper) reads, places and takes fluids in the
world, and WorldFluidPlaceEvent, WorldFluidRemoveEvent and
EntityFluidEvent (enter, leave) tell you when that happens. Your own effect,
mixing result and texture types register like other MachineEngine types.
Last updated on