Compare commits

..

7 Commits

28 changed files with 853 additions and 722 deletions
+2 -1
View File
@@ -1 +1,2 @@
use flake eval "$(devenv direnvrc)"
use devenv
-17
View File
@@ -1,17 +0,0 @@
version: 2
updates:
- package-ecosystem: "cargo"
directory: "/"
schedule:
interval: "monthly"
- package-ecosystem: "nix"
directory: "/"
schedule:
interval: "monthly"
- package-ecosystem: "github-actions"
directory: ".github/workflows"
schedule:
interval: "monthly"
+3 -3
View File
@@ -24,13 +24,13 @@ jobs:
steps: steps:
- name: Clone repository - name: Clone repository
uses: actions/checkout@v6 uses: actions/checkout@v4
- name: Install build dependencies - name: Install build dependencies
run: sudo apt install -y libluajit-5.1-dev mold run: sudo apt install -y libluajit-5.1-dev mold
- name: Set up build cache - name: Set up build cache
uses: actions/cache@v5 uses: actions/cache@v4
with: with:
path: | path: |
~/.cargo/bin/ ~/.cargo/bin/
@@ -46,7 +46,7 @@ jobs:
- run: cargo build --release ${{ matrix.feature.flags }} - run: cargo build --release ${{ matrix.feature.flags }}
- name: Upload build artifacts - name: Upload build artifacts
uses: actions/upload-artifact@v7 uses: actions/upload-artifact@v4
with: with:
name: errornowatcher_${{ matrix.feature.name }}_${{ matrix.os }} name: errornowatcher_${{ matrix.feature.name }}_${{ matrix.os }}
path: target/release/errornowatcher path: target/release/errornowatcher
+5 -5
View File
@@ -15,10 +15,10 @@ jobs:
steps: steps:
- name: Clone repository - name: Clone repository
uses: actions/checkout@v6 uses: actions/checkout@v4
- name: Install taplo - name: Install taplo
uses: uncenter/setup-taplo@v2 uses: uncenter/setup-taplo@v1
- name: Run taplo lint - name: Run taplo lint
run: taplo lint Cargo.toml run: taplo lint Cargo.toml
@@ -47,13 +47,13 @@ jobs:
steps: steps:
- name: Clone repository - name: Clone repository
uses: actions/checkout@v6 uses: actions/checkout@v4
- name: Install build dependencies - name: Install build dependencies
run: sudo apt install -y libluajit-5.1-dev mold run: sudo apt install -y libluajit-5.1-dev mold
- name: Set up build cache - name: Set up build cache
uses: actions/cache@v5 uses: actions/cache@v4
with: with:
path: | path: |
~/.cargo/bin/ ~/.cargo/bin/
@@ -69,7 +69,7 @@ jobs:
- name: Install components - name: Install components
run: rustup component add clippy rustfmt run: rustup component add clippy rustfmt
- run: cargo clippy ${{ matrix.feature.flags }} -- -D clippy::pedantic - run: cargo clippy ${{ matrix.feature.flags }} -- -D warnings -D clippy::pedantic
- if: always() - if: always()
run: cargo fmt --check run: cargo fmt --check
+13 -4
View File
@@ -1,4 +1,13 @@
/.direnv .luarc.json
/.luarc.json target
/result*
/target # Devenv
.devenv*
devenv.local.nix
devenv.local.yaml
# direnv
.direnv
# pre-commit
.pre-commit-config.yaml
Generated
+654 -358
View File
File diff suppressed because it is too large Load Diff
+3 -10
View File
@@ -15,20 +15,13 @@ codegen-units = 1
lto = true lto = true
strip = true strip = true
[profile.release-no-lto]
inherits = "release"
lto = false
[profile.small]
inherits = "release"
opt-level = "z"
[build-dependencies] [build-dependencies]
built = { version = "0", features = ["git2"] } built = { git = "https://github.com/lukaslueg/built", features = ["git2"] }
[dependencies] [dependencies]
anyhow = "1" anyhow = "1"
azalea = "0" azalea = { git = "https://github.com/azalea-rs/azalea" }
azalea-hax = { git = "https://github.com/azalea-rs/azalea-hax" }
bevy_app = "0" bevy_app = "0"
bevy_ecs = "0" bevy_ecs = "0"
bevy_log = "0" bevy_log = "0"
+1 -7
View File
@@ -21,13 +21,7 @@ A Minecraft bot with Lua scripting support, written in Rust with [azalea](https:
$ git clone https://github.com/ErrorNoInternet/ErrorNoWatcher $ git clone https://github.com/ErrorNoInternet/ErrorNoWatcher
$ cd ErrorNoWatcher $ cd ErrorNoWatcher
$ cargo build --release $ cargo build --release
$ ./target/release/errornowatcher $ # ./target/release/errornowatcher
```
#### Nix
```sh
nix run github:ErrorNoInternet/ErrorNoWatcher
``` ```
Make sure the `Server` and `Username` globals are defined in `main.lua` before starting the bot. Make sure the `Server` and `Username` globals are defined in `main.lua` before starting the bot.
-20
View File
@@ -1,20 +0,0 @@
{
craneLib,
pkgs,
}:
craneLib.buildPackage {
pname = "errornowatcher";
version = "0.2.0";
src = craneLib.cleanCargoSource ./.;
nativeBuildInputs = with pkgs; [
clang
mold
pkg-config
];
buildInputs = with pkgs; [
luajit
];
}
+86
View File
@@ -0,0 +1,86 @@
{
"nodes": {
"devenv": {
"locked": {
"dir": "src/modules",
"lastModified": 1775928269,
"narHash": "sha256-kolsui5s7citDkwz2RL4Au8/BUdH9/TYbfMthLrarrc=",
"owner": "cachix",
"repo": "devenv",
"rev": "b908ac3d4b59f28cb32e7294c621b1c7325002c7",
"type": "github"
},
"original": {
"dir": "src/modules",
"owner": "cachix",
"repo": "devenv",
"type": "github"
}
},
"nixpkgs": {
"inputs": {
"nixpkgs-src": "nixpkgs-src"
},
"locked": {
"lastModified": 1774287239,
"narHash": "sha256-W3krsWcDwYuA3gPWsFA24YAXxOFUL6iIlT6IknAoNSE=",
"owner": "cachix",
"repo": "devenv-nixpkgs",
"rev": "fa7125ea7f1ae5430010a6e071f68375a39bd24c",
"type": "github"
},
"original": {
"owner": "cachix",
"ref": "rolling",
"repo": "devenv-nixpkgs",
"type": "github"
}
},
"nixpkgs-src": {
"flake": false,
"locked": {
"lastModified": 1773840656,
"narHash": "sha256-9tpvMGFteZnd3gRQZFlRCohVpqooygFuy9yjuyRL2C0=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "9cf7092bdd603554bd8b63c216e8943cf9b12512",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixpkgs-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"devenv": "devenv",
"nixpkgs": "nixpkgs",
"rust-overlay": "rust-overlay"
}
},
"rust-overlay": {
"inputs": {
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1775877051,
"narHash": "sha256-wpSQm2PD/w4uRo2wb8utk0b5hOBkkg/CZ1xICY+qB7M=",
"owner": "oxalica",
"repo": "rust-overlay",
"rev": "08b4f3633471874c8894632ade1b78d75dbda002",
"type": "github"
},
"original": {
"owner": "oxalica",
"repo": "rust-overlay",
"type": "github"
}
}
},
"root": "root",
"version": 7
}
+19
View File
@@ -0,0 +1,19 @@
{
pkgs,
...
}:
{
packages = with pkgs; [
git
jujutsu
luajit
openssl
];
languages.rust = {
enable = true;
channel = "nightly";
};
}
+8
View File
@@ -0,0 +1,8 @@
inputs:
nixpkgs:
url: github:cachix/devenv-nixpkgs/rolling
rust-overlay:
url: github:oxalica/rust-overlay
inputs:
nixpkgs:
follows: nixpkgs
Generated
-116
View File
@@ -1,116 +0,0 @@
{
"nodes": {
"crane": {
"locked": {
"lastModified": 1778106249,
"narHash": "sha256-cM/AuKy5tMhwOOQIbha8ZRRMHVfNf7cv2aljIw+qoCg=",
"owner": "ipetkov",
"repo": "crane",
"rev": "6d015ea29630b7ad2402841386da2cb617a470a7",
"type": "github"
},
"original": {
"owner": "ipetkov",
"repo": "crane",
"type": "github"
}
},
"fenix": {
"inputs": {
"nixpkgs": [
"nixpkgs"
],
"rust-analyzer-src": "rust-analyzer-src"
},
"locked": {
"lastModified": 1778314245,
"narHash": "sha256-a8p3JMunVzj0o86V9CNTyEFw7z4105QWl+bEz6Du8Jw=",
"owner": "nix-community",
"repo": "fenix",
"rev": "f54d645218048a7abe226983a922cdaca63cd845",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "fenix",
"type": "github"
}
},
"flake-parts": {
"inputs": {
"nixpkgs-lib": "nixpkgs-lib"
},
"locked": {
"lastModified": 1777988971,
"narHash": "sha256-qIoWPDs+0/8JecyYgE3gpKQxW/4bLW/gp45vow9ioCQ=",
"owner": "hercules-ci",
"repo": "flake-parts",
"rev": "0678d8986be1661af6bb555f3489f2fdfc31f6ff",
"type": "github"
},
"original": {
"owner": "hercules-ci",
"repo": "flake-parts",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1777954456,
"narHash": "sha256-hGdgeU2Nk87RAuZyYjyDjFL6LK7dAZN5RE9+hrDTkDU=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "549bd84d6279f9852cae6225e372cc67fb91a4c1",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs-lib": {
"locked": {
"lastModified": 1777168982,
"narHash": "sha256-GOkGPcboWE9BmGCRMLX3worL4EMnsnG8MyKmXNeYuhQ=",
"owner": "nix-community",
"repo": "nixpkgs.lib",
"rev": "f5901329dade4a6ea039af1433fb087bd9c1fe14",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "nixpkgs.lib",
"type": "github"
}
},
"root": {
"inputs": {
"crane": "crane",
"fenix": "fenix",
"flake-parts": "flake-parts",
"nixpkgs": "nixpkgs"
}
},
"rust-analyzer-src": {
"flake": false,
"locked": {
"lastModified": 1778246258,
"narHash": "sha256-RUZuOfzouSaK/VjcOCU/P5Nb3EhpM8qGnIcHWIIo4Sw=",
"owner": "rust-lang",
"repo": "rust-analyzer",
"rev": "73ca1d4ef136e2367627d698f00db94882b49440",
"type": "github"
},
"original": {
"owner": "rust-lang",
"ref": "nightly",
"repo": "rust-analyzer",
"type": "github"
}
}
},
"root": "root",
"version": 7
}
-58
View File
@@ -1,58 +0,0 @@
{
inputs = {
crane.url = "github:ipetkov/crane";
fenix = {
url = "github:nix-community/fenix";
inputs.nixpkgs.follows = "nixpkgs";
};
flake-parts.url = "github:hercules-ci/flake-parts";
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
};
outputs =
{
crane,
fenix,
flake-parts,
...
}@inputs:
flake-parts.lib.mkFlake { inherit inputs; } {
systems = [
"aarch64-linux"
"x86_64-linux"
];
perSystem =
{
pkgs,
self',
system,
...
}:
let
craneLib = (crane.mkLib pkgs).overrideToolchain fenix.packages.${system}.complete.toolchain;
in
{
devShells.default = craneLib.devShell {
name = "errornowatcher";
inputsFrom = [ self'.packages.default ];
nativeBuildInputs = [ pkgs.pkg-config ];
buildInputs = [ pkgs.taplo ];
PKG_CONFIG_PATH = "${pkgs.openssl.dev}/lib/pkgconfig";
RUST_BACKTRACE = 1;
};
packages = rec {
default = errornowatcher;
errornowatcher = pkgs.callPackage ./. { inherit craneLib; };
};
};
};
description = "A Minecraft bot with Lua scripting support";
}
+1 -1
View File
@@ -99,7 +99,7 @@ function attack_entities(target_kind, minimum)
pos.y = pos.y + 1.5 pos.y = pos.y + 1.5
hold_sword() hold_sword()
client.looking_at = pos client:look_at(pos)
client:attack(e.id) client:attack(e.id)
while client.has_attack_cooldown do while client.has_attack_cooldown do
sleep(100) sleep(100)
+2 -2
View File
@@ -6,7 +6,7 @@ function hold_items_in_hotbar(target_kinds, inventory)
if index >= 37 and index <= 45 and table.contains(target_kinds, item.kind) then if index >= 37 and index <= 45 and table.contains(target_kinds, item.kind) then
inventory = nil inventory = nil
sleep(500) sleep(500)
client.held_slot = index - 37 client:set_held_slot(index - 37)
return true return true
end end
end end
@@ -35,7 +35,7 @@ end
function steal(item_name) function steal(item_name)
for _, chest_pos in ipairs(client:find_blocks(client.position, get_block_states({ "chest" }))) do for _, chest_pos in ipairs(client:find_blocks(client.position, get_block_states({ "chest" }))) do
client:go_to({ position = chest_pos, radius = 3 }, { type = RADIUS_GOAL }) client:go_to({ position = chest_pos, radius = 3 }, { type = RADIUS_GOAL })
client.looking_at = chest_pos client:look_at(chest_pos)
local container = client:open_container_at(chest_pos) local container = client:open_container_at(chest_pos)
for index, item in ipairs(container.contents) do for index, item in ipairs(container.contents) do
+1 -1
View File
@@ -2,7 +2,7 @@ function look_at_player(name)
local player = get_player(name) local player = get_player(name)
if player then if player then
player.position.y = player.position.y + 1 player.position.y = player.position.y + 1
client.looking_at = player.position client:look_at(player.position)
end end
end end
+1 -1
View File
@@ -141,7 +141,7 @@ function interact_bed()
end end
client:go_to({ position = bed, radius = 2 }, { type = RADIUS_GOAL, options = { without_mining = true } }) client:go_to({ position = bed, radius = 2 }, { type = RADIUS_GOAL, options = { without_mining = true } })
client.looking_at = bed client:look_at(bed)
client:block_interact(bed) client:block_interact(bed)
end end
+1 -1
View File
@@ -1,4 +1,4 @@
use azalea::{brigadier::prelude::*, chat::ChatPacket, prelude::*}; use azalea::{brigadier::prelude::*, client_chat::ChatPacket, prelude::*};
use futures::lock::Mutex; use futures::lock::Mutex;
use mlua::{Error, Result, Table, UserDataRef}; use mlua::{Error, Result, Table, UserDataRef};
use ncr::{ use ncr::{
-19
View File
@@ -1,19 +0,0 @@
use azalea::{
entity::Physics,
movement::{KnockbackEvent, handle_knockback},
prelude::*,
};
use bevy_ecs::{observer::On, query::With, system::Query};
#[derive(Component)]
pub struct AntiKnockback;
pub fn anti_knockback(
knockback: On<KnockbackEvent>,
entity_query: Query<(), With<AntiKnockback>>,
handle_knockback_query: Query<&mut Physics>,
) {
if entity_query.get(knockback.entity).is_err() {
handle_knockback(knockback, handle_knockback_query);
}
}
-28
View File
@@ -1,28 +0,0 @@
pub mod anti_knockback;
use azalea::movement::KnockbackEvent;
use bevy_app::{App, Plugin, PostStartup};
use bevy_ecs::world::World;
pub struct HacksPlugin;
impl Plugin for HacksPlugin {
fn build(&self, app: &mut App) {
app.add_systems(PostStartup, init_hacks);
}
}
fn init_hacks(ecs: &mut World) {
let observers = ecs
.observers()
.try_get_observers(ecs.event_key::<KnockbackEvent>().unwrap());
let mut to_despawn = Vec::new();
for (observer_entity, _) in observers.unwrap().global_observers() {
to_despawn.push(*observer_entity);
}
for observer_entity in to_despawn {
ecs.despawn(observer_entity);
}
ecs.add_observer(anti_knockback::anti_knockback);
}
+2 -2
View File
@@ -17,7 +17,7 @@ pub fn held_item(_lua: &Lua, client: &Client) -> Result<ItemStack> {
Ok(ItemStack(client.get_held_item())) Ok(ItemStack(client.get_held_item()))
} }
pub fn get_held_slot(_lua: &Lua, client: &Client) -> Result<u8> { pub fn held_slot(_lua: &Lua, client: &Client) -> Result<u8> {
Ok(client.component::<Inventory>().selected_hotbar_slot) Ok(client.component::<Inventory>().selected_hotbar_slot)
} }
@@ -113,7 +113,7 @@ pub fn open_inventory(_lua: &Lua, client: &Client, (): ()) -> Result<Option<Cont
Ok(client.open_inventory().map(Container)) Ok(client.open_inventory().map(Container))
} }
pub fn set_held_slot(_lua: &Lua, client: &mut Client, slot: u8) -> Result<()> { pub fn set_held_slot(_lua: &Lua, client: &Client, slot: u8) -> Result<()> {
if slot > 8 { if slot > 8 {
return Ok(()); return Ok(());
} }
+1 -5
View File
@@ -43,11 +43,7 @@ pub async fn mine(_lua: Lua, client: UserDataRef<Client>, position: Vec3) -> Res
Ok(()) Ok(())
} }
pub fn get_mining(_lua: &Lua, client: &Client) -> Result<bool> { pub fn set_mining(_lua: &Lua, client: &Client, state: bool) -> Result<()> {
Ok(client.is_mining())
}
pub fn set_mining(_lua: &Lua, client: &mut Client, state: bool) -> Result<()> {
client.left_click_mine(state); client.left_click_mine(state);
Ok(()) Ok(())
} }
+11 -14
View File
@@ -33,30 +33,20 @@ impl UserData for Client {
f.add_field_method_get("air_supply", state::air_supply); f.add_field_method_get("air_supply", state::air_supply);
f.add_field_method_get("container", container::container); f.add_field_method_get("container", container::container);
f.add_field_method_get("dimension", world::dimension); f.add_field_method_get("dimension", world::dimension);
f.add_field_method_get("direction", movement::get_direction); f.add_field_method_get("direction", movement::direction);
f.add_field_method_set("direction", movement::set_direction);
f.add_field_method_get("experience", state::experience); f.add_field_method_get("experience", state::experience);
f.add_field_method_get("eye_position", movement::eye_position); f.add_field_method_get("eye_position", movement::eye_position);
f.add_field_method_get("go_to_reached", movement::go_to_reached); f.add_field_method_get("go_to_reached", movement::go_to_reached);
f.add_field_method_get("has_attack_cooldown", interaction::has_attack_cooldown); f.add_field_method_get("has_attack_cooldown", interaction::has_attack_cooldown);
f.add_field_method_get("health", state::health); f.add_field_method_get("health", state::health);
f.add_field_method_get("held_item", container::held_item); f.add_field_method_get("held_item", container::held_item);
f.add_field_method_get("held_slot", container::get_held_slot); f.add_field_method_get("held_slot", container::held_slot);
f.add_field_method_set("held_slot", container::set_held_slot);
f.add_field_method_get("hunger", state::hunger); f.add_field_method_get("hunger", state::hunger);
f.add_field_method_get("id", id); f.add_field_method_get("id", id);
f.add_field_method_get("jumping", movement::get_jumping); f.add_field_method_get("looking_at", movement::looking_at);
f.add_field_method_set("jumping", movement::set_jumping);
f.add_field_method_get("looking_at", movement::get_looking_at);
f.add_field_method_set("looking_at", movement::set_looking_at);
f.add_field_method_get("menu", container::menu); f.add_field_method_get("menu", container::menu);
f.add_field_method_get("mining", interaction::get_mining);
f.add_field_method_set("mining", interaction::set_mining);
f.add_field_method_get("pathfinder", movement::pathfinder); f.add_field_method_get("pathfinder", movement::pathfinder);
f.add_field_method_get("position", movement::get_position); f.add_field_method_get("position", movement::position);
f.add_field_method_set("position", movement::set_position);
f.add_field_method_get("sneaking", movement::get_sneaking);
f.add_field_method_set("sneaking", movement::set_sneaking);
f.add_field_method_get("tab_list", tab_list); f.add_field_method_get("tab_list", tab_list);
f.add_field_method_get("username", username); f.add_field_method_get("username", username);
f.add_field_method_get("uuid", uuid); f.add_field_method_get("uuid", uuid);
@@ -82,8 +72,15 @@ impl UserData for Client {
m.add_method("get_block_state", world::get_block_state); m.add_method("get_block_state", world::get_block_state);
m.add_method("get_fluid_state", world::get_fluid_state); m.add_method("get_fluid_state", world::get_fluid_state);
m.add_method("jump", movement::jump); m.add_method("jump", movement::jump);
m.add_method("look_at", movement::look_at);
m.add_method("open_inventory", container::open_inventory); m.add_method("open_inventory", container::open_inventory);
m.add_method("set_component", state::set_component); m.add_method("set_component", state::set_component);
m.add_method("set_direction", movement::set_direction);
m.add_method("set_held_slot", container::set_held_slot);
m.add_method("set_jumping", movement::set_jumping);
m.add_method("set_mining", interaction::set_mining);
m.add_method("set_position", movement::set_position);
m.add_method("set_sneaking", movement::set_sneaking);
m.add_method("sprint", movement::sprint); m.add_method("sprint", movement::sprint);
m.add_method("start_mining", interaction::start_mining); m.add_method("start_mining", interaction::start_mining);
m.add_method("start_use_item", interaction::start_use_item); m.add_method("start_use_item", interaction::start_use_item);
+12 -22
View File
@@ -92,8 +92,7 @@ pub async fn go_to(
client client
.goto_with_opts( .goto_with_opts(
goal, goal,
PathfinderOpts::new() PathfinderOpts::new().allow_mining(options.get("without_mining").unwrap_or_default()),
.allow_mining(!options.get::<bool>("without_mining").unwrap_or_default()),
) )
.await; .await;
@@ -117,15 +116,14 @@ pub async fn start_go_to(
)?; )?;
client.start_goto_with_opts( client.start_goto_with_opts(
goal, goal,
PathfinderOpts::new() PathfinderOpts::new().allow_mining(options.get("without_mining").unwrap_or_default()),
.allow_mining(!options.get::<bool>("without_mining").unwrap_or_default()),
); );
let _ = client.get_tick_broadcaster().recv().await; let _ = client.get_tick_broadcaster().recv().await;
Ok(()) Ok(())
} }
pub fn get_direction(_lua: &Lua, client: &Client) -> Result<Direction> { pub fn direction(_lua: &Lua, client: &Client) -> Result<Direction> {
let direction = client.direction(); let direction = client.direction();
Ok(Direction { Ok(Direction {
y: direction.y_rot(), y: direction.y_rot(),
@@ -133,11 +131,6 @@ pub fn get_direction(_lua: &Lua, client: &Client) -> Result<Direction> {
}) })
} }
pub fn set_direction(_lua: &Lua, client: &mut Client, direction: Direction) -> Result<()> {
client.set_direction(direction.y, direction.x);
Ok(())
}
pub fn eye_position(_lua: &Lua, client: &Client) -> Result<Vec3> { pub fn eye_position(_lua: &Lua, client: &Client) -> Result<Vec3> {
Ok(Vec3::from(client.eye_position())) Ok(Vec3::from(client.eye_position()))
} }
@@ -147,7 +140,7 @@ pub fn jump(_lua: &Lua, client: &Client, (): ()) -> Result<()> {
Ok(()) Ok(())
} }
pub fn get_looking_at(lua: &Lua, client: &Client) -> Result<Option<Table>> { pub fn looking_at(lua: &Lua, client: &Client) -> Result<Option<Table>> {
Ok( Ok(
if let HitResult::Block(ref result) = **client.component::<HitResultComponent>() { if let HitResult::Block(ref result) = **client.component::<HitResultComponent>() {
let table = lua.create_table()?; let table = lua.create_table()?;
@@ -163,7 +156,7 @@ pub fn get_looking_at(lua: &Lua, client: &Client) -> Result<Option<Table>> {
) )
} }
pub fn set_looking_at(_lua: &Lua, client: &mut Client, position: Vec3) -> Result<()> { pub fn look_at(_lua: &Lua, client: &Client, position: Vec3) -> Result<()> {
client.look_at(azalea::Vec3::new(position.x, position.y, position.z)); client.look_at(azalea::Vec3::new(position.x, position.y, position.z));
Ok(()) Ok(())
} }
@@ -194,20 +187,21 @@ pub fn pathfinder(lua: &Lua, client: &Client) -> Result<Table> {
Ok(table) Ok(table)
} }
pub fn get_position(_lua: &Lua, client: &Client) -> Result<Vec3> { pub fn position(_lua: &Lua, client: &Client) -> Result<Vec3> {
Ok(Vec3::from(*client.component::<Position>())) Ok(Vec3::from(*client.component::<Position>()))
} }
pub fn get_jumping(_lua: &Lua, client: &Client) -> Result<bool> { pub fn set_direction(_lua: &Lua, client: &Client, direction: Direction) -> Result<()> {
Ok(client.jumping()) client.set_direction(direction.y, direction.x);
Ok(())
} }
pub fn set_jumping(_lua: &Lua, client: &mut Client, jumping: bool) -> Result<()> { pub fn set_jumping(_lua: &Lua, client: &Client, jumping: bool) -> Result<()> {
client.set_jumping(jumping); client.set_jumping(jumping);
Ok(()) Ok(())
} }
pub fn set_position(_lua: &Lua, client: &mut Client, new_pos: Vec3) -> Result<()> { pub fn set_position(_lua: &Lua, client: &Client, new_pos: Vec3) -> Result<()> {
client.query_self::<&mut Position, _>(|mut pos| { client.query_self::<&mut Position, _>(|mut pos| {
pos.x = new_pos.x; pos.x = new_pos.x;
pos.y = new_pos.y; pos.y = new_pos.y;
@@ -216,11 +210,7 @@ pub fn set_position(_lua: &Lua, client: &mut Client, new_pos: Vec3) -> Result<()
Ok(()) Ok(())
} }
pub fn get_sneaking(_lua: &Lua, client: &Client) -> Result<bool> { pub fn set_sneaking(_lua: &Lua, client: &Client, sneaking: bool) -> Result<()> {
Ok(client.crouching())
}
pub fn set_sneaking(_lua: &Lua, client: &mut Client, sneaking: bool) -> Result<()> {
client.set_crouching(sneaking); client.set_crouching(sneaking);
Ok(()) Ok(())
} }
+2 -1
View File
@@ -2,10 +2,11 @@ use azalea::{
ClientInformation, entity::metadata::AirSupply, pathfinder::debug::PathfinderDebugParticles, ClientInformation, entity::metadata::AirSupply, pathfinder::debug::PathfinderDebugParticles,
protocol::common::client_information::ModelCustomization, protocol::common::client_information::ModelCustomization,
}; };
use azalea_hax::AntiKnockback;
use mlua::{Error, Lua, Result, Table, UserDataRef}; use mlua::{Error, Lua, Result, Table, UserDataRef};
use super::Client; use super::Client;
use crate::{hacks::anti_knockback::AntiKnockback, unpack}; use crate::unpack;
pub fn air_supply(_lua: &Lua, client: &Client) -> Result<i32> { pub fn air_supply(_lua: &Lua, client: &Client) -> Result<i32> {
Ok(client.component::<AirSupply>().0) Ok(client.component::<AirSupply>().0)
+23 -22
View File
@@ -2,7 +2,7 @@
macro_rules! get_entities { macro_rules! get_entities {
($client:ident) => {{ ($client:ident) => {{
let ecs = $client.ecs.read(); let ecs = $client.ecs.read();
ecs.try_query::<( if let Some(mut query) = ecs.try_query::<(
&AzaleaPosition, &AzaleaPosition,
&CustomName, &CustomName,
&EntityKindComponent, &EntityKindComponent,
@@ -11,8 +11,7 @@ macro_rules! get_entities {
&MinecraftEntityId, &MinecraftEntityId,
Option<&Owneruuid>, Option<&Owneruuid>,
&Pose, &Pose,
)>() )>() {
.map(|mut query| {
query query
.iter(&ecs) .iter(&ecs)
.map( .map(
@@ -30,8 +29,9 @@ macro_rules! get_entities {
}, },
) )
.collect::<Vec<_>>() .collect::<Vec<_>>()
}) } else {
.unwrap_or_default() Vec::new()
}
}}; }};
} }
@@ -39,7 +39,7 @@ macro_rules! get_entities {
macro_rules! get_players { macro_rules! get_players {
($client:ident) => {{ ($client:ident) => {{
let ecs = $client.ecs.read(); let ecs = $client.ecs.read();
ecs.try_query_filtered::<( if let Some(mut query) = ecs.try_query_filtered::<(
&MinecraftEntityId, &MinecraftEntityId,
&EntityUuid, &EntityUuid,
&EntityKindComponent, &EntityKindComponent,
@@ -47,21 +47,22 @@ macro_rules! get_players {
&LookDirection, &LookDirection,
&Pose, &Pose,
), (With<Player>, Without<Dead>)>() ), (With<Player>, Without<Dead>)>()
.map(|mut query| { {
query query
.iter(&ecs) .iter(&ecs)
.map(|(id, uuid, kind, position, direction, pose)| { .map(|(id, uuid, kind, position, direction, pose)| {
( (
id.0, id.0,
uuid.to_string(), uuid.to_string(),
kind.to_string(), kind.to_string(),
Vec3::from(*position), Vec3::from(*position),
Direction::from(direction), Direction::from(direction),
*pose as u8, *pose as u8,
) )
}) })
.collect::<Vec<_>>() .collect::<Vec<_>>()
}) } else {
.unwrap_or_default() Vec::new()
}
}}; }};
} }
+2 -4
View File
@@ -5,7 +5,6 @@ mod arguments;
mod build_info; mod build_info;
mod commands; mod commands;
mod events; mod events;
mod hacks;
mod http; mod http;
mod lua; mod lua;
mod particle; mod particle;
@@ -28,6 +27,7 @@ use arguments::Arguments;
use azalea::{ use azalea::{
DefaultPlugins, bot::DefaultBotPlugins, brigadier::prelude::CommandDispatcher, prelude::*, DefaultPlugins, bot::DefaultBotPlugins, brigadier::prelude::CommandDispatcher, prelude::*,
}; };
use azalea_hax::HaxPlugin;
use bevy_app::PluginGroup; use bevy_app::PluginGroup;
use bevy_log::{ use bevy_log::{
LogPlugin, LogPlugin,
@@ -45,8 +45,6 @@ use {
replay::{plugin::RecordPlugin, recorder::Recorder}, replay::{plugin::RecordPlugin, recorder::Recorder},
}; };
use crate::hacks::HacksPlugin;
#[cfg(feature = "mimalloc")] #[cfg(feature = "mimalloc")]
#[global_allocator] #[global_allocator]
static GLOBAL: mimalloc::MiMalloc = mimalloc::MiMalloc; static GLOBAL: mimalloc::MiMalloc = mimalloc::MiMalloc;
@@ -116,7 +114,7 @@ async fn main() -> Result<()> {
let builder = ClientBuilder::new_without_plugins() let builder = ClientBuilder::new_without_plugins()
.add_plugins(default_plugins) .add_plugins(default_plugins)
.add_plugins(DefaultBotPlugins) .add_plugins(DefaultBotPlugins)
.add_plugins(HacksPlugin); .add_plugins(HaxPlugin);
#[cfg(feature = "replay")] #[cfg(feature = "replay")]
let builder = builder.add_plugins(RecordPlugin { let builder = builder.add_plugins(RecordPlugin {