Closed CodingMonkeyXYZ closed 10 years ago
Thanks for reporting. I have not clear. Can you post some example code or more detailed procedure to reproduce the bug? Information on the type of server would be of very great help (vanilla, bukkit, plugins, mods, ...).
If you needed to use master, I guess it will be a bukkit: can you paste the output of the /plugins
command?
Thanks for getting back to me so fast.
Well, I was trying master because of the problems I was having with chat.js but even before I could move on to testing that to see if the master branch would fix it, I got this error.
Here's my code.
var mineflayer = require('mineflayer');
var bot = mineflayer.createBot({
host: "mc.civcraft.vg",
username: "my user name",
password: "my password",
});
bot.on('chat', function(username, message) {
if (username === bot.username) return;
bot.chat(message);
});
As for plugins, that command didn't seem to be allowed for some reason but there's a list of them here: https://civcraft.org/doku.php/mods
Hope that helps. I'm itching to write my own bot :)
Sorry. I could not reproduce your error. I used your code example, connecting to "mc.civcraft.vg" with a valid login (I have been kicked due to inactivity multiple times). Make sure you are using the latest version of minecraft-protocol
library.
Thanks for your help. I updated the library using npm install minecraft-protocol. I'm confused - doesn't npm install mineflayer install the latest libraries it needs? Anyway, I didn't get any chat messages but I did get a little further, the bot joined and logged in. So I altered the code as follows, to add some diagnostics:
var mineflayer = require('mineflayer');
var bot = mineflayer.createBot({
host: "mc.civcraft.vg",
username: "xxx",
password: "xxx",
});
bot.on('chat', function(username, message) {
if (username === bot.username) return;
console.log(messge);
bot.chat(message);
});
bot.on('login', function() {
console.log("We're in.");
});
bot.on('message', function(message,jsonMsg) {
console.log(message);
});
and got this response:
We're in. { text: '§f §f §1 §0 §2 §4§f §f §2 §0 §4 §8§0§1§0§1§2§f§f§0§1§3§4§f§f§0§1§5§f§f§0§1§6§f§f§0§1§8§9§a§b§f§f§0§1§7§f§f§3 §9 §2 §0 §0 §1§3 §9 §2 §0 §0 §2§3 §9 §2 §0 §0 §3§0§0§1§f§e§0§0§2§f§e§0§0§3§4§5§6§7§8§f§e' } { text: '§f§fMonkeyWithAnAxe§f: Hi' }
Oh and I just tried bot.whisper(username, message) and calling bot.chat directly and they both worked fine, so it seems that the problem is somewhere inside the event handler for receiving chats maybe?
It doesn't seem to be calling the chat event handler with the chat message.
EDIT: I just noticed the bit in the instructions on the main page about updating the protocol. I tried the command there then tried to run the protocol tests like so:
:~$ npm test mincraft-protocol
npm ERR! Error: ENOENT, open '/home/ubuntu/node_modules/mincraft-protocol/packag e.json'
npm ERR! If you need help, you may report this log at:
npm ERR! <http://github.com/isaacs/npm/issues>
npm ERR! or email it to:
npm ERR! <npm-@googlegroups.com>
npm ERR! System Linux 3.8.0-19-generic
npm ERR! command "/usr/bin/node" "/usr/bin/npm" "test" "mincraft-protocol"
npm ERR! cwd /home/ubuntu
npm ERR! node -v v0.10.18
npm ERR! npm -v 1.3.8
npm ERR! path /home/ubuntu/node_modules/mincraft-protocol/package.json
npm ERR! code ENOENT
npm ERR! errno 34
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /home/ubuntu/npm-debug.log
npm ERR! not ok code 0
ubuntu@ip-172-31-0-86:~$ pwd
/home/ubuntu
I don't know what I'm doing here, I'm very new to node. I tried the bot again and this time I pm-ed it and it crashed the bot.
I did still get the 'I've joined' chat message though.
To use mineflayer, you don't really even need to know that minecraft-protocol exists. The instructions about updating the protocol are to be followed by developers of the library itself, not someone using the library as you are.
In node, packages are installed locally to the project. So if your project is in a folder called /home/ac7web/my-bot, you will have a file /home/ac7web/my-bot/package.json which contains the node module dependecies and /home/ac7web/my-bot/node_modules/* will contain the actual dependencies module code. See the docs and any other node module for example.
I suggest you start over as far as installing modules goes (rm -rf /home/ac7web/my-bot/node_modules
) since it sounds like you were thrashing around without understanding what you were doing. Then you would install mineflayer like this: npm install --save mineflayer
. This will both populate your package.json file with the dependency information and install mineflayer to /home/ac7web/my-bot/node_modules/mineflayer.
If this is too confusing, I suggest you take a look at some other minecraft bots already made for example. See https://github.com/rom1504/rbot/ and https://github.com/Darthfett/Helperbot
Hope that helps.
Yeah I was a bit...
I'm confused. I'm just trying to get 'echo.js' to work. There isn't a json file in that example. and just running the install with --save doesn't create one for me - I think I only need that if I'm making a 'package' for my new bot anyway, don't I? Which at this stage, I'm not because it's just a noddy example.
Anyway, I tried loggin in to CivCraft with the chat bot now, and adding some diagnostic (an event handler for kick), I can see that I was being kicked a lot with the message 'Kicked for flying (or related)', almost as soon as I joined. I kept trying though and eventually, it stayed logged in.
This is all great and it's no longer crashing but I'm still getting nothing from chat. Any ideas why? Is this a server chat standard that's not supported or something?
Here's my new code:
var mineflayer = require('mineflayer');
var bot = mineflayer.createBot({
host: "mc.civcraft.vg",
username: "derp derp",
password: "***********",
});
bot.on('chat', function(username, message) {
if (username === bot.username) return;
console.log(message);
});
bot.on('kicked', function(reason) {
console.log("Kicked:");
console.log(reason);
});
bot.on('end', function(){
console.log("we're not connected anymore");
});
bot.on('login', function(){
setInterval(function(){
var yaw = Math.floor(Math.random() * 360);
var pitch = Math.floor(Math.random() * 360);
bot.look(yaw, pitch, true);
}, 2000);
});
unrelated to mineflayer: @ac7web you may want to run the bot by the admins, if it's receiving environmental information it may not be supposed to do anything (moving its head). also what's your IGN?
Dated issue, possibly relates to https://github.com/andrewrk/mineflayer/issues/175 Closed. Reopen if you feel this is unresolved.
Hello. Fantastic project, excellent work btw.
I'm struggling with this, probably because I'm totally new to Node but I think I've found a problem with the latest code. I'm using the master branch because of the chat.js problem (documented in issue #159) and I'm getting an error here:
http://pastebin.com/DzHyqKZR
Is this a bug or am I doing it wrong?
I'm using an Ubuntu 64 bit server, node v0.10.18 and connecting to a 1.6.2 server - I'm afraid I don't know much else about the server (like if it's bucket or not).