nurtex-0.3.0 has been yanked.
NurtexMC
NurtexMC is a library written in Rust that allows you to create Minecraft bots and manage them, including connection and packet processing. This library focuses on an asynchronous environment, maximum speed and optimization, and ease of coding.
Supported Minecraft version: 1.21.11 (or protocol version - 774).
Usage
To use this library in your code, add a dependency to the Cargo.toml:
nurtex = "0.3.0"
Examples
Creating a bot
use std::io;
use nurtex::bot::Bot;
use nurtex::events::EventInvoker;
use nurtex::common::BotCommand;
#[tokio::main]
async fn main() -> io::Result<()> {
let bot = Bot::new("NurtexBot");
let mut event_invoker = EventInvoker::new();
event_invoker.on_spawn(|terminal| async move {
terminal.chat("Hello, world!").await;
});
event_invoker.on_chat(|terminal, payload| async move {
if payload.message.contains("disconnect") {
terminal.send(BotCommand::Disconnect).await;
}
});
bot
.set_event_invoker(event_invoker) .connect_to("localhost", 25565) .await?;
Ok(())
}
Creating a swarm
use std::io;
use std::time::Duration;
use nurtex::common::BotCommand;
use nurtex::swarm::SwarmObject;
use nurtex::time::sleep;
use nurtex::{create_shared_swarm, destroy_shared_swarm, launch_shared_swarm};
#[tokio::main]
async fn main() -> io::Result<()> {
let mut objects = Vec::new();
for i in 0..=5 {
let object = SwarmObject::new(format!("bot_{}", i));
objects.push(object);
}
let swarm = create_shared_swarm(objects);
launch_shared_swarm(swarm.clone(), "localhost".to_string(), 25565, 500);
sleep(8000).await;
{
let guard = swarm.read().await;
guard.send(BotCommand::Chat("Hello, world!".to_string())).await;
}
sleep(5000).await;
destroy_shared_swarm(swarm, Duration::from_secs(5)).await?;
Ok(())
}