Closed EvilGeorgee closed 1 year ago
Fixed!!!. You should not write any functions outside @On(Bot, 'spawn') function! Like that:
from javascript import require, On
mineflayer = require('mineflayer')
pathfinder = require('mineflayer-pathfinder')
GoalFollow = pathfinder.goals.GoalFollow
bot = mineflayer.createBot({
'host':'localhost',
'username':'Bot',
'version':'1.18',
})
bot.loadPlugin(pathfinder.pathfinder)
@on(bot, 'spawn') <---- spawn function
def spawn(*args):
mcData = require('minecraft-data')(bot.version)
movements = pathfinder.Movements(bot, mcData)
@On(bot, 'chat') <----other function
def msgHandler(this, user, message, *args):
@On(bot, 'whisper') <------------- other function
def whisper(user, message, player):
Versions
Detailed description of a problem
My bot is working, but after +- 20 seconds it crashes and i have error:
This problem not only with this code, i tried a lot of codes, everywhere same problem (it happens even if bot just afk and do nothing)
What did you try yet?
Other codes. Same problem
Your current code
/* from javascript import require, On import time import math import array pvp = require('mineflayer-pvp').plugin mineflayer = require('mineflayer') pathfinder = require('mineflayer-pathfinder') toolPlugin = require('mineflayer-tool').plugin movements = require('mineflayer-pathfinder').Movements GoalNear = require('mineflayer-pathfinder').goals GoalFollow = pathfinder.goals.GoalFollow blockAtCursor = pathfinder.blockAtCursor
bot = mineflayer.createBot({ 'host':'localhost', 'username':'mine', 'version':'1.18', 'port':'49417', })
bot.loadPlugin(pathfinder.pathfinder) mineflayer = require("mineflayer") bot.loadPlugin(toolPlugin) bot.loadPlugin(pvp)
def Fight(): player = input('Which player should i kill?: ') target = bot.players[player] if target == None: print('I cant find this player') Commands() else: bot.pvp.attack(target.entity) Commands()
def Go(): xyzp = input({'XYZ: '}) bot.pathfinder.setGoal(pathfinder.goals.GoalNear()) Commands()
@On(bot, 'spawn') def Commands(*args): mcData = require('minecraft-data')(bot.version) movements = pathfinder.Movements(bot, mcData)
time.sleep(7)
@On(bot, 'rain') def Rain(*args): bot.chat('/weather clear')
@On(bot, 'entityCrouch') def entityCrouch(this, entity, args): nrst = bot.ne /