Rename all "liquid" mentions to "fluid"
This commit is contained in:
@@ -87,7 +87,7 @@ when what it hangs from is gone. A block whose states follow from its neighbors,
|
||||
clients see it change right away.
|
||||
|
||||
`on_state_change` runs when the block's states change and it stays the same block: a script's `ctx.world.set_state`, a
|
||||
rule, a liquid's level. `before` is every state as it was, by name, and `ctx.world.get_state` gives what they are now.
|
||||
rule, a fluid's level. `before` is every state as it was, by name, and `ctx.world.get_state` gives what they are now.
|
||||
It's how a block reacts to a state something else sets on it, like a machine another mod's script turns off. It runs
|
||||
right away, before the blocks beside it are told, like `on_create`. Replacing the block with `set_block` runs `on_break`
|
||||
and `on_create` instead, and setting a state to what it already is runs nothing.
|
||||
@@ -296,20 +296,20 @@ catch up. If it's further behind than that, it skips the rest and logs a warning
|
||||
|
||||
`mods/bworld/scripts/server.ts` registers these, and any mod that depends on `bworld` can use them:
|
||||
|
||||
| Component | Params | What it does |
|
||||
| ----------------------- | --------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| `bworld:storage` | `rows` | A chest: `rows` × 9 slots, dropped when it's broken. |
|
||||
| `bworld:shipping_bin` | `rows` | Like `bworld:storage`, and every morning at 06:00 sells what's in it with a `base_sell_value` for coins. |
|
||||
| `bworld:furnace` | none | Smelts with `furnace` and `fuel` [recipes](../resources/recipes.md). Needs `lit` and `facing` states, see `blocks/furnace.json`. |
|
||||
| `bworld:smithing_table` | none | Upgrades tools with `smithing` recipes. |
|
||||
| `bworld:stonecutter` | none | Cuts one item into another with `bworld:stonecutting` recipes, picked from a list. |
|
||||
| `bworld:hoeable` | `tool`, `into` | Right clicking with a tool of type `tool` turns it into `into`, like a hoe on grass. |
|
||||
| `bworld:farmland` | none | Watered with the watering can, dries out every morning. |
|
||||
| `bworld:crop` | see [Crops](crops.md) | Grows a stage every morning its farmland was watered. |
|
||||
| `bworld:crop_top` | see [Crops](crops.md) | The top half of a two block crop, like rice. |
|
||||
| `bworld:water_source` | none | Refills the watering can. |
|
||||
| `bworld:fishable` | `loot_table`? | The fishing rod's hook floats on it and fish bite there when it lands in it. What's caught is `loot_table`, `bworld:gameplay/fishing` when not given, built from the fish whose `liquid` is this block. |
|
||||
| `bworld:trapdoor` | none | Opens and closes when right clicked, and is placed like Minecraft's (both are rules, in the shared script). Needs `facing` (2 bits), `half` and `open` states, see `blocks/oak_trapdoor.json`. |
|
||||
| `bworld:fence` | `connects_to` | Joins the blocks in the tag `connects_to` and sturdy sides of other blocks, except leaves. Needs the `north`, `east`, `south` and `west` states. |
|
||||
| Component | Params | What it does |
|
||||
| ----------------------- | --------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
||||
| `bworld:storage` | `rows` | A chest: `rows` × 9 slots, dropped when it's broken. |
|
||||
| `bworld:shipping_bin` | `rows` | Like `bworld:storage`, and every morning at 06:00 sells what's in it with a `base_sell_value` for coins. |
|
||||
| `bworld:furnace` | none | Smelts with `furnace` and `fuel` [recipes](../resources/recipes.md). Needs `lit` and `facing` states, see `blocks/furnace.json`. |
|
||||
| `bworld:smithing_table` | none | Upgrades tools with `smithing` recipes. |
|
||||
| `bworld:stonecutter` | none | Cuts one item into another with `bworld:stonecutting` recipes, picked from a list. |
|
||||
| `bworld:hoeable` | `tool`, `into` | Right clicking with a tool of type `tool` turns it into `into`, like a hoe on grass. |
|
||||
| `bworld:farmland` | none | Watered with the watering can, dries out every morning. |
|
||||
| `bworld:crop` | see [Crops](crops.md) | Grows a stage every morning its farmland was watered. |
|
||||
| `bworld:crop_top` | see [Crops](crops.md) | The top half of a two block crop, like rice. |
|
||||
| `bworld:water_source` | none | Refills the watering can. |
|
||||
| `bworld:fishable` | `loot_table`? | The fishing rod's hook floats on it and fish bite there when it lands in it. What's caught is `loot_table`, `bworld:gameplay/fishing` when not given, built from the fish whose `fluid` is this block. |
|
||||
| `bworld:trapdoor` | none | Opens and closes when right clicked, and is placed like Minecraft's (both are rules, in the shared script). Needs `facing` (2 bits), `half` and `open` states, see `blocks/oak_trapdoor.json`. |
|
||||
| `bworld:fence` | `connects_to` | Joins the blocks in the tag `connects_to` and sturdy sides of other blocks, except leaves. Needs the `north`, `east`, `south` and `west` states. |
|
||||
|
||||
Item components work the same way, see [Items](../items/index.md#item-components).
|
||||
|
||||
@@ -53,7 +53,7 @@ there will be holes in the world behind them.
|
||||
|
||||
| Field | Default | Meaning |
|
||||
| ---------------------- | ----------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| `collision` | `true` | Whether entities bump into it. Plants set `false`, and liquids default to it. |
|
||||
| `collision` | `true` | Whether entities bump into it. Plants set `false`, and fluids default to it. |
|
||||
| `shape` | its model | The boxes players point at and entities bump into, in pixels. See [Shapes](../resources/models.md#shapes). |
|
||||
| `collision_shape` | `shape` | What entities bump into when it's different, up to 24 pixels high. See [Collision Shapes](../resources/models.md#collision-shapes). |
|
||||
| `mining.toughness` | unbreakable | Seconds to break by hand. Without `mining`, a block can't be broken. |
|
||||
@@ -65,13 +65,13 @@ there will be holes in the world behind them.
|
||||
| `item` | `true` | Also register an item that places it, with the same id. To give that item more, see [Block Items](../items/index.md#block-items). |
|
||||
| `interactive` | `false` | Right clicking it does something, like opening a screen, so clients don't guess that it places a block. |
|
||||
| `scrollable` | `false` | The mouse wheel turned while looking at it goes to its components' `on_scroll` instead of the hotbar, see [Scrolling](components.md#scrolling). |
|
||||
| `replaceable` | `false` | Placing a block into it replaces it, like water. Liquids default to `true`. |
|
||||
| `replaceable` | `false` | Placing a block into it replaces it, like water. Fluids default to `true`. |
|
||||
| `place_in` | see meaning | Block ids or [tags](../resources/tags.md) it can be placed into, replacing them, like `["bworld:water"]` for rice. Air and `replaceable` blocks when not set. |
|
||||
| `place_on` | anywhere | Block ids or [tags](../resources/tags.md) it can stand on, like `["bworld:hoed_dirt"]` for crops or `["#bworld:logs"]`. See [below](#placement). |
|
||||
| `states` | none | Named [state](states.md) bits, like a crop's age. |
|
||||
| `components` | none | [Components](components.md) and their parameters. |
|
||||
| `item_display` | none | Shows an item on top of it, see [Tile Data](tiledata.md#showing-an-item). |
|
||||
| `liquid` | none | Makes it a liquid, like water. See [Liquids](#liquids). |
|
||||
| `fluid` | none | Makes it a fluid, like water. See [Fluids](#fluids). |
|
||||
|
||||
A block's definition goes to every player, since clients need it to draw the block, time breaking and collide with it.
|
||||
It can't hold functions.
|
||||
@@ -129,11 +129,10 @@ crop when its farmland is dug up.
|
||||
|
||||
Food that places a block, like potatoes, is planted when clicked somewhere it can go and eaten otherwise.
|
||||
|
||||
## Liquids
|
||||
## Fluids
|
||||
|
||||
A block with `liquid` is a liquid, like water. The engine draws it like Luanti's liquids: each corner of its surface is
|
||||
as high as the liquid around it, so it slopes down from a source to where it flows, and it thins out to a film at the
|
||||
shore.
|
||||
A block with `fluid` is a fluid, like water. The engine draws it like Luanti's fluids: each corner of its surface is as
|
||||
high as the fluid around it, so it slopes down from a source to where it flows, and it thins out to a film at the shore.
|
||||
|
||||
`mods/oily/blocks/oil.json`:
|
||||
|
||||
@@ -145,7 +144,7 @@ shore.
|
||||
"textures": { "still": "oily:oil_still", "flowing": "oily:oil_flowing" },
|
||||
"render_layer": "translucent",
|
||||
"alpha": 0.9,
|
||||
"liquid": { "range": 4 }
|
||||
"fluid": { "range": 4 }
|
||||
}
|
||||
}
|
||||
```
|
||||
@@ -154,9 +153,9 @@ shore.
|
||||
top. `flowing` is on its sides and on a sloping top, turned to run downhill. A block shows as many of `flowing`'s
|
||||
pixels across as `still` has, so a 32×32 `flowing` next to a 16×16 `still` spreads over two blocks. With one texture,
|
||||
it's all of that texture on every side. Either can be [animated](../resources/textures.md#animated-textures).
|
||||
- `liquid.range` is how many blocks it flows from a source, 1 to 7, and `7` when not set.
|
||||
- `liquid.ticks` is how many ticks each step of its flow takes, `5` when not set, like Minecraft's water. Lava's is 30.
|
||||
- `liquid.renewable`, `true` when not set: a spot with two sources beside it and something solid or a source under it
|
||||
- `fluid.range` is how many blocks it flows from a source, 1 to 7, and `7` when not set.
|
||||
- `fluid.ticks` is how many ticks each step of its flow takes, `5` when not set, like Minecraft's water. Lava's is 30.
|
||||
- `fluid.renewable`, `true` when not set: a spot with two sources beside it and something solid or a source under it
|
||||
becomes a source too, like Minecraft's infinite water.
|
||||
- It gets a `level` [state](states.md) of its own, after any it lists: `0` is a source, a full block, and `1` up to
|
||||
`range` as it flows away from one, each lower.
|
||||
@@ -168,43 +167,43 @@ shore.
|
||||
|
||||
### Flowing
|
||||
|
||||
Liquids flow on the server like Minecraft's water. When a block next to a liquid changes, the cells around it are looked
|
||||
Fluids flow on the server like Minecraft's water. When a block next to a fluid changes, the cells around it are looked
|
||||
at again after its `ticks`, and each works out what it should be:
|
||||
|
||||
- A source stays a source.
|
||||
- With the same liquid above, it's falling, and drawn full.
|
||||
- Otherwise it's one level more than the lowest of the liquid beside it that spreads sideways, and gone once that's past
|
||||
`range`. Sources spread sideways, and flowing liquid only does when it's on something solid: over air or more of
|
||||
- With the same fluid above, it's falling, and drawn full.
|
||||
- Otherwise it's one level more than the lowest of the fluid beside it that spreads sideways, and gone once that's past
|
||||
`range`. Sources spread sideways, and flowing fluid only does when it's on something solid: over air or more of
|
||||
itself, it falls instead.
|
||||
|
||||
So it spreads one block a step, falls off edges and spreads again where it lands, and drains away a step at a time once
|
||||
its source is gone. It only flows into air, and stops at chunks that aren't loaded. Buckets only pick up sources. Flows
|
||||
still going when the server stops don't carry on after it starts again until something next to them changes.
|
||||
|
||||
`ctx.world.liquid_flow(x, y, z)` says which way the liquid in a block flows, like Minecraft's `FluidState.getFlow`: a
|
||||
vector 1 long toward the lower liquid beside it, and down where it falls against a wall, or `{ x: 0, y: 0, z: 0 }` where
|
||||
`ctx.world.fluid_flow(x, y, z)` says which way the fluid in a block flows, like Minecraft's `FluidState.getFlow`: a
|
||||
vector 1 long toward the lower fluid beside it, and down where it falls against a wall, or `{ x: 0, y: 0, z: 0 }` where
|
||||
it's still or there's none. It's the same flow that pushes players and items along, for machines it turns, like a water
|
||||
wheel.
|
||||
|
||||
### Waterlogging
|
||||
|
||||
A block that isn't a liquid can hold one, like Minecraft's waterlogged fences. `waterloggable` names the liquid:
|
||||
A block that isn't a fluid can hold one, like Minecraft's waterlogged fences. `waterloggable` names the fluid:
|
||||
|
||||
```json
|
||||
"waterloggable": "bworld:water"
|
||||
```
|
||||
|
||||
- It gets a `waterlogged` [state](states.md) of its own, after any it lists: `1` while it holds a source of the liquid.
|
||||
- It gets a `waterlogged` [state](states.md) of its own, after any it lists: `1` while it holds a source of the fluid.
|
||||
It uses one of the block's 16 bits.
|
||||
- Placed into a source of the liquid, it holds it. Placed into flowing liquid or anything else, it doesn't. With
|
||||
- Placed into a source of the fluid, it holds it. Placed into flowing fluid or anything else, it doesn't. With
|
||||
`"waterlogged_only": true` it can only be placed into a source, so it's always placed holding it, like Farmer's
|
||||
Delight's rice.
|
||||
- Using the liquid's item on it, like a water bucket, fills it. An item that aims at liquids, like a bucket, uses the
|
||||
liquid in it instead of the block, so a bucket takes the water back out and the block stays.
|
||||
- It's a source of the liquid that never drains: the liquid flows out of it, and entities swim and are pushed in it.
|
||||
Flowing liquid doesn't flow into it.
|
||||
- Broken, it leaves a source of the liquid behind.
|
||||
- Raycasts with `liquids` other than `"none"` hit the liquid in it, filling the block, and say the liquid's id.
|
||||
- Using the fluid's item on it, like a water bucket, fills it. An item that aims at fluids, like a bucket, uses the
|
||||
fluid in it instead of the block, so a bucket takes the water back out and the block stays.
|
||||
- It's a source of the fluid that never drains: the fluid flows out of it, and entities swim and are pushed in it.
|
||||
Flowing fluid doesn't flow into it.
|
||||
- Broken, it leaves a source of the fluid behind.
|
||||
- Raycasts with `fluids` other than `"none"` hit the fluid in it, filling the block, and say the fluid's id.
|
||||
|
||||
The base game's wooden fences are waterloggable, and Farmer's Delight's rice is `waterlogged_only`.
|
||||
|
||||
@@ -228,22 +227,22 @@ hook uses it to see where it lands, and with a player's
|
||||
[`eye_position` and `look_direction`](../entities/players.md#the-player-api) it finds what they're looking at:
|
||||
|
||||
```ts
|
||||
const hit = ctx.world.raycast(from, to, { liquids: "any" });
|
||||
const hit = ctx.world.raycast(from, to, { fluids: "any" });
|
||||
if (hit && "bworld:fishable" in ctx.blocks.components(hit.id)) {
|
||||
// hit.x, hit.y, hit.z is the block, hit.face the side it went in by, hit.position the exact point
|
||||
}
|
||||
```
|
||||
|
||||
It hits what entities bump into, so it goes through plants and other blocks with `"collision": false`. `liquids` is like
|
||||
It hits what entities bump into, so it goes through plants and other blocks with `"collision": false`. `fluids` is like
|
||||
Minecraft's `ClipContext.Fluid`:
|
||||
|
||||
| `liquids` | Hits |
|
||||
| ------------------ | ------------------------------------------- |
|
||||
| `"none"` (default) | No liquids, it goes through them. |
|
||||
| `"source_only"` | Liquid sources, going through flowing ones. |
|
||||
| `"any"` | Every liquid. |
|
||||
| `fluids` | Hits |
|
||||
| ------------------ | ------------------------------------------ |
|
||||
| `"none"` (default) | No fluids, it goes through them. |
|
||||
| `"source_only"` | Fluid sources, going through flowing ones. |
|
||||
| `"any"` | Every fluid. |
|
||||
|
||||
A liquid is hit at its surface, which is lower where it flows. It returns `undefined` when nothing is in the way.
|
||||
A fluid is hit at its surface, which is lower where it flows. It returns `undefined` when nothing is in the way.
|
||||
|
||||
`ctx.blocks.components(id)` gives the components a block's json lists and their params, like `ctx.items.components`, and
|
||||
`ctx.blocks.exists(id)` whether a block exists.
|
||||
|
||||
Reference in New Issue
Block a user