Make fishing rods not actually target water
This commit is contained in:
@@ -164,7 +164,7 @@ catch up. If it's further behind than that, it skips the rest and logs a warning
|
||||
| `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` | none | Can be fished in with the fishing rod. |
|
||||
| `bworld:fishable` | none | The fishing rod's hook floats on it and fish bite there when it lands in it. |
|
||||
| `bworld:trapdoor` | none | Opens and closes when right clicked, and is placed like Minecraft's (its rules are 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. |
|
||||
|
||||
|
||||
@@ -158,3 +158,30 @@ still going when the server stops don't carry on after it starts again until som
|
||||
grass, leaves and water, or a fixed color like `"#80a755"`. `textures` lists the texture variables to tint, like only
|
||||
the grass block's top. Without it every texture is tinted. In inventories, where there's no biome, the block uses
|
||||
plains' color.
|
||||
|
||||
## Raycasts
|
||||
|
||||
Server scripts find the first block on a line with `ctx.world.raycast`, like Minecraft's `Level.clip`. The fishing rod's
|
||||
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" });
|
||||
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
|
||||
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. |
|
||||
|
||||
A liquid 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