Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update with latest mineflayer package #36

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ This afk bot will keep your aternos server alive 24/7
Simple for keeping an aternos server alive, or trying to get an AFKBot on your server.
IT DOESN'T HAVE TO BE AN ATERNOS SERVER too! It can be any server as long as it's cracked. Uses the mineflayer tool created by MannuG. This bot unlike any other will move around, keeping the server alive. I recommend putting the bot in a bedrock casing to keep it from going everywhere and dying.

Mainly Supports Minecraft version 1.8, 1.9, 1.10, 1.11, 1.12, 1.13, 1.14, 1.15 and 1.16.

# Requirements 🎒
What You'll need
Expand Down
5 changes: 2 additions & 3 deletions config.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{
"ip":"YOUR_ATERNOS_SERVER_IP",
"port": "YOUR_ATERNOS_SERVER_PORT",
"name": "BOT_NAME"
"ip": "gecko.aternos.host",
"port": 50063
}
70 changes: 32 additions & 38 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,50 +1,42 @@
const mineflayer = require('mineflayer')
const fs = require('fs');
let rawdata = fs.readFileSync('config.json');
let data = JSON.parse(rawdata);
var lasttime = -1;
var moving = 0;
var connected = 0;
var actions = [ 'forward', 'back', 'left', 'right']
var lastaction;
var pi = 3.14159;
var moveinterval = 2; // 2 second movement interval
var maxrandom = 5; // 0-5 seconds added to movement interval (randomly)
var host = data["ip"];
var port = data["port"];
var username = data["name"]
var bot = mineflayer.createBot({
host: host,
port: port,
username: username
const mineflayer = require("mineflayer");
const config = require("./config.json");
let lasttime = -1;
let moving = 0;
let connected = 0;
const actions = ["forward", "back", "left", "right"];
let lastaction;
let moveinterval = 2; // 2 second movement interval
let maxrandom = 5; // 0-5 seconds added to movement interval (randomly)
const bot = mineflayer.createBot({
host: config.ip,
port: config.port,
username: "afk_bot",
hideErrors: false,
});
function getRandomArbitrary(min, max) {
return Math.random() * (max - min) + min;

}
bot.on('login',function(){
console.log("Logged In")
bot.on("login", function () {
console.log("Logged In");
});
bot.on('time', function() {
if (connected <1) {
bot.on("time", function () {
if (connected < 1) {
return;
}
if (lasttime<0) {
if (lasttime < 0) {
lasttime = bot.time.age;
} else {
var randomadd = Math.random() * maxrandom * 20;
var interval = moveinterval*20 + randomadd;
const randomadd = Math.random() * maxrandom * 20;
const interval = moveinterval * 20 + randomadd;
if (bot.time.age - lasttime > interval) {
if (moving == 1) {
bot.setControlState(lastaction,false);
bot.setControlState(lastaction, false);
moving = 0;
lasttime = bot.time.age;
} else {
var yaw = Math.random()*pi - (0.5*pi);
var pitch = Math.random()*pi - (0.5*pi);
bot.look(yaw,pitch,false);
lastaction = actions[Math.floor(Math.random() * actions.length)];
bot.setControlState(lastaction,true);
const yaw = Math.random() * Math.PI - 0.5 * Math.PI;
const pitch = Math.random() * Math.PI - 0.5 * Math.PI;
bot.look(yaw, pitch, false);
lastaction =
actions[Math.floor(Math.random() * actions.length)];
bot.setControlState(lastaction, true);
moving = 1;
lasttime = bot.time.age;
bot.activateItem();
Expand All @@ -53,7 +45,9 @@ bot.on('time', function() {
}
});

bot.on('spawn',function() {
connected=1;
bot.on("spawn", function () {
connected = 1;
});

bot.on("kicked", console.log);
bot.on("error", console.log);
15 changes: 0 additions & 15 deletions node_modules/.bin/json5

This file was deleted.

17 changes: 0 additions & 17 deletions node_modules/.bin/json5.cmd

This file was deleted.

18 changes: 0 additions & 18 deletions node_modules/.bin/json5.ps1

This file was deleted.

15 changes: 0 additions & 15 deletions node_modules/.bin/nearley-railroad

This file was deleted.

17 changes: 0 additions & 17 deletions node_modules/.bin/nearley-railroad.cmd

This file was deleted.

18 changes: 0 additions & 18 deletions node_modules/.bin/nearley-railroad.ps1

This file was deleted.

15 changes: 0 additions & 15 deletions node_modules/.bin/nearley-test

This file was deleted.

17 changes: 0 additions & 17 deletions node_modules/.bin/nearley-test.cmd

This file was deleted.

18 changes: 0 additions & 18 deletions node_modules/.bin/nearley-test.ps1

This file was deleted.

15 changes: 0 additions & 15 deletions node_modules/.bin/nearley-unparse

This file was deleted.

17 changes: 0 additions & 17 deletions node_modules/.bin/nearley-unparse.cmd

This file was deleted.

18 changes: 0 additions & 18 deletions node_modules/.bin/nearley-unparse.ps1

This file was deleted.

15 changes: 0 additions & 15 deletions node_modules/.bin/nearleyc

This file was deleted.

17 changes: 0 additions & 17 deletions node_modules/.bin/nearleyc.cmd

This file was deleted.

18 changes: 0 additions & 18 deletions node_modules/.bin/nearleyc.ps1

This file was deleted.

15 changes: 0 additions & 15 deletions node_modules/.bin/protodef-validator

This file was deleted.

Loading