or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

tessl/npm-mineflayer

High-level JavaScript API for creating Minecraft bots with comprehensive world interaction, entity management, and gameplay automation

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
npmpkg:npm/mineflayer@4.32.x

To install, run

npx @tessl/cli install tessl/npm-mineflayer@4.32.0

0

# Mineflayer

1

2

Mineflayer is a comprehensive JavaScript/TypeScript library for creating Minecraft bots with a stable, high-level API. It provides extensive functionality for world interaction, entity management, inventory control, communication, and gameplay automation across Minecraft versions 1.8.8 through 1.21.6.

3

4

## Package Information

5

6

- **Package Name**: mineflayer

7

- **Package Type**: npm

8

- **Language**: JavaScript/TypeScript

9

- **Installation**: `npm install mineflayer`

10

11

## Core Imports

12

13

```typescript

14

import {

15

createBot,

16

Bot,

17

BotOptions,

18

Location,

19

Painting,

20

ScoreBoard,

21

BossBar,

22

Particle,

23

testedVersions,

24

latestSupportedVersion,

25

oldestSupportedVersion,

26

supportFeature

27

} from "mineflayer";

28

```

29

30

For CommonJS:

31

32

```javascript

33

const {

34

createBot,

35

Location,

36

Painting,

37

ScoreBoard,

38

BossBar,

39

Particle,

40

testedVersions,

41

latestSupportedVersion,

42

oldestSupportedVersion,

43

supportFeature

44

} = require("mineflayer");

45

```

46

47

## Basic Usage

48

49

```typescript

50

import { createBot } from "mineflayer";

51

52

// Create a bot instance

53

const bot = createBot({

54

host: "localhost", // Server hostname

55

port: 25565, // Server port (default: 25565)

56

username: "MyBot", // Bot username

57

version: "1.20.1" // Minecraft version

58

});

59

60

// Basic event handling

61

bot.once("spawn", () => {

62

console.log("Bot spawned in the game!");

63

64

// Send a chat message

65

bot.chat("Hello, Minecraft world!");

66

67

// Move forward

68

bot.setControlState("forward", true);

69

70

// Look around

71

bot.look(0, 0); // yaw, pitch

72

});

73

74

// Handle chat messages

75

bot.on("chat", (username, message) => {

76

if (username === bot.username) return; // Ignore own messages

77

console.log(`${username}: ${message}`);

78

79

// Simple command response

80

if (message === "follow me") {

81

const player = bot.players[username];

82

if (player?.entity) {

83

bot.lookAt(player.entity.position);

84

}

85

}

86

});

87

88

// Handle errors

89

bot.on("error", (err) => {

90

console.error("Bot error:", err);

91

});

92

```

93

94

## Architecture

95

96

Mineflayer is built around several key architectural components:

97

98

- **Event-Driven Core**: Bot extends EventEmitter with 60+ events for comprehensive game state monitoring

99

- **Plugin System**: 30+ internal plugins provide modular functionality (blocks, entities, inventory, crafting, etc.)

100

- **Prismarine Ecosystem**: Deep integration with minecraft-protocol and prismarine-* packages for protocol handling, world representation, and data structures

101

- **High-Level Abstractions**: Simplified interfaces for complex Minecraft mechanics like pathfinding, combat, and resource management

102

- **Version Compatibility**: Automatic protocol version detection and data registry management for broad Minecraft version support

103

104

## Capabilities

105

106

### Bot Creation and Connection

107

108

Core functionality for creating bot instances and managing server connections with comprehensive configuration options.

109

110

```typescript { .api }

111

function createBot(options: BotOptions): Bot;

112

113

interface BotOptions {

114

host?: string;

115

port?: number;

116

username?: string;

117

password?: string;

118

version?: string | boolean;

119

auth?: "microsoft" | "mojang" | "offline";

120

client?: Client;

121

logErrors?: boolean;

122

hideErrors?: boolean;

123

plugins?: PluginOptions;

124

physicsEnabled?: boolean;

125

viewDistance?: ViewDistance;

126

difficulty?: number;

127

respawn?: boolean;

128

}

129

```

130

131

[Bot Management](./bot-management.md)

132

133

### World Interaction

134

135

Comprehensive world interaction capabilities including block querying, manipulation, and spatial analysis for environmental awareness and interaction.

136

137

```typescript { .api }

138

blockAt(point: Vec3, extraInfos?: boolean): Block | null;

139

findBlock(options: FindBlockOptions): Block | null;

140

canDigBlock(block: Block): boolean;

141

dig(block: Block, forceLook?: boolean | "ignore"): Promise<void>;

142

placeBlock(referenceBlock: Block, faceVector: Vec3): Promise<void>;

143

activateBlock(block: Block, direction?: Vec3): Promise<void>;

144

```

145

146

[World Interaction](./world-interaction.md)

147

148

### Entity Management

149

150

Entity tracking, interaction, and management system for comprehensive awareness of players, mobs, items, and other game entities.

151

152

```typescript { .api }

153

nearestEntity(filter?: (entity: Entity) => boolean): Entity | null;

154

attack(entity: Entity): void;

155

activateEntity(entity: Entity): Promise<void>;

156

mount(entity: Entity): void;

157

dismount(): void;

158

```

159

160

[Entity Management](./entity-management.md)

161

162

### Movement and Physics

163

164

Advanced movement control with physics simulation, pathfinding integration, and precise positioning for sophisticated bot navigation.

165

166

```typescript { .api }

167

setControlState(control: ControlState, state: boolean): void;

168

getControlState(control: ControlState): boolean;

169

lookAt(point: Vec3, force?: boolean): Promise<void>;

170

look(yaw: number, pitch: number, force?: boolean): Promise<void>;

171

172

type ControlState = "forward" | "back" | "left" | "right" | "jump" | "sprint" | "sneak";

173

```

174

175

[Movement and Physics](./movement-physics.md)

176

177

### Inventory and Items

178

179

Complete inventory management system with equipment handling, item manipulation, and container interaction for sophisticated resource management.

180

181

```typescript { .api }

182

equip(item: Item | number, destination: EquipmentDestination): Promise<void>;

183

toss(itemType: number, metadata: number | null, count: number | null): Promise<void>;

184

craft(recipe: Recipe, count?: number, craftingTable?: Block): Promise<void>;

185

setQuickBarSlot(slot: number): void;

186

187

type EquipmentDestination = "hand" | "head" | "torso" | "legs" | "feet" | "off-hand";

188

```

189

190

[Inventory and Items](./inventory-items.md)

191

192

### Container Management

193

194

Specialized interfaces for interacting with chests, furnaces, enchantment tables, and other container blocks with type-safe operations.

195

196

```typescript { .api }

197

openChest(chest: Block | Entity): Promise<Chest>;

198

openFurnace(furnace: Block): Promise<Furnace>;

199

openEnchantmentTable(enchantmentTable: Block): Promise<EnchantmentTable>;

200

openVillager(villager: Entity): Promise<Villager>;

201

```

202

203

[Container Management](./container-management.md)

204

205

### Communication

206

207

Chat handling with pattern matching, command processing, and messaging capabilities for interactive bot behavior and user communication.

208

209

```typescript { .api }

210

chat(message: string): void;

211

whisper(username: string, message: string): void;

212

addChatPattern(name: string, pattern: RegExp, options?: ChatPatternOptions): number;

213

awaitMessage(...patterns: (string | RegExp)[]): Promise<string>;

214

```

215

216

[Communication](./communication.md)

217

218

### Game Mechanics

219

220

Advanced game mechanic integrations including sleep management, fishing, book writing, and specialized interactions for complete gameplay automation.

221

222

```typescript { .api }

223

sleep(bedBlock: Block): Promise<void>;

224

fish(): Promise<void>;

225

writeBook(slot: number, pages: string[]): Promise<void>;

226

trade(villager: Villager, tradeIndex: string | number, times?: number): Promise<void>;

227

```

228

229

[Game Mechanics](./game-mechanics.md)

230

231

### Creative Mode

232

233

Specialized methods available when the bot is in creative mode, providing enhanced capabilities for inventory management and flight control.

234

235

```typescript { .api }

236

interface CreativeMethods {

237

/**

238

* Set an inventory slot to contain a specific item

239

* @param slot - Inventory slot number

240

* @param item - Item to place in slot, or null to clear

241

*/

242

setInventorySlot(slot: number, item: Item | null): Promise<void>;

243

244

/**

245

* Clear a specific inventory slot

246

* @param slot - Slot number to clear

247

*/

248

clearSlot(slot: number): Promise<void>;

249

250

/**

251

* Clear all items from the inventory

252

*/

253

clearInventory(): Promise<void>;

254

255

/**

256

* Fly directly to a destination position

257

* @param destination - Target position coordinates

258

*/

259

flyTo(destination: Vec3): Promise<void>;

260

261

/**

262

* Start flying mode

263

*/

264

startFlying(): void;

265

266

/**

267

* Stop flying mode

268

*/

269

stopFlying(): void;

270

}

271

```

272

273

### Bot Events

274

275

Comprehensive event system with 95+ events for monitoring all aspects of game state, entity behavior, world changes, and bot interactions.

276

277

```typescript { .api }

278

interface BotEvents {

279

// Connection and lifecycle events

280

inject_allowed: () => void;

281

login: () => void;

282

spawn: () => void;

283

respawn: () => void;

284

game: () => void;

285

end: (reason: string) => void;

286

kicked: (reason: string, loggedIn: boolean) => void;

287

error: (err: Error) => void;

288

289

// Chat and messaging events

290

chat: (username: string, message: string, translate: string | null, jsonMsg: ChatMessage, matches: string[] | null) => void;

291

whisper: (username: string, message: string, translate: string | null, jsonMsg: ChatMessage, matches: string[] | null) => void;

292

actionBar: (jsonMsg: ChatMessage) => void;

293

message: (jsonMsg: ChatMessage, position: string) => void;

294

messagestr: (message: string, position: string, jsonMsg: ChatMessage) => void;

295

unmatchedMessage: (stringMsg: string, jsonMsg: ChatMessage) => void;

296

297

// Player and entity events

298

playerJoined: (player: Player) => void;

299

playerUpdated: (player: Player) => void;

300

playerLeft: (player: Player) => void;

301

entitySpawn: (entity: Entity) => void;

302

entityGone: (entity: Entity) => void;

303

entityMoved: (entity: Entity) => void;

304

entityUpdate: (entity: Entity) => void;

305

entityAttributes: (entity: Entity) => void;

306

307

// Entity action events

308

entitySwingArm: (entity: Entity) => void;

309

entityHurt: (entity: Entity, source: Entity) => void;

310

entityDead: (entity: Entity) => void;

311

entityTaming: (entity: Entity) => void;

312

entityTamed: (entity: Entity) => void;

313

entityShakingOffWater: (entity: Entity) => void;

314

entityEatingGrass: (entity: Entity) => void;

315

entityHandSwap: (entity: Entity) => void;

316

entityWake: (entity: Entity) => void;

317

entityEat: (entity: Entity) => void;

318

entityCriticalEffect: (entity: Entity) => void;

319

entityMagicCriticalEffect: (entity: Entity) => void;

320

entityCrouch: (entity: Entity) => void;

321

entityUncrouch: (entity: Entity) => void;

322

entityEquip: (entity: Entity) => void;

323

entitySleep: (entity: Entity) => void;

324

entityElytraFlew: (entity: Entity) => void;

325

entityDetach: (entity: Entity, vehicle: Entity) => void;

326

entityAttach: (entity: Entity, vehicle: Entity) => void;

327

entityEffect: (entity: Entity, effect: Effect) => void;

328

entityEffectEnd: (entity: Entity, effect: Effect) => void;

329

330

// World and environment events

331

blockUpdate: (oldBlock: Block | null, newBlock: Block) => void;

332

'blockUpdate:(x, y, z)': (oldBlock: Block | null, newBlock: Block | null) => void;

333

chunkColumnLoad: (chunk: Vec3) => void;

334

chunkColumnUnload: (chunk: Vec3) => void;

335

rain: () => void;

336

time: () => void;

337

338

// Bot state events

339

health: () => void;

340

breath: () => void;

341

death: () => void;

342

spawnReset: () => void;

343

move: (position: Vec3) => void;

344

forcedMove: () => void;

345

mount: () => void;

346

dismount: (vehicle: Entity) => void;

347

sleep: () => void;

348

wake: () => void;

349

experience: () => void;

350

physicsTick: () => void;

351

physicTick: () => void;

352

353

// Interaction events

354

diggingCompleted: (block: Block) => void;

355

diggingAborted: (block: Block) => void;

356

windowOpen: (window: Window) => void;

357

windowClose: (window: Window) => void;

358

itemDrop: (entity: Entity) => void;

359

playerCollect: (collector: Entity, collected: Entity) => void;

360

usedFirework: () => void;

361

362

// Audio and visual events

363

soundEffectHeard: (soundName: string, position: Vec3, volume: number, pitch: number) => void;

364

hardcodedSoundEffectHeard: (soundId: number, soundCategory: number, position: Vec3, volume: number, pitch: number) => void;

365

noteHeard: (block: Block, instrument: Instrument, pitch: number) => void;

366

title: (text: string, type: "subtitle" | "title") => void;

367

particle: (particle: Particle) => void;

368

369

// Block interaction events

370

pistonMove: (block: Block, isPulling: number, direction: number) => void;

371

chestLidMove: (block: Block, isOpen: number, block2: Block | null) => void;

372

blockBreakProgressObserved: (block: Block, destroyStage: number) => void;

373

blockBreakProgressEnd: (block: Block) => void;

374

375

// Scoreboard and team events

376

scoreboardCreated: (scoreboard: ScoreBoard) => void;

377

scoreboardDeleted: (scoreboard: ScoreBoard) => void;

378

scoreboardTitleChanged: (scoreboard: ScoreBoard) => void;

379

scoreUpdated: (scoreboard: ScoreBoard, item: number) => void;

380

scoreRemoved: (scoreboard: ScoreBoard, item: number) => void;

381

scoreboardPosition: (position: DisplaySlot, scoreboard: ScoreBoard) => void;

382

teamCreated: (team: Team) => void;

383

teamRemoved: (team: Team) => void;

384

teamUpdated: (team: Team) => void;

385

teamMemberAdded: (team: Team) => void;

386

teamMemberRemoved: (team: Team) => void;

387

388

// UI events

389

bossBarCreated: (bossBar: BossBar) => void;

390

bossBarDeleted: (bossBar: BossBar) => void;

391

bossBarUpdated: (bossBar: BossBar) => void;

392

resourcePack: (url: string, hash?: string, uuid?: string) => void;

393

}

394

```

395

396

### Version Utilities

397

398

Version checking and feature support utilities for cross-version compatibility.

399

400

```typescript { .api }

401

const testedVersions: string[];

402

const latestSupportedVersion: string;

403

const oldestSupportedVersion: string;

404

405

function supportFeature(feature: string, version: string): boolean;

406

```

407

408

### Utility Classes

409

410

Core utility classes for spatial positioning, world object representation, and game state management.

411

412

```typescript { .api }

413

class Location {

414

floored: Vec3;

415

blockPoint: Vec3;

416

chunkCorner: Vec3;

417

blockIndex: number;

418

biomeBlockIndex: number;

419

chunkYIndex: number;

420

constructor(absoluteVector: Vec3);

421

}

422

423

class Painting {

424

id: number;

425

position: Vec3;

426

name: string;

427

direction: Vec3;

428

constructor(id: number, position: Vec3, name: string, direction: Vec3);

429

}

430

431

class ScoreBoard {

432

name: string;

433

title: string;

434

itemsMap: { [name: string]: ScoreBoardItem };

435

items: ScoreBoardItem[];

436

constructor(packet: object);

437

setTitle(title: string): void;

438

add(name: string, value: number): ScoreBoardItem;

439

remove(name: string): ScoreBoardItem;

440

}

441

442

class BossBar {

443

entityUUID: string;

444

title: ChatMessage;

445

health: number;

446

dividers: number;

447

color: "pink" | "blue" | "red" | "green" | "yellow" | "purple" | "white";

448

shouldDarkenSky: boolean;

449

isDragonBar: boolean;

450

createFog: boolean;

451

constructor(uuid: string, title: string, health: number, dividers: number, color: number, flags: number);

452

}

453

454

class Particle {

455

id: number;

456

position: Vec3;

457

offset: Vec3;

458

count: number;

459

movementSpeed: number;

460

longDistanceRender: boolean;

461

static fromNetwork(packet: Object): Particle;

462

constructor(id: number, position: Vec3, offset: Vec3, count?: number, movementSpeed?: number, longDistanceRender?: boolean);

463

}

464

```

465

466

## Core Types

467

468

```typescript { .api }

469

interface Bot extends TypedEmitter<BotEvents> {

470

// Core identification and connection

471

username: string;

472

protocolVersion: string;

473

majorVersion: string;

474

version: string;

475

476

// Entity and player management

477

entity: Entity;

478

entities: { [id: string]: Entity };

479

player: Player;

480

players: { [username: string]: Player };

481

482

// Health and status

483

health: number;

484

food: number;

485

foodSaturation: number;

486

oxygenLevel: number;

487

fireworkRocketDuration: number;

488

489

// World and environment

490

world: world.WorldSync;

491

spawnPoint: Vec3;

492

game: GameState;

493

time: Time;

494

isRaining: boolean;

495

thunderState: number;

496

497

// Inventory and equipment

498

inventory: Window<StorageEvents>;

499

heldItem: Item | null;

500

usingHeldItem: boolean;

501

quickBarSlot: number;

502

currentWindow: Window | null;

503

504

// Movement and physics

505

physics: PhysicsOptions;

506

physicsEnabled: boolean;

507

isSleeping: boolean;

508

targetDigBlock: Block;

509

controlState: ControlStateStatus;

510

511

// Game state and settings

512

settings: GameSettings;

513

experience: Experience;

514

515

// Communication and UI

516

chatPatterns: ChatPattern[];

517

tablist: Tablist;

518

519

// Scoreboards and teams

520

scoreboards: { [name: string]: ScoreBoard };

521

scoreboard: { [slot in DisplaySlot]: ScoreBoard };

522

teams: { [name: string]: Team };

523

teamMap: { [name: string]: Team };

524

525

// Special modes

526

creative: CreativeMethods;

527

528

// Advanced features

529

registry: Registry;

530

simpleClick: SimpleClick;

531

_client: Client;

532

533

// Core methods

534

connect(options: BotOptions): void;

535

end(reason?: string): void;

536

quit(reason?: string): void;

537

supportFeature: IndexedData['supportFeature'];

538

539

// Block and world interaction

540

blockAt(point: Vec3, extraInfos?: boolean): Block | null;

541

blockInSight(maxSteps: number, vectorLength: number): Block | null;

542

blockAtCursor(maxDistance?: number, matcher?: Function): Block | null;

543

blockAtEntityCursor(entity?: Entity, maxDistance?: number, matcher?: Function): Block | null;

544

canSeeBlock(block: Block): boolean;

545

findBlock(options: FindBlockOptions): Block | null;

546

findBlocks(options: FindBlockOptions): Vec3[];

547

canDigBlock(block: Block): boolean;

548

dig(block: Block, forceLook?: boolean | 'ignore', digFace?: 'auto' | Vec3 | 'raycast'): Promise<void>;

549

stopDigging(): void;

550

digTime(block: Block): number;

551

placeBlock(referenceBlock: Block, faceVector: Vec3): Promise<void>;

552

placeEntity(referenceBlock: Block, faceVector: Vec3): Promise<Entity>;

553

activateBlock(block: Block, direction?: Vec3, cursorPos?: Vec3): Promise<void>;

554

555

// Entity interaction

556

nearestEntity(filter?: (entity: Entity) => boolean): Entity | null;

557

entityAtCursor(maxDistance?: number): Entity | null;

558

activateEntity(entity: Entity): Promise<void>;

559

activateEntityAt(entity: Entity, position: Vec3): Promise<void>;

560

attack(entity: Entity): void;

561

useOn(targetEntity: Entity): void;

562

mount(entity: Entity): void;

563

dismount(): void;

564

moveVehicle(left: number, forward: number): void;

565

566

// Movement and control

567

setControlState(control: ControlState, state: boolean): void;

568

getControlState(control: ControlState): boolean;

569

clearControlStates(): void;

570

lookAt(point: Vec3, force?: boolean): Promise<void>;

571

look(yaw: number, pitch: number, force?: boolean): Promise<void>;

572

swingArm(hand: 'left' | 'right' | undefined, showHand?: boolean): void;

573

574

// Item and inventory management

575

equip(item: Item | number, destination: EquipmentDestination | null): Promise<void>;

576

unequip(destination: EquipmentDestination | null): Promise<void>;

577

tossStack(item: Item): Promise<void>;

578

toss(itemType: number, metadata: number | null, count: number | null): Promise<void>;

579

craft(recipe: Recipe, count?: number, craftingTable?: Block): Promise<void>;

580

setQuickBarSlot(slot: number): void;

581

consume(): Promise<void>;

582

activateItem(offhand?: boolean): void;

583

deactivateItem(): void;

584

updateHeldItem(): void;

585

getEquipmentDestSlot(destination: string): number;

586

587

// Container management

588

openContainer(container: Block | Entity, direction?: Vec3, cursorPos?: Vec3): Promise<Chest | Dispenser>;

589

openChest(chest: Block | Entity, direction?: Vec3, cursorPos?: Vec3): Promise<Chest>;

590

openFurnace(furnace: Block): Promise<Furnace>;

591

openDispenser(dispenser: Block): Promise<Dispenser>;

592

openEnchantmentTable(enchantmentTable: Block): Promise<EnchantmentTable>;

593

openAnvil(anvil: Block): Promise<Anvil>;

594

openVillager(villager: Entity): Promise<Villager>;

595

trade(villagerInstance: Villager, tradeIndex: string | number, times?: number): Promise<void>;

596

openBlock(block: Block, direction?: Vec3, cursorPos?: Vec3): Promise<Window>;

597

openEntity(entity: Entity, Class: new () => EventEmitter): Promise<Window>;

598

closeWindow(window: Window): void;

599

600

// Window and inventory operations

601

clickWindow(slot: number, mouseButton: number, mode: number): Promise<void>;

602

putSelectedItemRange(start: number, end: number, window: Window, slot: any): Promise<void>;

603

putAway(slot: number): Promise<void>;

604

transfer(options: TransferOptions): Promise<void>;

605

moveSlotItem(sourceSlot: number, destSlot: number): Promise<void>;

606

607

// Communication

608

chat(message: string): void;

609

whisper(username: string, message: string): void;

610

tabComplete(str: string, assumeCommand?: boolean, sendBlockInSight?: boolean, timeout?: number): Promise<string[]>;

611

chatAddPattern(pattern: RegExp, chatType: string, description?: string): number;

612

addChatPattern(name: string, pattern: RegExp, options?: ChatPatternOptions): number;

613

addChatPatternSet(name: string, patterns: RegExp[], options?: ChatPatternOptions): number;

614

removeChatPattern(name: string | number): void;

615

awaitMessage(...args: string[] | RegExp[]): Promise<string>;

616

617

// Game mechanics

618

sleep(bedBlock: Block): Promise<void>;

619

isABed(bedBlock: Block): boolean;

620

wake(): Promise<void>;

621

fish(): Promise<void>;

622

elytraFly(): Promise<void>;

623

writeBook(slot: number, pages: string[]): Promise<void>;

624

updateSign(block: Block, text: string, back?: boolean): void;

625

setCommandBlock(pos: Vec3, command: string, options: CommandBlockOptions): void;

626

627

// Utility and helpers

628

getExplosionDamages(targetEntity: Entity, position: Vec3, radius: number, rawDamages?: boolean): number | null;

629

waitForChunksToLoad(): Promise<void>;

630

waitForTicks(ticks: number): Promise<void>;

631

recipesFor(itemType: number, metadata: number | null, minResultCount: number | null, craftingTable: Block | boolean | null): Recipe[];

632

recipesAll(itemType: number, metadata: number | null, craftingTable: Block | boolean | null): Recipe[];

633

634

// Settings and configuration

635

setSettings(options: Partial<GameSettings>): void;

636

loadPlugin(plugin: Plugin): void;

637

loadPlugins(plugins: Plugin[]): void;

638

hasPlugin(plugin: Plugin): boolean;

639

640

// Resource packs

641

acceptResourcePack(): void;

642

denyResourcePack(): void;

643

644

// Respawn

645

respawn(): void;

646

}

647

648

interface Vec3 {

649

x: number;

650

y: number;

651

z: number;

652

}

653

654

interface Block {

655

type: number;

656

name: string;

657

position: Vec3;

658

metadata: number;

659

light: number;

660

skyLight: number;

661

hardness: number;

662

material: string;

663

}

664

665

interface Entity {

666

id: number;

667

type: string;

668

username?: string;

669

position: Vec3;

670

velocity: Vec3;

671

yaw: number;

672

pitch: number;

673

health?: number;

674

isValid: boolean;

675

}

676

677

interface Item {

678

type: number;

679

count: number;

680

metadata: number;

681

name: string;

682

displayName: string;

683

stackSize: number;

684

durabilityUsed?: number;

685

enchants: Enchant[];

686

nbt?: NBT;

687

}

688

689

interface ScoreBoardItem {

690

name: string;

691

displayName: ChatMessage;

692

value: number;

693

}

694

695

interface ChatMessage {

696

text?: string;

697

color?: string;

698

bold?: boolean;

699

italic?: boolean;

700

underlined?: boolean;

701

strikethrough?: boolean;

702

obfuscated?: boolean;

703

extra?: ChatMessage[];

704

}

705

706

interface Enchant {

707

name: string;

708

lvl: number;

709

}

710

711

interface Player {

712

uuid: string;

713

username: string;

714

displayName: ChatMessage;

715

gamemode: number;

716

ping: number;

717

entity: Entity;

718

skinData: SkinData | undefined;

719

profileKeys?: {

720

publicKey: Buffer;

721

signature: Buffer;

722

};

723

}

724

725

interface SkinData {

726

url: string;

727

model: string | null;

728

}

729

730

interface GameState {

731

levelType: LevelType;

732

gameMode: GameMode;

733

hardcore: boolean;

734

dimension: Dimension;

735

difficulty: Difficulty;

736

maxPlayers: number;

737

serverBrand: string;

738

}

739

740

type LevelType = 'default' | 'flat' | 'largeBiomes' | 'amplified' | 'customized' | 'buffet' | 'default_1_1';

741

type GameMode = 'survival' | 'creative' | 'adventure' | 'spectator';

742

type Dimension = 'the_nether' | 'overworld' | 'the_end';

743

type Difficulty = 'peaceful' | 'easy' | 'normal' | 'hard';

744

745

interface Time {

746

doDaylightCycle: boolean;

747

bigTime: BigInt;

748

time: number;

749

timeOfDay: number;

750

day: number;

751

isDay: boolean;

752

moonPhase: number;

753

bigAge: BigInt;

754

age: number;

755

}

756

757

interface PhysicsOptions {

758

maxGroundSpeed: number;

759

terminalVelocity: number;

760

walkingAcceleration: number;

761

gravity: number;

762

groundFriction: number;

763

playerApothem: number;

764

playerHeight: number;

765

jumpSpeed: number;

766

yawSpeed: number;

767

pitchSpeed: number;

768

sprintSpeed: number;

769

maxGroundSpeedSoulSand: number;

770

maxGroundSpeedWater: number;

771

}

772

773

interface ControlStateStatus {

774

forward: boolean;

775

back: boolean;

776

left: boolean;

777

right: boolean;

778

jump: boolean;

779

sprint: boolean;

780

sneak: boolean;

781

}

782

783

type ControlState = 'forward' | 'back' | 'left' | 'right' | 'jump' | 'sprint' | 'sneak';

784

785

interface GameSettings {

786

chat: ChatLevel;

787

colorsEnabled: boolean;

788

viewDistance: ViewDistance;

789

difficulty: number;

790

skinParts: SkinParts;

791

mainHand: MainHands;

792

}

793

794

interface SkinParts {

795

showCape: boolean;

796

showJacket: boolean;

797

showLeftSleeve: boolean;

798

showRightSleeve: boolean;

799

showLeftPants: boolean;

800

showRightPants: boolean;

801

showHat: boolean;

802

}

803

804

interface Experience {

805

level: number;

806

points: number;

807

progress: number;

808

}

809

810

interface ChatPattern {

811

pattern: RegExp;

812

type: string;

813

description: string;

814

}

815

816

interface Tablist {

817

header: ChatMessage;

818

footer: ChatMessage;

819

}

820

821

interface SimpleClick {

822

leftMouse: (slot: number) => Promise<void>;

823

rightMouse: (slot: number) => Promise<void>;

824

}

825

826

interface FindBlockOptions {

827

point?: Vec3;

828

matching: number | number[] | ((block: Block) => boolean);

829

maxDistance?: number;

830

count?: number;

831

useExtraInfo?: boolean | ((block: Block) => boolean);

832

}

833

834

interface TransferOptions {

835

window: Window;

836

itemType: number;

837

metadata: number | null;

838

count?: number;

839

sourceStart: number;

840

sourceEnd: number;

841

destStart: number;

842

destEnd: number;

843

}

844

845

interface CommandBlockOptions {

846

mode: number;

847

trackOutput: boolean;

848

conditional: boolean;

849

alwaysActive: boolean;

850

}

851

852

interface ChatPatternOptions {

853

repeat: boolean;

854

parse: boolean;

855

}

856

857

interface Effect {

858

id: number;

859

amplifier: number;

860

duration: number;

861

}

862

863

interface Instrument {

864

id: number;

865

name: 'harp' | 'doubleBass' | 'snareDrum' | 'sticks' | 'bassDrum';

866

}

867

868

type DisplaySlot = 'list' | 'sidebar' | 'belowName' | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18;

869

type ChatLevel = 'enabled' | 'commandsOnly' | 'disabled';

870

type ViewDistance = 'far' | 'normal' | 'short' | 'tiny' | number;

871

type MainHands = 'left' | 'right';

872

```