Make fishing rods not actually target water
This commit is contained in:
@@ -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