@nxg-org/mineflayer-tracker
Version:
Provides functionality for more accurate entity and projectile tracking.
91 lines (90 loc) • 2.92 kB
TypeScript
import { Entity } from "prismarine-entity";
import { Bot, Effect } from "mineflayer";
import { Vec3 } from "vec3";
import { Physics } from "../engines/physics";
import { ControlStateHandler } from "../player/playerControls";
import { PlayerPoses } from "./poses";
import { PlayerState } from "./playerState";
import { AABB } from "@nxg-org/mineflayer-util-plugin";
export interface EntityStateBuilder {
position: Vec3;
velocity: Vec3;
pitch: number;
yaw: number;
controlState: ControlStateHandler;
onGround: boolean;
isUsingItem?: boolean;
isInWater?: boolean;
isInLava?: boolean;
isInWeb?: boolean;
sneakCollision?: boolean;
isCollidedHorizontally?: boolean;
isCollidedVertically?: boolean;
effects?: Effect[];
jumpBoost?: number;
speed?: number;
slowness?: number;
dolphinsGrace?: number;
slowFalling?: number;
levitation?: number;
depthStrider?: number;
}
export declare class EntityState implements EntityStateBuilder {
ctx: Physics;
position: Vec3;
velocity: Vec3;
onGround: boolean;
controlState: ControlStateHandler;
yaw: number;
pitch: number;
isInWater: boolean;
isInLava: boolean;
isInWeb: boolean;
isCollidedHorizontally: boolean;
isCollidedVertically: boolean;
jumpTicks: number;
jumpQueued: boolean;
sneakCollision: boolean;
attributes: any;
isUsingItem: boolean;
isUsingMainHand: boolean;
isUsingOffHand: boolean;
jumpBoost: number;
speed: number;
slowness: number;
dolphinsGrace: number;
slowFalling: number;
levitation: number;
depthStrider: number;
effects: Effect[];
pose: PlayerPoses;
constructor(ctx: Physics, position: Vec3, velocity: Vec3, onGround: boolean, controlState: ControlStateHandler, yaw: number, pitch: number);
static CREATE_FROM_BOT(ctx: Physics, bot: Bot): EntityState;
static CREATE_FROM_ENTITY(ctx: Physics, entity: Entity): EntityState;
static CREATE_FROM_PLAYER_STATE(ctx: Physics, state: PlayerState): EntityState;
/**
* Slightly different from the other two, use a pre-built object (assuming cloned) material.
* @param ctx Physics instance.
* @param raw CONSUMEABLE, build this with clones.
* @returns PhysicsState
*/
static CREATE_RAW(ctx: Physics, raw: EntityStateBuilder): EntityState;
updateFromBot(bot: Bot): EntityState;
updateFromEntity(entity: Entity): this;
updateFromRaw(other: EntityStateBuilder): this;
applyToBot(bot: Bot): this;
/**
* No idea when you'd use this.
*/
applyToEntity(entity: Entity): this;
clone(): EntityState;
merge(other: EntityState): this;
clearControlStates(): EntityState;
/**
* needs to be updated.
* @returns AABB
*/
getAABB(): AABB;
getUnderlyingBlockBBs(world: any): AABB[];
getSurroundingBBs(world: any): AABB[];
}