High-level JavaScript API for creating Minecraft bots with comprehensive world interaction, entity management, and gameplay automation
—
Pending
Does it follow best practices?
Impact
Pending
No eval scenarios have been run
Pending
The risk profile of this skill
Advanced movement control with physics simulation, pathfinding integration, and precise positioning for sophisticated bot navigation and environmental interaction.
Control bot movement through directional states and manual controls.
/**
* Set a movement control state (forward, back, left, right, jump, sprint, sneak)
* @param control - Control state to modify
* @param state - Enable or disable the control
*/
setControlState(control: ControlState, state: boolean): void;
/**
* Get the current state of a movement control
* @param control - Control state to check
* @returns True if control is currently active
*/
getControlState(control: ControlState): boolean;
/**
* Clear all movement control states
*/
clearControlStates(): void;
type ControlState = "forward" | "back" | "left" | "right" | "jump" | "sprint" | "sneak";
interface ControlStateStatus {
forward: boolean;
back: boolean;
left: boolean;
right: boolean;
jump: boolean;
sprint: boolean;
sneak: boolean;
}Usage Examples:
// Basic movement
bot.setControlState("forward", true);
setTimeout(() => bot.setControlState("forward", false), 2000); // Move forward for 2 seconds
// Strafe right while moving forward
bot.setControlState("forward", true);
bot.setControlState("right", true);
// Jump and sprint
bot.setControlState("jump", true);
bot.setControlState("sprint", true);
// Check current movement state
if (bot.getControlState("sneak")) {
console.log("Bot is currently sneaking");
}
// Stop all movement
bot.clearControlStates();Control bot's view direction and camera orientation.
/**
* Look at a specific world position
* @param point - Target position to look at
* @param force - Force looking even if already looking in that direction
* @returns Promise that resolves when look action completes
*/
lookAt(point: Vec3, force?: boolean): Promise<void>;
/**
* Look in a specific direction using yaw and pitch
* @param yaw - Horizontal rotation in radians
* @param pitch - Vertical rotation in radians
* @param force - Force looking even if already in that direction
* @returns Promise that resolves when look action completes
*/
look(yaw: number, pitch: number, force?: boolean): Promise<void>;Usage Examples:
// Look at specific coordinates
await bot.lookAt(new Vec3(100, 64, 200));
// Look at nearest player
const player = bot.nearestEntity(entity => entity.type === "player");
if (player) {
await bot.lookAt(player.position.offset(0, 1.6, 0)); // Look at head level
}
// Look in cardinal directions
await bot.look(0, 0); // North
await bot.look(Math.PI/2, 0); // East
await bot.look(Math.PI, 0); // South
await bot.look(-Math.PI/2, 0); // West
// Look up and down
await bot.look(0, -Math.PI/2); // Look straight up
await bot.look(0, Math.PI/2); // Look straight downAdvanced movement capabilities including elytra flight and special movement modes.
/**
* Activate elytra flight (requires equipped elytra)
* @returns Promise that resolves when elytra activates
*/
elytraFly(): Promise<void>;
/**
* Swing the bot's arm
* @param hand - Which hand to swing ("left" or "right")
* @param showHand - Whether to show hand animation to other players
*/
swingArm(hand: "left" | "right" | undefined, showHand?: boolean): void;Access and configure physics simulation parameters.
interface Bot {
/** Current physics options */
physics: PhysicsOptions;
/** Whether physics simulation is enabled */
physicsEnabled: boolean;
}
interface PhysicsOptions {
/** Maximum ground movement speed */
maxGroundSpeed: number;
/** Terminal falling velocity */
terminalVelocity: number;
/** Walking acceleration */
walkingAcceleration: number;
/** Gravity force */
gravity: number;
/** Ground friction coefficient */
groundFriction: number;
/** Player collision box width radius */
playerApothem: number;
/** Player height */
playerHeight: number;
/** Jump velocity */
jumpSpeed: number;
/** Yaw rotation speed */
yawSpeed: number;
/** Pitch rotation speed */
pitchSpeed: number;
/** Sprint speed multiplier */
sprintSpeed: number;
/** Maximum speed on soul sand */
maxGroundSpeedSoulSand: number;
/** Maximum speed in water */
maxGroundSpeedWater: number;
}Access current position and movement state information.
interface Bot {
/** Bot's entity with position and movement data */
entity: Entity;
/** Current control states */
controlState: ControlStateStatus;
}
interface Entity {
/** Current world position */
position: Vec3;
/** Current velocity vector */
velocity: Vec3;
/** Horizontal rotation (yaw) in radians */
yaw: number;
/** Vertical rotation (pitch) in radians */
pitch: number;
/** Whether entity is on ground */
onGround: boolean;
/** Whether entity is in water */
inWater: boolean;
/** Whether entity is in lava */
inLava: boolean;
/** Whether entity is in web */
inWeb: boolean;
}Monitor movement and physics events.
interface BotEvents {
/** Bot moved to a new position */
move(position: Vec3): void;
/** Bot was moved by server (teleport, knockback, etc.) */
forcedMove(): void;
/** Bot mounted a vehicle/entity */
mount(): void;
/** Bot dismounted from vehicle */
dismount(vehicle: Entity): void;
/** Physics simulation tick */
physicsTick(): void;
/** Legacy physics tick event (typo kept for compatibility) */
physicTick(): void;
}Usage Examples:
// Monitor movement
bot.on("move", (position) => {
console.log(`Bot moved to: ${position}`);
});
bot.on("forcedMove", () => {
console.log("Bot was teleported or pushed by server");
});
// Track mounting
bot.on("mount", () => {
console.log("Bot mounted a vehicle");
});
bot.on("dismount", (vehicle) => {
console.log(`Bot dismounted from ${vehicle.type}`);
});
// Physics simulation monitoring
bot.on("physicsTick", () => {
// Called every physics update (20 times per second)
const pos = bot.entity.position;
const vel = bot.entity.velocity;
// console.log(`Position: ${pos}, Velocity: ${vel}`);
});Examples of complex movement behaviors and patterns.
// Follow a player
function followPlayer(username: string, distance: number = 3) {
const player = bot.players[username];
if (!player?.entity) return;
const target = player.entity.position;
const botPos = bot.entity.position;
const distanceToPlayer = botPos.distanceTo(target);
if (distanceToPlayer > distance) {
// Move towards player
bot.lookAt(target);
bot.setControlState("forward", true);
if (distanceToPlayer > distance * 2) {
bot.setControlState("sprint", true);
}
} else {
// Stop when close enough
bot.setControlState("forward", false);
bot.setControlState("sprint", false);
}
}
// Circle around a point
async function circleAround(center: Vec3, radius: number, speed: number = 0.1) {
let angle = 0;
const circleInterval = setInterval(async () => {
const targetX = center.x + Math.cos(angle) * radius;
const targetZ = center.z + Math.sin(angle) * radius;
const target = new Vec3(targetX, center.y, targetZ);
await bot.lookAt(center); // Look at center while circling
await bot.lookAt(target); // Then look at movement direction
bot.setControlState("forward", true);
angle += speed;
if (angle > Math.PI * 2) {
clearInterval(circleInterval);
bot.clearControlStates();
}
}, 50);
}
// Jump across gaps
async function jumpGap() {
bot.setControlState("forward", true);
bot.setControlState("sprint", true);
// Jump when approaching edge
setTimeout(() => {
bot.setControlState("jump", true);
}, 500);
// Land and stop
setTimeout(() => {
bot.clearControlStates();
}, 1500);
}
// Parkour movement with timing
async function parkourJump(direction: ControlState, jumpTiming: number) {
return new Promise<void>((resolve) => {
bot.setControlState(direction, true);
bot.setControlState("sprint", true);
setTimeout(() => {
bot.setControlState("jump", true);
}, jumpTiming);
setTimeout(() => {
bot.clearControlStates();
resolve();
}, jumpTiming + 1000);
});
}Helper functions for movement calculations and positioning.
// Calculate movement direction
function getDirectionToTarget(target: Vec3): ControlState[] {
const bot_pos = bot.entity.position;
const dx = target.x - bot_pos.x;
const dz = target.z - bot_pos.z;
const controls: ControlState[] = [];
if (Math.abs(dx) > 0.5) {
controls.push(dx > 0 ? "right" : "left");
}
if (Math.abs(dz) > 0.5) {
controls.push(dz > 0 ? "forward" : "back");
}
return controls;
}
// Check if bot should jump
function shouldJump(): boolean {
const frontBlock = bot.blockAt(bot.entity.position.offset(0, 0, 1));
const frontGroundBlock = bot.blockAt(bot.entity.position.offset(0, -1, 1));
return frontBlock?.type !== 0 && frontGroundBlock?.type !== 0; // Block in front and ground exists
}
// Safe movement with obstacle avoidance
function safeMoveTo(target: Vec3) {
const directions = getDirectionToTarget(target);
directions.forEach(dir => bot.setControlState(dir, true));
if (shouldJump()) {
bot.setControlState("jump", true);
}
// Stop when close to target
if (bot.entity.position.distanceTo(target) < 1) {
bot.clearControlStates();
}
}