A simple bot using mineflayer (javascript) in python
- Install NodeJS
- Install Python >=3.10
pip install uvuv syncuv run -m src.__main__from src.mcbot import Bot, Dispatcher
from src.mcbot.types import Message
bot = Bot("Botik", "localhost", 3000, "1.20.1", hideErrors=False)
dp = Dispatcher()
@dp.on.spawn()
def spawn(*args):
bot.chat("Hello world!")
@dp.on.message()
def chat(message: Message) -> None:
if "hi" in message.text:
message.bot.chat("Hello!")
if __name__ == "__main__":
dp.run(bot)bot_1 = Bot("Botik", ...)
bot_2 = Bot("Botik_2", ...)
dp = Dispatcher()
# Handlers...
if __name__ == "__main__":
dp.run(bot_1, bot_2)Tip
1 Tick = 50ms (20 ticks = 1 second)
@dp.on.spawn()
def spawn(*args):
bot.chat("Let me jump")
bot.action("jump")
bot.off_action()
@dp.on.message()
def chat(message: Message) -> None:
if "jump" in message.text:
bot.action("jump")
bot.wait(20)
bot.action("forward")
bot.wait(20)
bot.off_action()@dp.on.entityHurt()
def hurt(*args) -> None: # entity, second_entity
attacker = bot.nearestEntity()
if attacker:
bot.attack(attacker)