Make fishing rods not actually target water

This commit is contained in:
2026-10-07 18:00:37 -03:00
parent b128da0631
commit b6b10e35e2
10 changed files with 374 additions and 70 deletions
+32
View File
@@ -16,6 +16,7 @@ export interface ServerContext {
players: PlayerList;
containers: ContainerApi;
items: ItemApi;
blocks: BlockApi;
recipes: RecipeApi;
tags: TagApi;
menus: MenuRegistry;
@@ -215,6 +216,9 @@ export interface ServerWorld {
drop_item(x: number, y: number, z: number, item: ItemStack): void;
// an entity from entities/ with its feet at x y z. throws for kinds that don't exist
spawn_entity(id: Id, x: number, y: number, z: number): EntityRef;
// the first block on the line from one point to another, like minecraft's Level.clip. it hits what entities bump
// into, so it goes through plants and other blocks without collision. undefined when nothing is in the way
raycast(from: Position, to: Position, options?: RaycastOptions): RaycastHit | undefined;
is_loaded(x: number, z: number): boolean;
readonly seed: string;
// ticks since 06:00 of day 1. a day is 36000 ticks (06:00 to 18:00), a night 12000
@@ -224,6 +228,24 @@ export interface ServerWorld {
set_time(time: number): void;
}
export interface RaycastOptions {
// like minecraft's ClipContext.Fluid: "none" (the default) goes through liquids, "source_only" hits their sources
// and goes through where they flow, "any" hits all of them. a liquid is hit at its surface
liquids?: "none" | "source_only" | "any";
}
export interface RaycastHit {
// the block it hit, and where that is
readonly id: Id;
readonly x: number;
readonly y: number;
readonly z: number;
// the side it went in by
readonly face: Face;
// the exact point it hit
readonly position: Readonly<Position>;
}
// an entity in the world. once it's removed, by a script or anything else, it stays removed and moving it does nothing
export interface EntityRef {
readonly id: string;
@@ -238,6 +260,10 @@ export interface Player {
readonly id: string;
readonly name: string;
readonly position: Readonly<Position>;
// where they see from, lower while swimming, and which way they look as a vector 1 long. for aiming, like
// ctx.world.raycast(player.eye_position, ...)
readonly eye_position: Readonly<Position>;
readonly look_direction: Readonly<Position>;
readonly inventory: Container; // 36 slots, hotbar is 0-8
readonly selected_slot: number;
readonly held_item: ItemStack | undefined;
@@ -344,6 +370,12 @@ export interface ItemApi {
components(id: Id): Record<Id, unknown>;
}
export interface BlockApi {
exists(id: Id): boolean;
// the components its json lists and their params, a copy, like ItemApi.components
components(id: Id): Record<Id, unknown>;
}
export interface RecipeApi {
furnace_result(input: Id): { output: ItemStack; cook_time: number } | undefined;
fuel_value(item: Id): number; // burn time in ticks, 0 if it isn't fuel