Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

The Minecraft protocol for Node.js. (aka. bots!)

branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 examples
Octocat-spinner-32 src
Octocat-spinner-32 .gitignore
Octocat-spinner-32 AUTHORS
Octocat-spinner-32 LICENSE
Octocat-spinner-32 README.md
Octocat-spinner-32 index.coffee
Octocat-spinner-32 package.json
README.md

node-minecraft

by Chris Lloyd & Dave Newman @ Minefold

Provides an implementation of the Minecraft protocol for Node.js that can be used for both client and server hacking.

Installation

You need Node.js and NPM installed first.

$ npm install node-minecraft

Writing Bots

It's best to check out examples/helloworld.coffee and examples/perv.coffee. They are both small bots that successfully connect to a world and serve some function. Let's run through a simple echo bot. All it does is repeat any chat messages it hears.

# Loads the library
mc = require 'node-minecraft'

# This creates a new client
mc.createOnlineClient host, port, username, password, (bot) ->

  # 'chat' is an event that is fired when a chat message is recieved
  bot.on 'chat', (msg) ->
    # `say` writes a string back for everybody to see.
    bot.say msg

Dead simple!

FAQ

Why createOnlineClient?

Minecraft checks that you have bought a copy of the game before you can play online. This why the library needs your password. You'll need to use that method if you are putting your bot into public servers who are in online-mode.

If you have a local server that is in offline mode you can use the createOfflineClient that doesn't validate with Mojang. This is best for testing and spinning up lots of bots locally.

Why does the bot just float there?

Minecraft works by each client calculating where it is suppose to be. The bot at the moment is too dumb to know about gravity, so it doesn't move. However, in future versions of node-minecraft we want to make the bots more intelligent. Perhaps you could contribute that?

Something went wrong with that request. Please try again.