0.1.1 • Published 4 months ago

mineflayer-mouse v0.1.1

Weekly downloads
-
License
MIT
Repository
github
Last release
4 months ago

Mineflayer Mouse

First-class battle-tested simple API for emulating real Minecraft mouse control in Mineflayer. You should use it for digging (mining) or placing blocks and entity attacking or using and using items!

Note: This module will be deprecated once the functionality is merged into the main mineflayer library with 1:1 implementation.

Installation

pnpm add mineflayer-mouse

Features

  • Predict block placement (optimistic update, needed for correct physics on high ping)
  • Block breaking server cancellation
  • Accurate entity raycasting (targeting)
  • Debug logging

Philosophy

The world interaction system in Minecraft is complex and not easy to replicate. We have two hands and different holding item/blocks logic along with different entities and activatable items and blocks in the world. For example:

  • Would what happen if you right click on a crafting table with a torch in left hand and potion in right hand? But if you are shift clicking it? But if you are loooking at entity? Should the item be used or entity interaction happen?

Using hardcoded methods like bot.attack will make your bot act not natural and more likely would result in ban.

Usage

import { createMouse } from 'mineflayer-mouse';
import { createBot } from 'mineflayer';

const bot = createBot({
  host: 'localhost',
  port: 25565,
});

bot.loadPlugin(createMouse());

// based on returned entity or block you can determine what action would happen (you cant enfoce specific action since thats not how game works)
const { entity, cursorBlock, cursorBlockDiggable } = bot.mouse.getCursorState();

// attack entity
bot.leftClick();
// start digging block
bot.leftClickStart()
// stop digging block
bot.leftClickEnd()

// place block
bot.rightClick()

// start placing block
bot.rightClickStart()

// ...

Roadmap

  • Tests
  • Block placement prediction
  • Raycast, item/block activatable, block prediction overrides
  • Better item activation
  • Validate packets on item activation on entity
0.1.1

4 months ago

0.2.0

4 months ago

0.1.0

4 months ago

0.0.10

4 months ago

0.0.9

4 months ago

0.0.8

4 months ago

0.0.7

4 months ago

0.0.6

4 months ago

0.0.5

4 months ago

0.0.4

5 months ago

0.0.3

5 months ago

0.0.2

5 months ago

0.0.1

5 months ago