Make fishing rods not actually target water
This commit is contained in:
@@ -20,6 +20,8 @@ interface Player {
|
||||
readonly id: string;
|
||||
readonly name: string;
|
||||
readonly position: { x: number; y: number; z: number }; // their feet
|
||||
readonly eye_position: { x: number; y: number; z: number }; // where they see from, lower while swimming
|
||||
readonly look_direction: { x: number; y: number; z: number }; // which way they look, 1 long
|
||||
readonly inventory: Container; // 36 slots, the hotbar is 0-8
|
||||
readonly selected_slot: number;
|
||||
readonly held_item: ItemStack | undefined;
|
||||
@@ -54,6 +56,17 @@ interface Player {
|
||||
`inventory` is a live [container](../inventories/containers.md), and `held_item` a live stack: changing them changes
|
||||
what the player has.
|
||||
|
||||
`eye_position` and `look_direction` are for aiming. With [`ctx.world.raycast`](../blocks/index.md#raycasts) they find
|
||||
what a player is looking at, like Minecraft's `getPlayerPOVHitResult`:
|
||||
|
||||
```ts
|
||||
const eye = player.eye_position;
|
||||
const look = player.look_direction;
|
||||
const reach = 5;
|
||||
const to = { x: eye.x + look.x * reach, y: eye.y + look.y * reach, z: eye.z + look.z * reach };
|
||||
const hit = ctx.world.raycast(eye, to, { liquids: "source_only" });
|
||||
```
|
||||
|
||||
## Health and Hunger
|
||||
|
||||
Players follow Minecraft's rules, with 20 health (10 hearts) and 20 hunger:
|
||||
|
||||
Reference in New Issue
Block a user