Compare commits
21 Commits
b3b2252220
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
b2ed65519e
|
|||
|
dea30ceec9
|
|||
| 2c83072427 | |||
| 91aafa3853 | |||
| c5ccb494ba | |||
|
|
1d6ef9a63f | ||
|
|
8acbc84242 | ||
|
|
cde6bebb50 | ||
|
55ee91885d
|
|||
|
1acaa3d88c
|
|||
|
7d1996306c
|
|||
|
9a362630a2
|
|||
|
57397d3718
|
|||
|
d6c16f0d5d
|
|||
|
04bfd733b1
|
|||
|
63cfc7c9c0
|
|||
|
3b154c6a35
|
|||
|
40c5950b26
|
|||
|
2cf4265732
|
|||
|
ca8c9d4d1c
|
|||
|
64c96450a4
|
17
.github/dependabot.yaml
vendored
Normal file
17
.github/dependabot.yaml
vendored
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
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"
|
||||||
6
.github/workflows/build.yaml
vendored
6
.github/workflows/build.yaml
vendored
@@ -24,13 +24,13 @@ jobs:
|
|||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Clone repository
|
- name: Clone repository
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v6
|
||||||
|
|
||||||
- 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@v4
|
uses: actions/cache@v5
|
||||||
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@v4
|
uses: actions/upload-artifact@v7
|
||||||
with:
|
with:
|
||||||
name: errornowatcher_${{ matrix.feature.name }}_${{ matrix.os }}
|
name: errornowatcher_${{ matrix.feature.name }}_${{ matrix.os }}
|
||||||
path: target/release/errornowatcher
|
path: target/release/errornowatcher
|
||||||
|
|||||||
8
.github/workflows/lint.yaml
vendored
8
.github/workflows/lint.yaml
vendored
@@ -15,7 +15,7 @@ jobs:
|
|||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Clone repository
|
- name: Clone repository
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v6
|
||||||
|
|
||||||
- name: Install taplo
|
- name: Install taplo
|
||||||
uses: uncenter/setup-taplo@v1
|
uses: uncenter/setup-taplo@v1
|
||||||
@@ -47,13 +47,13 @@ jobs:
|
|||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Clone repository
|
- name: Clone repository
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v6
|
||||||
|
|
||||||
- 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@v4
|
uses: actions/cache@v5
|
||||||
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 warnings -D clippy::pedantic
|
- run: cargo clippy ${{ matrix.feature.flags }} -- -D clippy::pedantic
|
||||||
|
|
||||||
- if: always()
|
- if: always()
|
||||||
run: cargo fmt --check
|
run: cargo fmt --check
|
||||||
|
|||||||
11
.gitignore
vendored
11
.gitignore
vendored
@@ -1,2 +1,13 @@
|
|||||||
.luarc.json
|
.luarc.json
|
||||||
target
|
target
|
||||||
|
|
||||||
|
# Devenv
|
||||||
|
.devenv*
|
||||||
|
devenv.local.nix
|
||||||
|
devenv.local.yaml
|
||||||
|
|
||||||
|
# direnv
|
||||||
|
.direnv
|
||||||
|
|
||||||
|
# pre-commit
|
||||||
|
.pre-commit-config.yaml
|
||||||
|
|||||||
3600
Cargo.lock
generated
3600
Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
19
Cargo.toml
19
Cargo.toml
@@ -15,12 +15,20 @@ 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 = { git = "https://github.com/lukaslueg/built", features = ["git2"] }
|
built = { version = "0", features = ["git2"] }
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
anyhow = "1"
|
anyhow = "1"
|
||||||
azalea = { git = "https://github.com/azalea-rs/azalea" }
|
azalea = "0"
|
||||||
bevy_app = "0"
|
bevy_app = "0"
|
||||||
bevy_ecs = "0"
|
bevy_ecs = "0"
|
||||||
bevy_log = "0"
|
bevy_log = "0"
|
||||||
@@ -42,10 +50,13 @@ parking_lot = "0"
|
|||||||
serde = "1"
|
serde = "1"
|
||||||
serde_json = "1"
|
serde_json = "1"
|
||||||
tokio = { version = "1", features = ["full"] }
|
tokio = { version = "1", features = ["full"] }
|
||||||
zip = { version = "2", default-features = false, features = ["flate2"] }
|
zip = { version = "8", default-features = false, features = [
|
||||||
|
"deflate",
|
||||||
|
], optional = true }
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
console-subscriber = ["dep:console-subscriber"]
|
console-subscriber = ["dep:console-subscriber"]
|
||||||
default = ["matrix"]
|
default = []
|
||||||
matrix = ["dep:dirs", "dep:matrix-sdk"]
|
matrix = ["dep:dirs", "dep:matrix-sdk"]
|
||||||
mimalloc = ["dep:mimalloc"]
|
mimalloc = ["dep:mimalloc"]
|
||||||
|
replay = ["dep:zip"]
|
||||||
|
|||||||
@@ -21,7 +21,13 @@ 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.
|
||||||
|
|||||||
24
default.nix
Normal file
24
default.nix
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
{
|
||||||
|
lib,
|
||||||
|
pkgs,
|
||||||
|
rust,
|
||||||
|
self,
|
||||||
|
}:
|
||||||
|
pkgs.rustPlatform.buildRustPackage {
|
||||||
|
pname = "errornowatcher";
|
||||||
|
version = self.shortRev or self.dirtyShortRev;
|
||||||
|
|
||||||
|
cargoLock.lockFile = ./Cargo.lock;
|
||||||
|
src = lib.cleanSource ./.;
|
||||||
|
|
||||||
|
nativeBuildInputs = with pkgs; [
|
||||||
|
rust
|
||||||
|
|
||||||
|
mold
|
||||||
|
pkg-config
|
||||||
|
];
|
||||||
|
|
||||||
|
buildInputs = with pkgs; [
|
||||||
|
luajit
|
||||||
|
];
|
||||||
|
}
|
||||||
82
flake.lock
generated
Normal file
82
flake.lock
generated
Normal file
@@ -0,0 +1,82 @@
|
|||||||
|
{
|
||||||
|
"nodes": {
|
||||||
|
"flake-parts": {
|
||||||
|
"inputs": {
|
||||||
|
"nixpkgs-lib": "nixpkgs-lib"
|
||||||
|
},
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1772408722,
|
||||||
|
"narHash": "sha256-rHuJtdcOjK7rAHpHphUb1iCvgkU3GpfvicLMwwnfMT0=",
|
||||||
|
"owner": "hercules-ci",
|
||||||
|
"repo": "flake-parts",
|
||||||
|
"rev": "f20dc5d9b8027381c474144ecabc9034d6a839a3",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "hercules-ci",
|
||||||
|
"repo": "flake-parts",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"nixpkgs": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1774709303,
|
||||||
|
"narHash": "sha256-D3Q07BbIA2KnTcSXIqqu9P586uWxN74zNoCH3h2ESHg=",
|
||||||
|
"owner": "NixOS",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"rev": "8110df5ad7abf5d4c0f6fb0f8f978390e77f9685",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "NixOS",
|
||||||
|
"ref": "nixos-unstable",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"nixpkgs-lib": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1772328832,
|
||||||
|
"narHash": "sha256-e+/T/pmEkLP6BHhYjx6GmwP5ivonQQn0bJdH9YrRB+Q=",
|
||||||
|
"owner": "nix-community",
|
||||||
|
"repo": "nixpkgs.lib",
|
||||||
|
"rev": "c185c7a5e5dd8f9add5b2f8ebeff00888b070742",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "nix-community",
|
||||||
|
"repo": "nixpkgs.lib",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"root": {
|
||||||
|
"inputs": {
|
||||||
|
"flake-parts": "flake-parts",
|
||||||
|
"nixpkgs": "nixpkgs",
|
||||||
|
"rust-overlay": "rust-overlay"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"rust-overlay": {
|
||||||
|
"inputs": {
|
||||||
|
"nixpkgs": [
|
||||||
|
"nixpkgs"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1775013181,
|
||||||
|
"narHash": "sha256-zPrt6oNM1r/RO5bWYaZ3hthfG9vzkr6kQdoqDd5x4Qw=",
|
||||||
|
"owner": "oxalica",
|
||||||
|
"repo": "rust-overlay",
|
||||||
|
"rev": "e8046c1d9ccadd497c2344d8fa49dab62f22f7be",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "oxalica",
|
||||||
|
"repo": "rust-overlay",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"root": "root",
|
||||||
|
"version": 7
|
||||||
|
}
|
||||||
66
flake.nix
Normal file
66
flake.nix
Normal file
@@ -0,0 +1,66 @@
|
|||||||
|
{
|
||||||
|
inputs = {
|
||||||
|
flake-parts.url = "github:hercules-ci/flake-parts";
|
||||||
|
|
||||||
|
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
||||||
|
|
||||||
|
rust-overlay = {
|
||||||
|
url = "github:oxalica/rust-overlay";
|
||||||
|
inputs.nixpkgs.follows = "nixpkgs";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
outputs =
|
||||||
|
{
|
||||||
|
flake-parts,
|
||||||
|
nixpkgs,
|
||||||
|
rust-overlay,
|
||||||
|
self,
|
||||||
|
...
|
||||||
|
}@inputs:
|
||||||
|
flake-parts.lib.mkFlake { inherit inputs; } {
|
||||||
|
systems = [
|
||||||
|
"aarch64-linux"
|
||||||
|
"x86_64-linux"
|
||||||
|
];
|
||||||
|
|
||||||
|
perSystem =
|
||||||
|
{
|
||||||
|
pkgs,
|
||||||
|
self',
|
||||||
|
system,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
let
|
||||||
|
rust = pkgs.rust-bin.nightly.latest.default.override {
|
||||||
|
extensions = [
|
||||||
|
"rust-src"
|
||||||
|
"rust-analyzer-preview"
|
||||||
|
];
|
||||||
|
};
|
||||||
|
in
|
||||||
|
{
|
||||||
|
_module.args.pkgs = import nixpkgs {
|
||||||
|
inherit system;
|
||||||
|
overlays = [ rust-overlay.overlays.default ];
|
||||||
|
};
|
||||||
|
|
||||||
|
devShells.default = pkgs.mkShell {
|
||||||
|
name = "errornowatcher";
|
||||||
|
|
||||||
|
inputsFrom = [ self'.packages.default ];
|
||||||
|
nativeBuildInputs = [ pkgs.pkg-config ];
|
||||||
|
buildInputs = [ pkgs.taplo ];
|
||||||
|
|
||||||
|
RUST_BACKTRACE = 1;
|
||||||
|
};
|
||||||
|
|
||||||
|
packages = rec {
|
||||||
|
default = errornowatcher;
|
||||||
|
errornowatcher = pkgs.callPackage ./. { inherit rust self; };
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
description = "A Minecraft bot with Lua scripting support";
|
||||||
|
}
|
||||||
@@ -1,11 +1,15 @@
|
|||||||
use azalea::{brigadier::prelude::*, chat::ChatPacket, prelude::*};
|
use azalea::{brigadier::prelude::*, chat::ChatPacket, prelude::*};
|
||||||
use futures::lock::Mutex;
|
use futures::lock::Mutex;
|
||||||
use mlua::{Function, Table};
|
use mlua::{Error, Result, Table, UserDataRef};
|
||||||
use ncr::utils::prepend_header;
|
use ncr::{
|
||||||
|
encoding::{Base64Encoding, Base64rEncoding, NewBase64rEncoding},
|
||||||
|
encryption::{CaesarEncryption, Cfb8Encryption, EcbEncryption, Encryption, GcmEncryption},
|
||||||
|
utils::prepend_header,
|
||||||
|
};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
State,
|
State, crypt,
|
||||||
lua::{eval, exec, reload},
|
lua::{eval, exec, nochatreports::key::AesKey, reload},
|
||||||
};
|
};
|
||||||
|
|
||||||
pub type Ctx = CommandContext<Mutex<CommandSource>>;
|
pub type Ctx = CommandContext<Mutex<CommandSource>>;
|
||||||
@@ -19,15 +23,20 @@ pub struct CommandSource {
|
|||||||
|
|
||||||
impl CommandSource {
|
impl CommandSource {
|
||||||
pub fn reply(&self, message: &str) {
|
pub fn reply(&self, message: &str) {
|
||||||
|
fn encrypt(options: &Table, plaintext: &str) -> Result<String> {
|
||||||
|
Ok(crypt!(encrypt, options, &prepend_header(plaintext)))
|
||||||
|
}
|
||||||
|
|
||||||
for mut chunk in message
|
for mut chunk in message
|
||||||
.chars()
|
.chars()
|
||||||
.collect::<Vec<char>>()
|
.collect::<Vec<char>>()
|
||||||
.chunks(if self.ncr_options.is_some() { 150 } else { 236 })
|
.chunks(if self.ncr_options.is_some() { 150 } else { 236 })
|
||||||
.map(|chars| chars.iter().collect::<String>())
|
.map(|chars| chars.iter().collect::<String>())
|
||||||
{
|
{
|
||||||
if let Some(options) = &self.ncr_options
|
if let Some(ciphertext) = self
|
||||||
&& let Ok(encrypt) = self.state.lua.globals().get::<Function>("ncr_encrypt")
|
.ncr_options
|
||||||
&& let Ok(ciphertext) = encrypt.call::<String>((options, prepend_header(&chunk)))
|
.as_ref()
|
||||||
|
.and_then(|options| encrypt(options, &chunk).ok())
|
||||||
{
|
{
|
||||||
chunk = ciphertext;
|
chunk = ciphertext;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,18 +1,19 @@
|
|||||||
use std::{net::SocketAddr, process::exit};
|
use std::net::SocketAddr;
|
||||||
|
|
||||||
use anyhow::{Context, Result};
|
use anyhow::Result;
|
||||||
use azalea::{
|
use azalea::{
|
||||||
brigadier::exceptions::BuiltInExceptions::DispatcherUnknownCommand, prelude::*,
|
brigadier::errors::BuiltInError, prelude::*, protocol::packets::game::ClientboundGamePacket,
|
||||||
protocol::packets::game::ClientboundGamePacket,
|
|
||||||
};
|
};
|
||||||
use hyper::{server::conn::http1, service::service_fn};
|
use hyper::{server::conn::http1, service::service_fn};
|
||||||
use hyper_util::rt::TokioIo;
|
use hyper_util::rt::TokioIo;
|
||||||
use log::{debug, error, info, trace};
|
use log::{debug, error, info, trace};
|
||||||
use mlua::{Error, Function, IntoLuaMulti, Table};
|
use mlua::{Function, IntoLuaMulti, Table};
|
||||||
use ncr::utils::trim_header;
|
use ncr::utils::trim_header;
|
||||||
use tokio::net::TcpListener;
|
use tokio::net::TcpListener;
|
||||||
#[cfg(feature = "matrix")]
|
#[cfg(feature = "matrix")]
|
||||||
use {crate::matrix, std::time::Duration, tokio::time::sleep};
|
use {crate::matrix, std::time::Duration, tokio::time::sleep};
|
||||||
|
#[cfg(feature = "replay")]
|
||||||
|
use {crate::replay::recorder::Recorder, anyhow::Context, mlua::Error, std::process::exit};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
State,
|
State,
|
||||||
@@ -20,7 +21,6 @@ use crate::{
|
|||||||
http::serve,
|
http::serve,
|
||||||
lua::{client, direction::Direction, player::Player, vec3::Vec3},
|
lua::{client, direction::Direction, player::Player, vec3::Vec3},
|
||||||
particle,
|
particle,
|
||||||
replay::recorder::Recorder,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#[allow(clippy::cognitive_complexity, clippy::too_many_lines)]
|
#[allow(clippy::cognitive_complexity, clippy::too_many_lines)]
|
||||||
@@ -71,7 +71,7 @@ pub async fn handle_event(client: Client, event: Event, state: State) -> Result<
|
|||||||
}
|
}
|
||||||
.into(),
|
.into(),
|
||||||
)
|
)
|
||||||
&& error.type_ != DispatcherUnknownCommand
|
&& *error.kind() != BuiltInError::DispatcherUnknownCommand
|
||||||
{
|
{
|
||||||
CommandSource {
|
CommandSource {
|
||||||
client,
|
client,
|
||||||
@@ -97,6 +97,9 @@ pub async fn handle_event(client: Client, event: Event, state: State) -> Result<
|
|||||||
})
|
})
|
||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
Event::ConnectionFailed(error) => {
|
||||||
|
call_listeners(&state, "connection_failed", || Ok(error.to_string())).await
|
||||||
|
}
|
||||||
Event::Death(packet) => {
|
Event::Death(packet) => {
|
||||||
if let Some(packet) = packet {
|
if let Some(packet) = packet {
|
||||||
call_listeners(&state, "death", || {
|
call_listeners(&state, "death", || {
|
||||||
@@ -129,6 +132,7 @@ pub async fn handle_event(client: Client, event: Event, state: State) -> Result<
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
Event::KeepAlive(id) => call_listeners(&state, "keep_alive", || Ok(id)).await,
|
Event::KeepAlive(id) => call_listeners(&state, "keep_alive", || Ok(id)).await,
|
||||||
|
Event::ReceiveChunk(_) => Ok(()),
|
||||||
Event::RemovePlayer(player_info) => {
|
Event::RemovePlayer(player_info) => {
|
||||||
call_listeners(&state, "remove_player", || Ok(Player::from(player_info))).await
|
call_listeners(&state, "remove_player", || Ok(Player::from(player_info))).await
|
||||||
}
|
}
|
||||||
@@ -186,8 +190,11 @@ pub async fn handle_event(client: Client, event: Event, state: State) -> Result<
|
|||||||
ClientboundGamePacket::SetPassengers(packet) => {
|
ClientboundGamePacket::SetPassengers(packet) => {
|
||||||
call_listeners(&state, "set_passengers", || {
|
call_listeners(&state, "set_passengers", || {
|
||||||
let table = state.lua.create_table()?;
|
let table = state.lua.create_table()?;
|
||||||
table.set("vehicle", packet.vehicle)?;
|
table.set("vehicle", *packet.vehicle)?;
|
||||||
table.set("passengers", &*packet.passengers)?;
|
table.set(
|
||||||
|
"passengers",
|
||||||
|
packet.passengers.iter().map(|id| id.0).collect::<Vec<_>>(),
|
||||||
|
)?;
|
||||||
Ok(table)
|
Ok(table)
|
||||||
})
|
})
|
||||||
.await
|
.await
|
||||||
@@ -195,9 +202,7 @@ pub async fn handle_event(client: Client, event: Event, state: State) -> Result<
|
|||||||
ClientboundGamePacket::SetTime(packet) => {
|
ClientboundGamePacket::SetTime(packet) => {
|
||||||
call_listeners(&state, "set_time", || {
|
call_listeners(&state, "set_time", || {
|
||||||
let table = state.lua.create_table()?;
|
let table = state.lua.create_table()?;
|
||||||
table.set("day_time", packet.day_time)?;
|
|
||||||
table.set("game_time", packet.game_time)?;
|
table.set("game_time", packet.game_time)?;
|
||||||
table.set("tick_day_time", packet.tick_day_time)?;
|
|
||||||
Ok(table)
|
Ok(table)
|
||||||
})
|
})
|
||||||
.await
|
.await
|
||||||
@@ -213,13 +218,16 @@ pub async fn handle_event(client: Client, event: Event, state: State) -> Result<
|
|||||||
Event::Init => {
|
Event::Init => {
|
||||||
debug!("received init event");
|
debug!("received init event");
|
||||||
|
|
||||||
|
#[cfg(feature = "replay")]
|
||||||
|
{
|
||||||
let ecs = client.ecs.clone();
|
let ecs = client.ecs.clone();
|
||||||
ctrlc::set_handler(move || {
|
ctrlc::set_handler(move || {
|
||||||
ecs.lock()
|
ecs.write()
|
||||||
.remove_resource::<Recorder>()
|
.remove_resource::<Recorder>()
|
||||||
.map(Recorder::finish);
|
.map(Recorder::finish);
|
||||||
exit(0);
|
exit(0);
|
||||||
})?;
|
})?;
|
||||||
|
};
|
||||||
|
|
||||||
let globals = state.lua.globals();
|
let globals = state.lua.globals();
|
||||||
lua_init(client, &state, &globals).await?;
|
lua_init(client, &state, &globals).await?;
|
||||||
@@ -268,11 +276,13 @@ pub async fn handle_event(client: Client, event: Event, state: State) -> Result<
|
|||||||
}
|
}
|
||||||
|
|
||||||
async fn lua_init(client: Client, state: &State, globals: &Table) -> Result<()> {
|
async fn lua_init(client: Client, state: &State, globals: &Table) -> Result<()> {
|
||||||
|
#[cfg(feature = "replay")]
|
||||||
|
{
|
||||||
let ecs = client.ecs.clone();
|
let ecs = client.ecs.clone();
|
||||||
globals.set(
|
globals.set(
|
||||||
"finish_replay_recording",
|
"finish_replay_recording",
|
||||||
state.lua.create_function_mut(move |_, (): ()| {
|
state.lua.create_function_mut(move |_, (): ()| {
|
||||||
ecs.lock()
|
ecs.write()
|
||||||
.remove_resource::<Recorder>()
|
.remove_resource::<Recorder>()
|
||||||
.context("recording not active")
|
.context("recording not active")
|
||||||
.map_err(Error::external)?
|
.map_err(Error::external)?
|
||||||
@@ -280,6 +290,7 @@ async fn lua_init(client: Client, state: &State, globals: &Table) -> Result<()>
|
|||||||
.map_err(Error::external)
|
.map_err(Error::external)
|
||||||
})?,
|
})?,
|
||||||
)?;
|
)?;
|
||||||
|
}
|
||||||
globals.set("client", client::Client(Some(client)))?;
|
globals.set("client", client::Client(Some(client)))?;
|
||||||
call_listeners(state, "init", || Ok(())).await
|
call_listeners(state, "init", || Ok(())).await
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,20 +1,19 @@
|
|||||||
use azalea::{
|
use azalea::{
|
||||||
Vec3,
|
entity::Physics,
|
||||||
movement::{KnockbackEvent, KnockbackType},
|
movement::{KnockbackEvent, handle_knockback},
|
||||||
prelude::Component,
|
prelude::*,
|
||||||
};
|
};
|
||||||
use bevy_ecs::{event::EventMutator, query::With, system::Query};
|
use bevy_ecs::{observer::On, query::With, system::Query};
|
||||||
|
|
||||||
#[derive(Component)]
|
#[derive(Component)]
|
||||||
pub struct AntiKnockback;
|
pub struct AntiKnockback;
|
||||||
|
|
||||||
pub fn anti_knockback(
|
pub fn anti_knockback(
|
||||||
mut events: EventMutator<KnockbackEvent>,
|
knockback: On<KnockbackEvent>,
|
||||||
entity_query: Query<(), With<AntiKnockback>>,
|
entity_query: Query<(), With<AntiKnockback>>,
|
||||||
|
handle_knockback_query: Query<&mut Physics>,
|
||||||
) {
|
) {
|
||||||
for event in events.read() {
|
if entity_query.get(knockback.entity).is_err() {
|
||||||
if entity_query.get(event.entity).is_ok() {
|
handle_knockback(knockback, handle_knockback_query);
|
||||||
event.knockback = KnockbackType::Add(Vec3::default());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,19 +1,28 @@
|
|||||||
#![allow(clippy::needless_pass_by_value)]
|
|
||||||
|
|
||||||
pub mod anti_knockback;
|
pub mod anti_knockback;
|
||||||
|
|
||||||
use anti_knockback::anti_knockback;
|
use azalea::movement::KnockbackEvent;
|
||||||
use azalea::{connection::read_packets, movement::handle_knockback};
|
use bevy_app::{App, Plugin, PostStartup};
|
||||||
use bevy_app::{App, Plugin, PreUpdate};
|
use bevy_ecs::world::World;
|
||||||
use bevy_ecs::schedule::IntoScheduleConfigs;
|
|
||||||
|
|
||||||
pub struct HacksPlugin;
|
pub struct HacksPlugin;
|
||||||
|
|
||||||
impl Plugin for HacksPlugin {
|
impl Plugin for HacksPlugin {
|
||||||
fn build(&self, app: &mut App) {
|
fn build(&self, app: &mut App) {
|
||||||
app.add_systems(
|
app.add_systems(PostStartup, init_hacks);
|
||||||
PreUpdate,
|
|
||||||
anti_knockback.after(read_packets).before(handle_knockback),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
use azalea::blocks::{
|
use azalea::block::{
|
||||||
Block as AzaleaBlock, BlockState,
|
BlockState, BlockTrait,
|
||||||
properties::{ChestType, Facing, LightLevel},
|
properties::{ChestKind, Facing, LightLevel},
|
||||||
};
|
};
|
||||||
use mlua::{Function, Lua, Result, Table};
|
use mlua::{Function, Lua, Result, Table};
|
||||||
|
|
||||||
@@ -21,7 +21,7 @@ pub fn get_block_from_state(lua: &Lua, state: u32) -> Result<Option<Table>> {
|
|||||||
let Ok(state) = BlockState::try_from(state) else {
|
let Ok(state) = BlockState::try_from(state) else {
|
||||||
return Ok(None);
|
return Ok(None);
|
||||||
};
|
};
|
||||||
let block: Box<dyn AzaleaBlock> = state.into();
|
let block: Box<dyn BlockTrait> = state.into();
|
||||||
let behavior = block.behavior();
|
let behavior = block.behavior();
|
||||||
|
|
||||||
let table = lua.create_table()?;
|
let table = lua.create_table()?;
|
||||||
@@ -46,10 +46,10 @@ pub async fn get_block_states(
|
|||||||
for block in
|
for block in
|
||||||
(u32::MIN..u32::MAX).map_while(|possible_id| BlockState::try_from(possible_id).ok())
|
(u32::MIN..u32::MAX).map_while(|possible_id| BlockState::try_from(possible_id).ok())
|
||||||
{
|
{
|
||||||
if block_name == Into::<Box<dyn AzaleaBlock>>::into(block).id()
|
if block_name == Into::<Box<dyn BlockTrait>>::into(block).id()
|
||||||
&& (if let Some(filter_fn) = &filter_fn {
|
&& (if let Some(filter_fn) = &filter_fn {
|
||||||
let table = lua.create_table()?;
|
let table = lua.create_table()?;
|
||||||
table.set("chest_type", block.property::<ChestType>().map(|v| v as u8))?;
|
table.set("chest_kind", block.property::<ChestKind>().map(|v| v as u8))?;
|
||||||
table.set("facing", block.property::<Facing>().map(|v| v as u8))?;
|
table.set("facing", block.property::<Facing>().map(|v| v as u8))?;
|
||||||
table.set(
|
table.set(
|
||||||
"light_level",
|
"light_level",
|
||||||
|
|||||||
@@ -1,19 +1,20 @@
|
|||||||
use azalea::{
|
use azalea::{
|
||||||
BlockPos,
|
BlockPos,
|
||||||
inventory::{Inventory, Menu, Player, SlotList},
|
entity::inventory::Inventory,
|
||||||
prelude::ContainerClientExt,
|
inventory::{Menu, Player, SlotList},
|
||||||
protocol::packets::game::ServerboundSetCarriedItem,
|
protocol::packets::game::ServerboundSetCarriedItem,
|
||||||
};
|
};
|
||||||
use mlua::{Lua, Result, UserDataRef, Value};
|
use mlua::{Lua, Result, UserDataRef, Value};
|
||||||
|
|
||||||
use super::{Client, Container, ContainerRef, ItemStack, Vec3};
|
use super::{Client, Container, ContainerRef, ItemStack, Vec3};
|
||||||
|
use crate::unpack;
|
||||||
|
|
||||||
pub fn container(_lua: &Lua, client: &Client) -> Result<Option<ContainerRef>> {
|
pub fn container(_lua: &Lua, client: &Client) -> Result<ContainerRef> {
|
||||||
Ok(client.get_open_container().map(ContainerRef))
|
Ok(ContainerRef(client.get_inventory()))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn held_item(_lua: &Lua, client: &Client) -> Result<ItemStack> {
|
pub fn held_item(_lua: &Lua, client: &Client) -> Result<ItemStack> {
|
||||||
Ok(ItemStack(client.component::<Inventory>().held_item()))
|
Ok(ItemStack(client.get_held_item()))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn held_slot(_lua: &Lua, client: &Client) -> Result<u8> {
|
pub fn held_slot(_lua: &Lua, client: &Client) -> Result<u8> {
|
||||||
@@ -95,9 +96,10 @@ pub async fn open_container_at(
|
|||||||
client: UserDataRef<Client>,
|
client: UserDataRef<Client>,
|
||||||
position: Vec3,
|
position: Vec3,
|
||||||
) -> Result<Option<Container>> {
|
) -> Result<Option<Container>> {
|
||||||
|
let client = unpack!(client);
|
||||||
|
|
||||||
#[allow(clippy::cast_possible_truncation)]
|
#[allow(clippy::cast_possible_truncation)]
|
||||||
Ok(client
|
Ok(client
|
||||||
.clone()
|
|
||||||
.open_container_at(BlockPos::new(
|
.open_container_at(BlockPos::new(
|
||||||
position.x as i32,
|
position.x as i32,
|
||||||
position.y as i32,
|
position.y as i32,
|
||||||
@@ -116,17 +118,14 @@ pub fn set_held_slot(_lua: &Lua, client: &Client, slot: u8) -> Result<()> {
|
|||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
client.query_self::<&mut Inventory, _>(|mut inventory| {
|
||||||
let mut ecs = client.ecs.lock();
|
if inventory.selected_hotbar_slot != slot {
|
||||||
let mut inventory = client.query::<&mut Inventory>(&mut ecs);
|
|
||||||
if inventory.selected_hotbar_slot == slot {
|
|
||||||
return Ok(());
|
|
||||||
}
|
|
||||||
inventory.selected_hotbar_slot = slot;
|
inventory.selected_hotbar_slot = slot;
|
||||||
};
|
}
|
||||||
|
});
|
||||||
client.write_packet(ServerboundSetCarriedItem {
|
client.write_packet(ServerboundSetCarriedItem {
|
||||||
slot: u16::from(slot),
|
slot: u16::from(slot),
|
||||||
});
|
});
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,13 +1,17 @@
|
|||||||
use azalea::{
|
use azalea::{
|
||||||
BlockPos, BotClientExt, interact::StartUseItemEvent,
|
BlockPos,
|
||||||
protocol::packets::game::s_interact::InteractionHand, world::MinecraftEntityId,
|
core::entity_id::MinecraftEntityId,
|
||||||
|
protocol::packets::game::{ServerboundUseItem, s_interact::InteractionHand},
|
||||||
};
|
};
|
||||||
use mlua::{Lua, Result, UserDataRef};
|
use mlua::{Lua, Result, UserDataRef};
|
||||||
|
|
||||||
use super::{Client, Vec3};
|
use super::{Client, Vec3};
|
||||||
|
use crate::unpack;
|
||||||
|
|
||||||
pub fn attack(_lua: &Lua, client: &Client, entity_id: i32) -> Result<()> {
|
pub fn attack(_lua: &Lua, client: &Client, entity_id: i32) -> Result<()> {
|
||||||
client.attack(MinecraftEntityId(entity_id));
|
if let Some(entity) = client.entity_id_by_minecraft_id(MinecraftEntityId(entity_id)) {
|
||||||
|
client.attack(entity);
|
||||||
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -26,9 +30,10 @@ pub fn has_attack_cooldown(_lua: &Lua, client: &Client) -> Result<bool> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub async fn mine(_lua: Lua, client: UserDataRef<Client>, position: Vec3) -> Result<()> {
|
pub async fn mine(_lua: Lua, client: UserDataRef<Client>, position: Vec3) -> Result<()> {
|
||||||
|
let client = unpack!(client);
|
||||||
|
|
||||||
#[allow(clippy::cast_possible_truncation)]
|
#[allow(clippy::cast_possible_truncation)]
|
||||||
client
|
client
|
||||||
.clone()
|
|
||||||
.mine(BlockPos::new(
|
.mine(BlockPos::new(
|
||||||
position.x as i32,
|
position.x as i32,
|
||||||
position.y as i32,
|
position.y as i32,
|
||||||
@@ -54,13 +59,15 @@ pub fn start_mining(_lua: &Lua, client: &Client, position: Vec3) -> Result<()> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn start_use_item(_lua: &Lua, client: &Client, hand: Option<u8>) -> Result<()> {
|
pub fn start_use_item(_lua: &Lua, client: &Client, hand: Option<u8>) -> Result<()> {
|
||||||
client.ecs.lock().send_event(StartUseItemEvent {
|
let direction = client.direction();
|
||||||
entity: client.entity,
|
client.write_packet(ServerboundUseItem {
|
||||||
hand: match hand {
|
hand: match hand {
|
||||||
Some(1) => InteractionHand::OffHand,
|
Some(1) => InteractionHand::OffHand,
|
||||||
_ => InteractionHand::MainHand,
|
_ => InteractionHand::MainHand,
|
||||||
},
|
},
|
||||||
force_block: None,
|
seq: 0,
|
||||||
|
x_rot: direction.x_rot(),
|
||||||
|
y_rot: direction.y_rot(),
|
||||||
});
|
});
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,9 +6,9 @@ mod movement;
|
|||||||
mod state;
|
mod state;
|
||||||
mod world;
|
mod world;
|
||||||
|
|
||||||
use std::ops::{Deref, DerefMut};
|
use std::ops::Deref;
|
||||||
|
|
||||||
use azalea::{Client as AzaleaClient, world::MinecraftEntityId};
|
use azalea::{Client as AzaleaClient, core::entity_id::MinecraftEntityId};
|
||||||
use mlua::{Lua, Result, UserData, UserDataFields, UserDataMethods};
|
use mlua::{Lua, Result, UserData, UserDataFields, UserDataMethods};
|
||||||
|
|
||||||
use super::{
|
use super::{
|
||||||
@@ -28,18 +28,13 @@ impl Deref for Client {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl DerefMut for Client {
|
|
||||||
fn deref_mut(&mut self) -> &mut Self::Target {
|
|
||||||
self.0.as_mut().expect("should have received init event")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl UserData for Client {
|
impl UserData for Client {
|
||||||
fn add_fields<F: UserDataFields<Self>>(f: &mut F) {
|
fn add_fields<F: UserDataFields<Self>>(f: &mut F) {
|
||||||
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::direction);
|
f.add_field_method_get("direction", movement::direction);
|
||||||
|
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);
|
||||||
@@ -52,7 +47,6 @@ impl UserData for Client {
|
|||||||
f.add_field_method_get("menu", container::menu);
|
f.add_field_method_get("menu", container::menu);
|
||||||
f.add_field_method_get("pathfinder", movement::pathfinder);
|
f.add_field_method_get("pathfinder", movement::pathfinder);
|
||||||
f.add_field_method_get("position", movement::position);
|
f.add_field_method_get("position", movement::position);
|
||||||
f.add_field_method_get("score", state::score);
|
|
||||||
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);
|
||||||
@@ -121,3 +115,12 @@ fn username(_lua: &Lua, client: &Client) -> Result<String> {
|
|||||||
fn uuid(_lua: &Lua, client: &Client) -> Result<String> {
|
fn uuid(_lua: &Lua, client: &Client) -> Result<String> {
|
||||||
Ok(client.uuid().to_string())
|
Ok(client.uuid().to_string())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[macro_export]
|
||||||
|
macro_rules! unpack {
|
||||||
|
($client:ident) => {{
|
||||||
|
let inner = (**$client).clone();
|
||||||
|
drop($client);
|
||||||
|
inner
|
||||||
|
}};
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,18 +1,18 @@
|
|||||||
use azalea::{
|
use azalea::{
|
||||||
BlockPos, BotClientExt, SprintDirection, WalkDirection,
|
BlockPos, Client as AzaleaClient, SprintDirection, WalkDirection,
|
||||||
core::hit_result::HitResult,
|
core::{entity_id::MinecraftEntityId, hit_result::HitResult},
|
||||||
entity::Position,
|
entity::Position,
|
||||||
interact::HitResultComponent,
|
interact::pick::HitResultComponent,
|
||||||
pathfinder::{
|
pathfinder::{
|
||||||
ExecutingPath, Pathfinder, PathfinderClientExt,
|
ExecutingPath, Pathfinder, PathfinderClientExt, PathfinderOpts,
|
||||||
goals::{BlockPosGoal, Goal, InverseGoal, RadiusGoal, ReachBlockPosGoal, XZGoal, YGoal},
|
goals::{BlockPosGoal, Goal, RadiusGoal, ReachBlockPosGoal, XZGoal, YGoal},
|
||||||
},
|
},
|
||||||
protocol::packets::game::{ServerboundPlayerCommand, s_player_command::Action},
|
protocol::packets::game::{ServerboundPlayerCommand, s_player_command::Action},
|
||||||
world::MinecraftEntityId,
|
|
||||||
};
|
};
|
||||||
use mlua::{FromLua, Lua, Result, Table, UserDataRef, Value};
|
use mlua::{FromLua, Lua, Result, Table, UserDataRef, Value};
|
||||||
|
|
||||||
use super::{Client, Direction, Vec3};
|
use super::{Client, Direction, Vec3};
|
||||||
|
use crate::unpack;
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
struct AnyGoal(Box<dyn Goal>);
|
struct AnyGoal(Box<dyn Goal>);
|
||||||
@@ -28,7 +28,7 @@ impl Goal for AnyGoal {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[allow(clippy::cast_possible_truncation)]
|
#[allow(clippy::cast_possible_truncation)]
|
||||||
fn to_goal(lua: &Lua, client: &Client, data: Table, options: &Table, kind: u8) -> Result<AnyGoal> {
|
fn to_goal(lua: &Lua, client: &AzaleaClient, data: Table, kind: u8) -> Result<AnyGoal> {
|
||||||
let goal: Box<dyn Goal> = match kind {
|
let goal: Box<dyn Goal> = match kind {
|
||||||
1 => {
|
1 => {
|
||||||
let pos = Vec3::from_lua(data.get("position")?, lua)?;
|
let pos = Vec3::from_lua(data.get("position")?, lua)?;
|
||||||
@@ -61,11 +61,7 @@ fn to_goal(lua: &Lua, client: &Client, data: Table, options: &Table, kind: u8) -
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
Ok(AnyGoal(if options.get("inverse").unwrap_or_default() {
|
Ok(AnyGoal(goal))
|
||||||
Box::new(InverseGoal(AnyGoal(goal)))
|
|
||||||
} else {
|
|
||||||
goal
|
|
||||||
}))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn go_to_reached(_lua: &Lua, client: &Client) -> Result<bool> {
|
pub fn go_to_reached(_lua: &Lua, client: &Client) -> Result<bool> {
|
||||||
@@ -73,6 +69,7 @@ pub fn go_to_reached(_lua: &Lua, client: &Client) -> Result<bool> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub async fn wait_until_goal_reached(_lua: Lua, client: UserDataRef<Client>, (): ()) -> Result<()> {
|
pub async fn wait_until_goal_reached(_lua: Lua, client: UserDataRef<Client>, (): ()) -> Result<()> {
|
||||||
|
let client = unpack!(client);
|
||||||
client.wait_until_goto_target_reached().await;
|
client.wait_until_goto_target_reached().await;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
@@ -82,21 +79,24 @@ pub async fn go_to(
|
|||||||
client: UserDataRef<Client>,
|
client: UserDataRef<Client>,
|
||||||
(data, metadata): (Table, Option<Table>),
|
(data, metadata): (Table, Option<Table>),
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
|
let client = unpack!(client);
|
||||||
|
|
||||||
let metadata = metadata.unwrap_or(lua.create_table()?);
|
let metadata = metadata.unwrap_or(lua.create_table()?);
|
||||||
let options = metadata.get("options").unwrap_or(lua.create_table()?);
|
let options = metadata.get("options").unwrap_or(lua.create_table()?);
|
||||||
let goal = to_goal(
|
let goal = to_goal(
|
||||||
&lua,
|
&lua,
|
||||||
&client,
|
&client,
|
||||||
data,
|
data,
|
||||||
&options,
|
|
||||||
metadata.get("type").unwrap_or_default(),
|
metadata.get("type").unwrap_or_default(),
|
||||||
)?;
|
)?;
|
||||||
if options.get("without_mining").unwrap_or_default() {
|
client
|
||||||
client.start_goto_without_mining(goal);
|
.goto_with_opts(
|
||||||
client.wait_until_goto_target_reached().await;
|
goal,
|
||||||
} else {
|
PathfinderOpts::new()
|
||||||
client.goto(goal).await;
|
.allow_mining(!options.get::<bool>("without_mining").unwrap_or_default()),
|
||||||
}
|
)
|
||||||
|
.await;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -105,20 +105,21 @@ pub async fn start_go_to(
|
|||||||
client: UserDataRef<Client>,
|
client: UserDataRef<Client>,
|
||||||
(data, metadata): (Table, Option<Table>),
|
(data, metadata): (Table, Option<Table>),
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
|
let client = unpack!(client);
|
||||||
|
|
||||||
let metadata = metadata.unwrap_or(lua.create_table()?);
|
let metadata = metadata.unwrap_or(lua.create_table()?);
|
||||||
let options = metadata.get("options").unwrap_or(lua.create_table()?);
|
let options = metadata.get("options").unwrap_or(lua.create_table()?);
|
||||||
let goal = to_goal(
|
let goal = to_goal(
|
||||||
&lua,
|
&lua,
|
||||||
&client,
|
&client,
|
||||||
data,
|
data,
|
||||||
&options,
|
|
||||||
metadata.get("type").unwrap_or_default(),
|
metadata.get("type").unwrap_or_default(),
|
||||||
)?;
|
)?;
|
||||||
if options.get("without_mining").unwrap_or_default() {
|
client.start_goto_with_opts(
|
||||||
client.start_goto_without_mining(goal);
|
goal,
|
||||||
} else {
|
PathfinderOpts::new()
|
||||||
client.start_goto(goal);
|
.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(())
|
||||||
@@ -127,8 +128,8 @@ pub async fn start_go_to(
|
|||||||
pub fn 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.0,
|
y: direction.y_rot(),
|
||||||
x: direction.1,
|
x: direction.x_rot(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -143,7 +144,7 @@ pub fn jump(_lua: &Lua, client: &Client, (): ()) -> Result<()> {
|
|||||||
|
|
||||||
pub fn 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()?;
|
||||||
table.set("direction", Vec3::from(result.direction.normal()))?;
|
table.set("direction", Vec3::from(result.direction.normal()))?;
|
||||||
table.set("inside", result.inside)?;
|
table.set("inside", result.inside)?;
|
||||||
@@ -176,8 +177,8 @@ pub fn pathfinder(lua: &Lua, client: &Client) -> Result<Table> {
|
|||||||
Vec3::from(pathfinder.last_reached_node),
|
Vec3::from(pathfinder.last_reached_node),
|
||||||
)?;
|
)?;
|
||||||
table.set(
|
table.set(
|
||||||
"last_node_reach_elapsed",
|
"ticks_since_last_node_reached",
|
||||||
pathfinder.last_node_reached_at.elapsed().as_millis(),
|
pathfinder.ticks_since_last_node_reached,
|
||||||
)?;
|
)?;
|
||||||
table.set("is_path_partial", pathfinder.is_path_partial)?;
|
table.set("is_path_partial", pathfinder.is_path_partial)?;
|
||||||
true
|
true
|
||||||
@@ -189,7 +190,7 @@ pub fn pathfinder(lua: &Lua, client: &Client) -> Result<Table> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn 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 set_direction(_lua: &Lua, client: &Client, direction: Direction) -> Result<()> {
|
pub fn set_direction(_lua: &Lua, client: &Client, direction: Direction) -> Result<()> {
|
||||||
@@ -202,25 +203,17 @@ pub fn set_jumping(_lua: &Lua, client: &Client, jumping: bool) -> Result<()> {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_position(_lua: &Lua, client: &Client, new_position: Vec3) -> Result<()> {
|
pub fn set_position(_lua: &Lua, client: &Client, new_pos: Vec3) -> Result<()> {
|
||||||
let mut ecs = client.ecs.lock();
|
client.query_self::<&mut Position, _>(|mut pos| {
|
||||||
let mut position = client.query::<&mut Position>(&mut ecs);
|
pos.x = new_pos.x;
|
||||||
position.x = new_position.x;
|
pos.y = new_pos.y;
|
||||||
position.y = new_position.y;
|
pos.z = new_pos.z;
|
||||||
position.z = new_position.z;
|
});
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_sneaking(_lua: &Lua, client: &Client, sneaking: bool) -> Result<()> {
|
pub fn set_sneaking(_lua: &Lua, client: &Client, sneaking: bool) -> Result<()> {
|
||||||
client.write_packet(ServerboundPlayerCommand {
|
client.set_crouching(sneaking);
|
||||||
id: client.component::<MinecraftEntityId>(),
|
|
||||||
action: if sneaking {
|
|
||||||
Action::PressShiftKey
|
|
||||||
} else {
|
|
||||||
Action::ReleaseShiftKey
|
|
||||||
},
|
|
||||||
data: 0,
|
|
||||||
});
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -240,7 +233,7 @@ pub fn stop_pathfinding(_lua: &Lua, client: &Client, (): ()) -> Result<()> {
|
|||||||
|
|
||||||
pub fn stop_sleeping(_lua: &Lua, client: &Client, (): ()) -> Result<()> {
|
pub fn stop_sleeping(_lua: &Lua, client: &Client, (): ()) -> Result<()> {
|
||||||
client.write_packet(ServerboundPlayerCommand {
|
client.write_packet(ServerboundPlayerCommand {
|
||||||
id: client.component::<MinecraftEntityId>(),
|
id: *client.component::<MinecraftEntityId>(),
|
||||||
action: Action::StopSleeping,
|
action: Action::StopSleeping,
|
||||||
data: 0,
|
data: 0,
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,18 +1,25 @@
|
|||||||
use azalea::{
|
use azalea::{
|
||||||
ClientInformation,
|
ClientInformation, entity::metadata::AirSupply, pathfinder::debug::PathfinderDebugParticles,
|
||||||
entity::metadata::{AirSupply, Score},
|
|
||||||
pathfinder::debug::PathfinderDebugParticles,
|
|
||||||
protocol::common::client_information::ModelCustomization,
|
protocol::common::client_information::ModelCustomization,
|
||||||
};
|
};
|
||||||
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;
|
use crate::{hacks::anti_knockback::AntiKnockback, 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)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn experience(lua: &Lua, client: &Client) -> Result<Table> {
|
||||||
|
let experience = client.experience();
|
||||||
|
let table = lua.create_table()?;
|
||||||
|
table.set("progress", experience.progress)?;
|
||||||
|
table.set("total", experience.total)?;
|
||||||
|
table.set("level", experience.level)?;
|
||||||
|
Ok(table)
|
||||||
|
}
|
||||||
|
|
||||||
pub fn health(_lua: &Lua, client: &Client) -> Result<f32> {
|
pub fn health(_lua: &Lua, client: &Client) -> Result<f32> {
|
||||||
Ok(client.health())
|
Ok(client.health())
|
||||||
}
|
}
|
||||||
@@ -25,18 +32,15 @@ pub fn hunger(lua: &Lua, client: &Client) -> Result<Table> {
|
|||||||
Ok(table)
|
Ok(table)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn score(_lua: &Lua, client: &Client) -> Result<i32> {
|
|
||||||
Ok(client.component::<Score>().0)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub async fn set_client_information(
|
pub async fn set_client_information(
|
||||||
_lua: Lua,
|
_lua: Lua,
|
||||||
client: UserDataRef<Client>,
|
client: UserDataRef<Client>,
|
||||||
info: Table,
|
info: Table,
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
|
let client = unpack!(client);
|
||||||
|
|
||||||
let get_bool = |table: &Table, name| table.get(name).unwrap_or(true);
|
let get_bool = |table: &Table, name| table.get(name).unwrap_or(true);
|
||||||
client
|
client.set_client_information(ClientInformation {
|
||||||
.set_client_information(ClientInformation {
|
|
||||||
allows_listing: info.get("allows_listing")?,
|
allows_listing: info.get("allows_listing")?,
|
||||||
model_customization: info
|
model_customization: info
|
||||||
.get::<Table>("model_customization")
|
.get::<Table>("model_customization")
|
||||||
@@ -53,8 +57,7 @@ pub async fn set_client_information(
|
|||||||
.unwrap_or_default(),
|
.unwrap_or_default(),
|
||||||
view_distance: info.get("view_distance").unwrap_or(8),
|
view_distance: info.get("view_distance").unwrap_or(8),
|
||||||
..ClientInformation::default()
|
..ClientInformation::default()
|
||||||
})
|
});
|
||||||
.await;
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -65,7 +68,7 @@ pub fn set_component(
|
|||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
macro_rules! set {
|
macro_rules! set {
|
||||||
($name:ident) => {{
|
($name:ident) => {{
|
||||||
let mut ecs = client.ecs.lock();
|
let mut ecs = client.ecs.write();
|
||||||
let mut entity = ecs.entity_mut(client.entity);
|
let mut entity = ecs.entity_mut(client.entity);
|
||||||
if enabled.unwrap_or(true) {
|
if enabled.unwrap_or(true) {
|
||||||
entity.insert($name)
|
entity.insert($name)
|
||||||
|
|||||||
@@ -1,16 +1,16 @@
|
|||||||
use azalea::{
|
use azalea::{
|
||||||
BlockPos,
|
BlockPos,
|
||||||
blocks::{BlockState, BlockStates},
|
block::{BlockState, BlockStates},
|
||||||
ecs::query::{With, Without},
|
ecs::query::{With, Without},
|
||||||
entity::{
|
entity::{
|
||||||
Dead, EntityKind, EntityUuid, LookDirection, Pose, Position as AzaleaPosition,
|
Dead, EntityKindComponent, EntityUuid, LookDirection, Pose, Position as AzaleaPosition,
|
||||||
metadata::{CustomName, Owneruuid, Player},
|
metadata::{CustomName, Owneruuid, Player},
|
||||||
},
|
},
|
||||||
world::MinecraftEntityId,
|
|
||||||
};
|
};
|
||||||
use mlua::{Function, Lua, Result, Table, UserDataRef};
|
use mlua::{Function, Lua, Result, Table, UserDataRef};
|
||||||
|
|
||||||
use super::{Client, Direction, Vec3};
|
use super::{Client, Direction, Vec3};
|
||||||
|
use crate::{lua::client::MinecraftEntityId, unpack};
|
||||||
|
|
||||||
pub fn blocks(
|
pub fn blocks(
|
||||||
_lua: &Lua,
|
_lua: &Lua,
|
||||||
@@ -39,6 +39,8 @@ pub fn blocks(
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub async fn all_entities(lua: Lua, client: UserDataRef<Client>, (): ()) -> Result<Vec<Table>> {
|
pub async fn all_entities(lua: Lua, client: UserDataRef<Client>, (): ()) -> Result<Vec<Table>> {
|
||||||
|
let client = unpack!(client);
|
||||||
|
|
||||||
let mut matched = Vec::with_capacity(256);
|
let mut matched = Vec::with_capacity(256);
|
||||||
for (position, custom_name, kind, uuid, direction, id, owner_uuid, pose) in
|
for (position, custom_name, kind, uuid, direction, id, owner_uuid, pose) in
|
||||||
get_entities!(client)
|
get_entities!(client)
|
||||||
@@ -65,6 +67,8 @@ pub async fn entities(
|
|||||||
client: UserDataRef<Client>,
|
client: UserDataRef<Client>,
|
||||||
filter_fn: Function,
|
filter_fn: Function,
|
||||||
) -> Result<Vec<Table>> {
|
) -> Result<Vec<Table>> {
|
||||||
|
let client = unpack!(client);
|
||||||
|
|
||||||
let mut matched = Vec::new();
|
let mut matched = Vec::new();
|
||||||
for (position, custom_name, kind, uuid, direction, id, owner_uuid, pose) in
|
for (position, custom_name, kind, uuid, direction, id, owner_uuid, pose) in
|
||||||
get_entities!(client)
|
get_entities!(client)
|
||||||
@@ -89,6 +93,8 @@ pub async fn entities(
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub async fn all_players(lua: Lua, client: UserDataRef<Client>, (): ()) -> Result<Vec<Table>> {
|
pub async fn all_players(lua: Lua, client: UserDataRef<Client>, (): ()) -> Result<Vec<Table>> {
|
||||||
|
let client = unpack!(client);
|
||||||
|
|
||||||
let mut matched = Vec::new();
|
let mut matched = Vec::new();
|
||||||
for (id, uuid, kind, position, direction, pose) in get_players!(client) {
|
for (id, uuid, kind, position, direction, pose) in get_players!(client) {
|
||||||
let table = lua.create_table()?;
|
let table = lua.create_table()?;
|
||||||
@@ -108,6 +114,8 @@ pub async fn players(
|
|||||||
client: UserDataRef<Client>,
|
client: UserDataRef<Client>,
|
||||||
filter_fn: Function,
|
filter_fn: Function,
|
||||||
) -> Result<Vec<Table>> {
|
) -> Result<Vec<Table>> {
|
||||||
|
let client = unpack!(client);
|
||||||
|
|
||||||
let mut matched = Vec::new();
|
let mut matched = Vec::new();
|
||||||
for (id, uuid, kind, position, direction, pose) in get_players!(client) {
|
for (id, uuid, kind, position, direction, pose) in get_players!(client) {
|
||||||
let table = lua.create_table()?;
|
let table = lua.create_table()?;
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
mod queries;
|
mod queries;
|
||||||
pub mod find;
|
pub mod find;
|
||||||
|
|
||||||
use azalea::{BlockPos, auto_tool::AutoToolClientExt, blocks::BlockState, world::InstanceName};
|
use azalea::{BlockPos, block::BlockState, world::WorldName};
|
||||||
use mlua::{Lua, Result, Table, Value};
|
use mlua::{Lua, Result, Table, Value};
|
||||||
|
|
||||||
use super::{Client, Direction, Vec3};
|
use super::{Client, Direction, Vec3};
|
||||||
@@ -19,7 +19,7 @@ pub fn best_tool_for_block(lua: &Lua, client: &Client, block_state: u16) -> Resu
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn dimension(_lua: &Lua, client: &Client) -> Result<String> {
|
pub fn dimension(_lua: &Lua, client: &Client) -> Result<String> {
|
||||||
Ok(client.component::<InstanceName>().to_string())
|
Ok(client.component::<WorldName>().to_string())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_block_state(_lua: &Lua, client: &Client, position: Vec3) -> Result<Option<u16>> {
|
pub fn get_block_state(_lua: &Lua, client: &Client, position: Vec3) -> Result<Option<u16>> {
|
||||||
@@ -27,7 +27,7 @@ pub fn get_block_state(_lua: &Lua, client: &Client, position: Vec3) -> Result<Op
|
|||||||
Ok(client
|
Ok(client
|
||||||
.world()
|
.world()
|
||||||
.read()
|
.read()
|
||||||
.get_block_state(&BlockPos::new(
|
.get_block_state(BlockPos::new(
|
||||||
position.x as i32,
|
position.x as i32,
|
||||||
position.y as i32,
|
position.y as i32,
|
||||||
position.z as i32,
|
position.z as i32,
|
||||||
@@ -37,7 +37,7 @@ pub fn get_block_state(_lua: &Lua, client: &Client, position: Vec3) -> Result<Op
|
|||||||
|
|
||||||
#[allow(clippy::cast_possible_truncation)]
|
#[allow(clippy::cast_possible_truncation)]
|
||||||
pub fn get_fluid_state(lua: &Lua, client: &Client, position: Vec3) -> Result<Option<Table>> {
|
pub fn get_fluid_state(lua: &Lua, client: &Client, position: Vec3) -> Result<Option<Table>> {
|
||||||
let fluid_state = client.world().read().get_fluid_state(&BlockPos::new(
|
let fluid_state = client.world().read().get_fluid_state(BlockPos::new(
|
||||||
position.x as i32,
|
position.x as i32,
|
||||||
position.y as i32,
|
position.y as i32,
|
||||||
position.z as i32,
|
position.z as i32,
|
||||||
|
|||||||
@@ -1,22 +1,24 @@
|
|||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! get_entities {
|
macro_rules! get_entities {
|
||||||
($client:ident) => {{
|
($client:ident) => {{
|
||||||
let mut ecs = $client.ecs.lock();
|
let ecs = $client.ecs.read();
|
||||||
ecs.query::<(
|
ecs.try_query::<(
|
||||||
&AzaleaPosition,
|
&AzaleaPosition,
|
||||||
&CustomName,
|
&CustomName,
|
||||||
&EntityKind,
|
&EntityKindComponent,
|
||||||
&EntityUuid,
|
&EntityUuid,
|
||||||
&LookDirection,
|
&LookDirection,
|
||||||
&MinecraftEntityId,
|
&MinecraftEntityId,
|
||||||
Option<&Owneruuid>,
|
Option<&Owneruuid>,
|
||||||
&Pose,
|
&Pose,
|
||||||
)>()
|
)>()
|
||||||
|
.map(|mut query| {
|
||||||
|
query
|
||||||
.iter(&ecs)
|
.iter(&ecs)
|
||||||
.map(
|
.map(
|
||||||
|(position, custom_name, kind, uuid, direction, id, owner_uuid, pose)| {
|
|(position, custom_name, kind, uuid, direction, id, owner_uuid, pose)| {
|
||||||
(
|
(
|
||||||
Vec3::from(position),
|
Vec3::from(*position),
|
||||||
custom_name.as_ref().map(ToString::to_string),
|
custom_name.as_ref().map(ToString::to_string),
|
||||||
kind.to_string(),
|
kind.to_string(),
|
||||||
uuid.to_string(),
|
uuid.to_string(),
|
||||||
@@ -28,32 +30,38 @@ macro_rules! get_entities {
|
|||||||
},
|
},
|
||||||
)
|
)
|
||||||
.collect::<Vec<_>>()
|
.collect::<Vec<_>>()
|
||||||
|
})
|
||||||
|
.unwrap_or_default()
|
||||||
}};
|
}};
|
||||||
}
|
}
|
||||||
|
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! get_players {
|
macro_rules! get_players {
|
||||||
($client:ident) => {{
|
($client:ident) => {{
|
||||||
let mut ecs = $client.ecs.lock();
|
let ecs = $client.ecs.read();
|
||||||
ecs.query_filtered::<(
|
ecs.try_query_filtered::<(
|
||||||
&MinecraftEntityId,
|
&MinecraftEntityId,
|
||||||
&EntityUuid,
|
&EntityUuid,
|
||||||
&EntityKind,
|
&EntityKindComponent,
|
||||||
&AzaleaPosition,
|
&AzaleaPosition,
|
||||||
&LookDirection,
|
&LookDirection,
|
||||||
&Pose,
|
&Pose,
|
||||||
), (With<Player>, Without<Dead>)>()
|
), (With<Player>, Without<Dead>)>()
|
||||||
|
.map(|mut 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<_>>()
|
||||||
|
})
|
||||||
|
.unwrap_or_default()
|
||||||
}};
|
}};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
use azalea::inventory::{
|
use azalea::inventory::{
|
||||||
self,
|
self, ItemStackData,
|
||||||
components::{Consumable, CustomName, Damage, Food, MaxDamage},
|
components::{Consumable, CustomName, Damage, Food, MaxDamage},
|
||||||
};
|
};
|
||||||
use mlua::{UserData, UserDataFields, UserDataMethods};
|
use mlua::{UserData, UserDataFields, UserDataMethods};
|
||||||
@@ -14,8 +14,7 @@ impl UserData for ItemStack {
|
|||||||
f.add_field_method_get("kind", |_, this| Ok(this.0.kind().to_string()));
|
f.add_field_method_get("kind", |_, this| Ok(this.0.kind().to_string()));
|
||||||
f.add_field_method_get("custom_name", |_, this| {
|
f.add_field_method_get("custom_name", |_, this| {
|
||||||
Ok(this.0.as_present().map(|data| {
|
Ok(this.0.as_present().map(|data| {
|
||||||
data.components
|
data.get_component::<CustomName>()
|
||||||
.get::<CustomName>()
|
|
||||||
.map(|c| c.name.to_string())
|
.map(|c| c.name.to_string())
|
||||||
}))
|
}))
|
||||||
});
|
});
|
||||||
@@ -23,13 +22,13 @@ impl UserData for ItemStack {
|
|||||||
Ok(this
|
Ok(this
|
||||||
.0
|
.0
|
||||||
.as_present()
|
.as_present()
|
||||||
.map(|data| data.components.get::<Damage>().map(|d| d.amount)))
|
.map(|data| data.get_component::<Damage>().map(|d| d.amount)))
|
||||||
});
|
});
|
||||||
f.add_field_method_get("max_damage", |_, this| {
|
f.add_field_method_get("max_damage", |_, this| {
|
||||||
Ok(this
|
Ok(this
|
||||||
.0
|
.0
|
||||||
.as_present()
|
.as_present()
|
||||||
.map(|data| data.components.get::<MaxDamage>().map(|d| d.amount)))
|
.map(|data| data.get_component::<MaxDamage>().map(|d| d.amount)))
|
||||||
});
|
});
|
||||||
|
|
||||||
f.add_field_method_get("consumable", |lua, this| {
|
f.add_field_method_get("consumable", |lua, this| {
|
||||||
@@ -37,7 +36,7 @@ impl UserData for ItemStack {
|
|||||||
if let Some(consumable) = this
|
if let Some(consumable) = this
|
||||||
.0
|
.0
|
||||||
.as_present()
|
.as_present()
|
||||||
.and_then(|data| data.components.get::<Consumable>())
|
.and_then(ItemStackData::get_component::<Consumable>)
|
||||||
{
|
{
|
||||||
let table = lua.create_table()?;
|
let table = lua.create_table()?;
|
||||||
table.set("animation", consumable.animation as u8)?;
|
table.set("animation", consumable.animation as u8)?;
|
||||||
@@ -55,13 +54,12 @@ impl UserData for ItemStack {
|
|||||||
if let Some(food) = this
|
if let Some(food) = this
|
||||||
.0
|
.0
|
||||||
.as_present()
|
.as_present()
|
||||||
.and_then(|data| data.components.get::<Food>())
|
.and_then(ItemStackData::get_component::<Food>)
|
||||||
{
|
{
|
||||||
let table = lua.create_table()?;
|
let table = lua.create_table()?;
|
||||||
table.set("nutrition", food.nutrition)?;
|
table.set("nutrition", food.nutrition)?;
|
||||||
table.set("saturation", food.saturation)?;
|
table.set("saturation", food.saturation)?;
|
||||||
table.set("can_always_eat", food.can_always_eat)?;
|
table.set("can_always_eat", food.can_always_eat)?;
|
||||||
table.set("eat_seconds", food.eat_seconds)?;
|
|
||||||
Some(table)
|
Some(table)
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
|
|||||||
@@ -10,8 +10,8 @@ pub struct Direction {
|
|||||||
impl From<&LookDirection> for Direction {
|
impl From<&LookDirection> for Direction {
|
||||||
fn from(d: &LookDirection) -> Self {
|
fn from(d: &LookDirection) -> Self {
|
||||||
Self {
|
Self {
|
||||||
y: d.y_rot,
|
y: d.y_rot(),
|
||||||
x: d.x_rot,
|
x: d.x_rot(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,9 +3,8 @@ macro_rules! crypt {
|
|||||||
($op:ident, $options:expr, $text:expr) => {{
|
($op:ident, $options:expr, $text:expr) => {{
|
||||||
macro_rules! crypt_with {
|
macro_rules! crypt_with {
|
||||||
($algo:ident) => {{
|
($algo:ident) => {{
|
||||||
let encoding = $options.get("encoding").unwrap_or_default();
|
|
||||||
let key = &$options.get::<UserDataRef<AesKey>>("key")?.0;
|
let key = &$options.get::<UserDataRef<AesKey>>("key")?.0;
|
||||||
match encoding {
|
match $options.get("encoding").unwrap_or_default() {
|
||||||
1 => $algo::<Base64Encoding>::$op($text, &key),
|
1 => $algo::<Base64Encoding>::$op($text, &key),
|
||||||
2 => $algo::<Base64rEncoding>::$op($text, &key),
|
2 => $algo::<Base64rEncoding>::$op($text, &key),
|
||||||
_ => $algo::<NewBase64rEncoding>::$op($text, &key),
|
_ => $algo::<NewBase64rEncoding>::$op($text, &key),
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
use azalea::PlayerInfo;
|
use azalea::player::PlayerInfo;
|
||||||
use mlua::{IntoLua, Lua, Result, Value};
|
use mlua::{IntoLua, Lua, Result, Value};
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
|
|||||||
@@ -28,8 +28,8 @@ impl From<azalea::Vec3> for Vec3 {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<&Position> for Vec3 {
|
impl From<Position> for Vec3 {
|
||||||
fn from(p: &Position) -> Self {
|
fn from(p: Position) -> Self {
|
||||||
Self {
|
Self {
|
||||||
x: p.x,
|
x: p.x,
|
||||||
y: p.y,
|
y: p.y,
|
||||||
|
|||||||
54
src/main.rs
54
src/main.rs
@@ -1,4 +1,3 @@
|
|||||||
#![feature(if_let_guard, let_chains)]
|
|
||||||
#![warn(clippy::pedantic, clippy::nursery)]
|
#![warn(clippy::pedantic, clippy::nursery)]
|
||||||
#![allow(clippy::significant_drop_tightening)]
|
#![allow(clippy::significant_drop_tightening)]
|
||||||
|
|
||||||
@@ -10,11 +9,13 @@ mod hacks;
|
|||||||
mod http;
|
mod http;
|
||||||
mod lua;
|
mod lua;
|
||||||
mod particle;
|
mod particle;
|
||||||
mod replay;
|
|
||||||
|
|
||||||
#[cfg(feature = "matrix")]
|
#[cfg(feature = "matrix")]
|
||||||
mod matrix;
|
mod matrix;
|
||||||
|
|
||||||
|
#[cfg(feature = "replay")]
|
||||||
|
mod replay;
|
||||||
|
|
||||||
use std::{
|
use std::{
|
||||||
collections::HashMap,
|
collections::HashMap,
|
||||||
env,
|
env,
|
||||||
@@ -22,10 +23,10 @@ use std::{
|
|||||||
sync::Arc,
|
sync::Arc,
|
||||||
};
|
};
|
||||||
|
|
||||||
use anyhow::{Context, Result};
|
use anyhow::{Context, Result, bail};
|
||||||
use arguments::Arguments;
|
use arguments::Arguments;
|
||||||
use azalea::{
|
use azalea::{
|
||||||
DefaultBotPlugins, DefaultPlugins, brigadier::prelude::CommandDispatcher, prelude::*,
|
DefaultPlugins, bot::DefaultBotPlugins, brigadier::prelude::CommandDispatcher, prelude::*,
|
||||||
};
|
};
|
||||||
use bevy_app::PluginGroup;
|
use bevy_app::PluginGroup;
|
||||||
use bevy_log::{
|
use bevy_log::{
|
||||||
@@ -36,10 +37,15 @@ use clap::Parser;
|
|||||||
use commands::{CommandSource, register};
|
use commands::{CommandSource, register};
|
||||||
use futures::lock::Mutex;
|
use futures::lock::Mutex;
|
||||||
use futures_locks::RwLock;
|
use futures_locks::RwLock;
|
||||||
use hacks::HacksPlugin;
|
|
||||||
use log::debug;
|
use log::debug;
|
||||||
use mlua::{Function, Lua, Table};
|
use mlua::{Function, Lua};
|
||||||
use replay::{plugin::RecordPlugin, recorder::Recorder};
|
#[cfg(feature = "replay")]
|
||||||
|
use {
|
||||||
|
mlua::Table,
|
||||||
|
replay::{plugin::RecordPlugin, recorder::Recorder},
|
||||||
|
};
|
||||||
|
|
||||||
|
use crate::hacks::HacksPlugin;
|
||||||
|
|
||||||
#[cfg(feature = "mimalloc")]
|
#[cfg(feature = "mimalloc")]
|
||||||
#[global_allocator]
|
#[global_allocator]
|
||||||
@@ -95,21 +101,25 @@ async fn main() -> Result<()> {
|
|||||||
DefaultPlugins.set(LogPlugin {
|
DefaultPlugins.set(LogPlugin {
|
||||||
custom_layer: |_| {
|
custom_layer: |_| {
|
||||||
env::var("LOG_FILE").ok().map(|path| {
|
env::var("LOG_FILE").ok().map(|path| {
|
||||||
layer()
|
let file = OpenOptions::new()
|
||||||
.with_writer(
|
|
||||||
OpenOptions::new()
|
|
||||||
.append(true)
|
.append(true)
|
||||||
.create(true)
|
.create(true)
|
||||||
.open(&path)
|
.open(&path)
|
||||||
.expect(&(path + " should be accessible")),
|
.expect(&(path + " should be accessible"));
|
||||||
)
|
layer().with_writer(file).boxed()
|
||||||
.boxed()
|
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
..Default::default()
|
..Default::default()
|
||||||
})
|
})
|
||||||
};
|
};
|
||||||
let record_plugin = RecordPlugin {
|
|
||||||
|
let builder = ClientBuilder::new_without_plugins()
|
||||||
|
.add_plugins(default_plugins)
|
||||||
|
.add_plugins(DefaultBotPlugins)
|
||||||
|
.add_plugins(HacksPlugin);
|
||||||
|
|
||||||
|
#[cfg(feature = "replay")]
|
||||||
|
let builder = builder.add_plugins(RecordPlugin {
|
||||||
recorder: Arc::new(parking_lot::Mutex::new(
|
recorder: Arc::new(parking_lot::Mutex::new(
|
||||||
if let Ok(options) = globals.get::<Table>("ReplayRecordingOptions")
|
if let Ok(options) = globals.get::<Table>("ReplayRecordingOptions")
|
||||||
&& let Ok(path) = options.get::<String>("path")
|
&& let Ok(path) = options.get::<String>("path")
|
||||||
@@ -125,17 +135,15 @@ async fn main() -> Result<()> {
|
|||||||
None
|
None
|
||||||
},
|
},
|
||||||
)),
|
)),
|
||||||
};
|
});
|
||||||
|
|
||||||
let account = if username.contains('@') {
|
let account = if username.contains('@') {
|
||||||
Account::microsoft(&username).await?
|
Account::microsoft(&username).await?
|
||||||
} else {
|
} else {
|
||||||
Account::offline(&username)
|
Account::offline(&username)
|
||||||
};
|
};
|
||||||
let Err(err) = ClientBuilder::new_without_plugins()
|
|
||||||
.add_plugins(DefaultBotPlugins)
|
if let AppExit::Error(code) = builder
|
||||||
.add_plugins(HacksPlugin)
|
|
||||||
.add_plugins(default_plugins)
|
|
||||||
.add_plugins(record_plugin)
|
|
||||||
.set_handler(events::handle_event)
|
.set_handler(events::handle_event)
|
||||||
.set_state(State {
|
.set_state(State {
|
||||||
lua: Arc::new(lua),
|
lua: Arc::new(lua),
|
||||||
@@ -143,8 +151,10 @@ async fn main() -> Result<()> {
|
|||||||
commands: Arc::new(commands),
|
commands: Arc::new(commands),
|
||||||
})
|
})
|
||||||
.start(account, server)
|
.start(account, server)
|
||||||
.await;
|
.await
|
||||||
eprintln!("{err}");
|
{
|
||||||
|
bail!("azalea exited with code {code}")
|
||||||
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|||||||
143
src/particle.rs
143
src/particle.rs
@@ -1,121 +1,124 @@
|
|||||||
use azalea::{entity::particle::Particle, registry::ParticleKind};
|
use azalea::{entity::particle::Particle, registry::builtin::ParticleKind};
|
||||||
|
|
||||||
#[allow(clippy::too_many_lines)]
|
#[allow(clippy::too_many_lines)]
|
||||||
pub const fn to_kind(particle: &Particle) -> ParticleKind {
|
pub const fn to_kind(particle: &Particle) -> ParticleKind {
|
||||||
match particle {
|
match particle {
|
||||||
Particle::AngryVillager => ParticleKind::AngryVillager,
|
Particle::AngryVillager => ParticleKind::AngryVillager,
|
||||||
|
Particle::Ash => ParticleKind::Ash,
|
||||||
Particle::Block(_) => ParticleKind::Block,
|
Particle::Block(_) => ParticleKind::Block,
|
||||||
|
Particle::BlockCrumble => ParticleKind::BlockCrumble,
|
||||||
Particle::BlockMarker(_) => ParticleKind::BlockMarker,
|
Particle::BlockMarker(_) => ParticleKind::BlockMarker,
|
||||||
Particle::Bubble => ParticleKind::Bubble,
|
Particle::Bubble => ParticleKind::Bubble,
|
||||||
|
Particle::BubbleColumnUp => ParticleKind::BubbleColumnUp,
|
||||||
|
Particle::BubblePop => ParticleKind::BubblePop,
|
||||||
|
Particle::CampfireCosySmoke => ParticleKind::CampfireCosySmoke,
|
||||||
|
Particle::CampfireSignalSmoke => ParticleKind::CampfireSignalSmoke,
|
||||||
|
Particle::CherryLeaves => ParticleKind::CherryLeaves,
|
||||||
Particle::Cloud => ParticleKind::Cloud,
|
Particle::Cloud => ParticleKind::Cloud,
|
||||||
|
Particle::Composter => ParticleKind::Composter,
|
||||||
|
Particle::CopperFireFlame => ParticleKind::CopperFireFlame,
|
||||||
|
Particle::CrimsonSpore => ParticleKind::CrimsonSpore,
|
||||||
Particle::Crit => ParticleKind::Crit,
|
Particle::Crit => ParticleKind::Crit,
|
||||||
|
Particle::CurrentDown => ParticleKind::CurrentDown,
|
||||||
Particle::DamageIndicator => ParticleKind::DamageIndicator,
|
Particle::DamageIndicator => ParticleKind::DamageIndicator,
|
||||||
|
Particle::Dolphin => ParticleKind::Dolphin,
|
||||||
Particle::DragonBreath => ParticleKind::DragonBreath,
|
Particle::DragonBreath => ParticleKind::DragonBreath,
|
||||||
|
Particle::DrippingDripstoneLava => ParticleKind::DrippingDripstoneLava,
|
||||||
|
Particle::DrippingDripstoneWater => ParticleKind::DrippingDripstoneWater,
|
||||||
|
Particle::DrippingHoney => ParticleKind::DrippingHoney,
|
||||||
Particle::DrippingLava => ParticleKind::DrippingLava,
|
Particle::DrippingLava => ParticleKind::DrippingLava,
|
||||||
Particle::FallingLava => ParticleKind::FallingLava,
|
Particle::DrippingObsidianTear => ParticleKind::DrippingObsidianTear,
|
||||||
Particle::LandingLava => ParticleKind::LandingLava,
|
|
||||||
Particle::DrippingWater => ParticleKind::DrippingWater,
|
Particle::DrippingWater => ParticleKind::DrippingWater,
|
||||||
Particle::FallingWater => ParticleKind::FallingWater,
|
|
||||||
Particle::Dust(_) => ParticleKind::Dust,
|
Particle::Dust(_) => ParticleKind::Dust,
|
||||||
Particle::DustColorTransition(_) => ParticleKind::DustColorTransition,
|
Particle::DustColorTransition(_) => ParticleKind::DustColorTransition,
|
||||||
|
Particle::DustPillar => ParticleKind::DustPillar,
|
||||||
|
Particle::DustPlume => ParticleKind::DustPlume,
|
||||||
Particle::Effect => ParticleKind::Effect,
|
Particle::Effect => ParticleKind::Effect,
|
||||||
|
Particle::EggCrack => ParticleKind::EggCrack,
|
||||||
Particle::ElderGuardian => ParticleKind::ElderGuardian,
|
Particle::ElderGuardian => ParticleKind::ElderGuardian,
|
||||||
Particle::EnchantedHit => ParticleKind::EnchantedHit,
|
Particle::ElectricSpark => ParticleKind::ElectricSpark,
|
||||||
Particle::Enchant => ParticleKind::Enchant,
|
Particle::Enchant => ParticleKind::Enchant,
|
||||||
|
Particle::EnchantedHit => ParticleKind::EnchantedHit,
|
||||||
Particle::EndRod => ParticleKind::EndRod,
|
Particle::EndRod => ParticleKind::EndRod,
|
||||||
Particle::EntityEffect(_) => ParticleKind::EntityEffect,
|
Particle::EntityEffect(_) => ParticleKind::EntityEffect,
|
||||||
Particle::ExplosionEmitter => ParticleKind::ExplosionEmitter,
|
|
||||||
Particle::Explosion => ParticleKind::Explosion,
|
Particle::Explosion => ParticleKind::Explosion,
|
||||||
Particle::Gust => ParticleKind::Gust,
|
Particle::ExplosionEmitter => ParticleKind::ExplosionEmitter,
|
||||||
Particle::SonicBoom => ParticleKind::SonicBoom,
|
Particle::FallingDripstoneLava => ParticleKind::FallingDripstoneLava,
|
||||||
|
Particle::FallingDripstoneWater => ParticleKind::FallingDripstoneWater,
|
||||||
Particle::FallingDust(_) => ParticleKind::FallingDust,
|
Particle::FallingDust(_) => ParticleKind::FallingDust,
|
||||||
|
Particle::FallingHoney => ParticleKind::FallingHoney,
|
||||||
|
Particle::FallingLava => ParticleKind::FallingLava,
|
||||||
|
Particle::FallingNectar => ParticleKind::FallingNectar,
|
||||||
|
Particle::FallingObsidianTear => ParticleKind::FallingObsidianTear,
|
||||||
|
Particle::FallingSporeBlossom => ParticleKind::FallingSporeBlossom,
|
||||||
|
Particle::FallingWater => ParticleKind::FallingWater,
|
||||||
|
Particle::Firefly => ParticleKind::Firefly,
|
||||||
Particle::Firework => ParticleKind::Firework,
|
Particle::Firework => ParticleKind::Firework,
|
||||||
Particle::Fishing => ParticleKind::Fishing,
|
Particle::Fishing => ParticleKind::Fishing,
|
||||||
Particle::Flame => ParticleKind::Flame,
|
Particle::Flame => ParticleKind::Flame,
|
||||||
Particle::CherryLeaves => ParticleKind::CherryLeaves,
|
|
||||||
Particle::PaleOakLeaves => ParticleKind::PaleOakLeaves,
|
|
||||||
Particle::TintedLeaves => ParticleKind::TintedLeaves,
|
|
||||||
Particle::SculkSoul => ParticleKind::SculkSoul,
|
|
||||||
Particle::SculkCharge(_) => ParticleKind::SculkCharge,
|
|
||||||
Particle::SculkChargePop => ParticleKind::SculkChargePop,
|
|
||||||
Particle::SoulFireFlame => ParticleKind::SoulFireFlame,
|
|
||||||
Particle::Soul => ParticleKind::Soul,
|
|
||||||
Particle::Flash => ParticleKind::Flash,
|
Particle::Flash => ParticleKind::Flash,
|
||||||
|
Particle::Glow => ParticleKind::Glow,
|
||||||
|
Particle::GlowSquidInk => ParticleKind::GlowSquidInk,
|
||||||
|
Particle::Gust => ParticleKind::Gust,
|
||||||
|
Particle::GustEmitterLarge => ParticleKind::GustEmitterLarge,
|
||||||
|
Particle::GustEmitterSmall => ParticleKind::GustEmitterSmall,
|
||||||
Particle::HappyVillager => ParticleKind::HappyVillager,
|
Particle::HappyVillager => ParticleKind::HappyVillager,
|
||||||
Particle::Composter => ParticleKind::Composter,
|
|
||||||
Particle::Heart => ParticleKind::Heart,
|
Particle::Heart => ParticleKind::Heart,
|
||||||
|
Particle::Infested => ParticleKind::Infested,
|
||||||
Particle::InstantEffect => ParticleKind::InstantEffect,
|
Particle::InstantEffect => ParticleKind::InstantEffect,
|
||||||
Particle::Item(_) => ParticleKind::Item,
|
Particle::Item(_) => ParticleKind::Item,
|
||||||
Particle::Vibration(_) => ParticleKind::Vibration,
|
Particle::ItemCobweb => ParticleKind::ItemCobweb,
|
||||||
Particle::ItemSlime => ParticleKind::ItemSlime,
|
Particle::ItemSlime => ParticleKind::ItemSlime,
|
||||||
Particle::ItemSnowball => ParticleKind::ItemSnowball,
|
Particle::ItemSnowball => ParticleKind::ItemSnowball,
|
||||||
|
Particle::LandingHoney => ParticleKind::LandingHoney,
|
||||||
|
Particle::LandingLava => ParticleKind::LandingLava,
|
||||||
|
Particle::LandingObsidianTear => ParticleKind::LandingObsidianTear,
|
||||||
Particle::LargeSmoke => ParticleKind::LargeSmoke,
|
Particle::LargeSmoke => ParticleKind::LargeSmoke,
|
||||||
Particle::Lava => ParticleKind::Lava,
|
Particle::Lava => ParticleKind::Lava,
|
||||||
Particle::Mycelium => ParticleKind::Mycelium,
|
Particle::Mycelium => ParticleKind::Mycelium,
|
||||||
|
Particle::Nautilus => ParticleKind::Nautilus,
|
||||||
Particle::Note => ParticleKind::Note,
|
Particle::Note => ParticleKind::Note,
|
||||||
|
Particle::OminousSpawning => ParticleKind::OminousSpawning,
|
||||||
|
Particle::PaleOakLeaves => ParticleKind::PaleOakLeaves,
|
||||||
|
Particle::PauseMobGrowth => ParticleKind::PauseMobGrowth,
|
||||||
Particle::Poof => ParticleKind::Poof,
|
Particle::Poof => ParticleKind::Poof,
|
||||||
Particle::Portal => ParticleKind::Portal,
|
Particle::Portal => ParticleKind::Portal,
|
||||||
|
Particle::RaidOmen => ParticleKind::RaidOmen,
|
||||||
Particle::Rain => ParticleKind::Rain,
|
Particle::Rain => ParticleKind::Rain,
|
||||||
|
Particle::ResetMobGrowth => ParticleKind::ResetMobGrowth,
|
||||||
|
Particle::ReversePortal => ParticleKind::ReversePortal,
|
||||||
|
Particle::Scrape => ParticleKind::Scrape,
|
||||||
|
Particle::SculkCharge(_) => ParticleKind::SculkCharge,
|
||||||
|
Particle::SculkChargePop => ParticleKind::SculkChargePop,
|
||||||
|
Particle::SculkSoul => ParticleKind::SculkSoul,
|
||||||
|
Particle::Shriek(_) => ParticleKind::Shriek,
|
||||||
|
Particle::SmallFlame => ParticleKind::SmallFlame,
|
||||||
|
Particle::SmallGust => ParticleKind::SmallGust,
|
||||||
Particle::Smoke => ParticleKind::Smoke,
|
Particle::Smoke => ParticleKind::Smoke,
|
||||||
Particle::WhiteSmoke => ParticleKind::WhiteSmoke,
|
|
||||||
Particle::Sneeze => ParticleKind::Sneeze,
|
Particle::Sneeze => ParticleKind::Sneeze,
|
||||||
|
Particle::Snowflake => ParticleKind::Snowflake,
|
||||||
|
Particle::SonicBoom => ParticleKind::SonicBoom,
|
||||||
|
Particle::Soul => ParticleKind::Soul,
|
||||||
|
Particle::SoulFireFlame => ParticleKind::SoulFireFlame,
|
||||||
Particle::Spit => ParticleKind::Spit,
|
Particle::Spit => ParticleKind::Spit,
|
||||||
|
Particle::Splash => ParticleKind::Splash,
|
||||||
|
Particle::SporeBlossomAir => ParticleKind::SporeBlossomAir,
|
||||||
Particle::SquidInk => ParticleKind::SquidInk,
|
Particle::SquidInk => ParticleKind::SquidInk,
|
||||||
Particle::SweepAttack => ParticleKind::SweepAttack,
|
Particle::SweepAttack => ParticleKind::SweepAttack,
|
||||||
|
Particle::TintedLeaves => ParticleKind::TintedLeaves,
|
||||||
Particle::TotemOfUndying => ParticleKind::TotemOfUndying,
|
Particle::TotemOfUndying => ParticleKind::TotemOfUndying,
|
||||||
Particle::Underwater => ParticleKind::Underwater,
|
Particle::Trail => ParticleKind::Trail,
|
||||||
Particle::Splash => ParticleKind::Splash,
|
Particle::TrialOmen => ParticleKind::TrialOmen,
|
||||||
Particle::Witch => ParticleKind::Witch,
|
|
||||||
Particle::BubblePop => ParticleKind::BubblePop,
|
|
||||||
Particle::CurrentDown => ParticleKind::CurrentDown,
|
|
||||||
Particle::BubbleColumnUp => ParticleKind::BubbleColumnUp,
|
|
||||||
Particle::Nautilus => ParticleKind::Nautilus,
|
|
||||||
Particle::Dolphin => ParticleKind::Dolphin,
|
|
||||||
Particle::CampfireCosySmoke => ParticleKind::CampfireCosySmoke,
|
|
||||||
Particle::CampfireSignalSmoke => ParticleKind::CampfireSignalSmoke,
|
|
||||||
Particle::DrippingHoney => ParticleKind::DrippingHoney,
|
|
||||||
Particle::FallingHoney => ParticleKind::FallingHoney,
|
|
||||||
Particle::LandingHoney => ParticleKind::LandingHoney,
|
|
||||||
Particle::FallingNectar => ParticleKind::FallingNectar,
|
|
||||||
Particle::FallingSporeBlossom => ParticleKind::FallingSporeBlossom,
|
|
||||||
Particle::Ash => ParticleKind::Ash,
|
|
||||||
Particle::CrimsonSpore => ParticleKind::CrimsonSpore,
|
|
||||||
Particle::WarpedSpore => ParticleKind::WarpedSpore,
|
|
||||||
Particle::SporeBlossomAir => ParticleKind::SporeBlossomAir,
|
|
||||||
Particle::DrippingObsidianTear => ParticleKind::DrippingObsidianTear,
|
|
||||||
Particle::FallingObsidianTear => ParticleKind::FallingObsidianTear,
|
|
||||||
Particle::LandingObsidianTear => ParticleKind::LandingObsidianTear,
|
|
||||||
Particle::ReversePortal => ParticleKind::ReversePortal,
|
|
||||||
Particle::WhiteAsh => ParticleKind::WhiteAsh,
|
|
||||||
Particle::SmallFlame => ParticleKind::SmallFlame,
|
|
||||||
Particle::Snowflake => ParticleKind::Snowflake,
|
|
||||||
Particle::DrippingDripstoneLava => ParticleKind::DrippingDripstoneLava,
|
|
||||||
Particle::FallingDripstoneLava => ParticleKind::FallingDripstoneLava,
|
|
||||||
Particle::DrippingDripstoneWater => ParticleKind::DrippingDripstoneWater,
|
|
||||||
Particle::FallingDripstoneWater => ParticleKind::FallingDripstoneWater,
|
|
||||||
Particle::GlowSquidInk => ParticleKind::GlowSquidInk,
|
|
||||||
Particle::Glow => ParticleKind::Glow,
|
|
||||||
Particle::WaxOn => ParticleKind::WaxOn,
|
|
||||||
Particle::WaxOff => ParticleKind::WaxOff,
|
|
||||||
Particle::ElectricSpark => ParticleKind::ElectricSpark,
|
|
||||||
Particle::Scrape => ParticleKind::Scrape,
|
|
||||||
Particle::Shriek(_) => ParticleKind::Shriek,
|
|
||||||
Particle::EggCrack => ParticleKind::EggCrack,
|
|
||||||
Particle::DustPlume => ParticleKind::DustPlume,
|
|
||||||
Particle::SmallGust => ParticleKind::SmallGust,
|
|
||||||
Particle::GustEmitterLarge => ParticleKind::GustEmitterLarge,
|
|
||||||
Particle::GustEmitterSmall => ParticleKind::GustEmitterSmall,
|
|
||||||
Particle::Infested => ParticleKind::Infested,
|
|
||||||
Particle::ItemCobweb => ParticleKind::ItemCobweb,
|
|
||||||
Particle::TrialSpawnerDetection => ParticleKind::TrialSpawnerDetection,
|
Particle::TrialSpawnerDetection => ParticleKind::TrialSpawnerDetection,
|
||||||
Particle::TrialSpawnerDetectionOminous => ParticleKind::TrialSpawnerDetectionOminous,
|
Particle::TrialSpawnerDetectionOminous => ParticleKind::TrialSpawnerDetectionOminous,
|
||||||
|
Particle::Underwater => ParticleKind::Underwater,
|
||||||
Particle::VaultConnection => ParticleKind::VaultConnection,
|
Particle::VaultConnection => ParticleKind::VaultConnection,
|
||||||
Particle::DustPillar => ParticleKind::DustPillar,
|
Particle::Vibration(_) => ParticleKind::Vibration,
|
||||||
Particle::OminousSpawning => ParticleKind::OminousSpawning,
|
Particle::WarpedSpore => ParticleKind::WarpedSpore,
|
||||||
Particle::RaidOmen => ParticleKind::RaidOmen,
|
Particle::WaxOff => ParticleKind::WaxOff,
|
||||||
Particle::TrialOmen => ParticleKind::TrialOmen,
|
Particle::WaxOn => ParticleKind::WaxOn,
|
||||||
Particle::Trail => ParticleKind::Trail,
|
Particle::WhiteAsh => ParticleKind::WhiteAsh,
|
||||||
Particle::BlockCrumble => ParticleKind::BlockCrumble,
|
Particle::WhiteSmoke => ParticleKind::WhiteSmoke,
|
||||||
Particle::Firefly => ParticleKind::Firefly,
|
Particle::Witch => ParticleKind::Witch,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,6 @@
|
|||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
use azalea::{
|
use azalea::{
|
||||||
ecs::event::EventReader,
|
|
||||||
packet::{
|
packet::{
|
||||||
config::ReceiveConfigPacketEvent, game::ReceiveGamePacketEvent,
|
config::ReceiveConfigPacketEvent, game::ReceiveGamePacketEvent,
|
||||||
login::ReceiveLoginPacketEvent,
|
login::ReceiveLoginPacketEvent,
|
||||||
@@ -11,7 +10,7 @@ use azalea::{
|
|||||||
protocol::packets::login::ClientboundLoginPacket,
|
protocol::packets::login::ClientboundLoginPacket,
|
||||||
};
|
};
|
||||||
use bevy_app::{App, First, Plugin};
|
use bevy_app::{App, First, Plugin};
|
||||||
use bevy_ecs::system::ResMut;
|
use bevy_ecs::{message::MessageReader, system::ResMut};
|
||||||
use log::error;
|
use log::error;
|
||||||
use parking_lot::Mutex;
|
use parking_lot::Mutex;
|
||||||
|
|
||||||
@@ -35,7 +34,7 @@ impl Plugin for RecordPlugin {
|
|||||||
|
|
||||||
fn record_login_packets(
|
fn record_login_packets(
|
||||||
recorder: Option<ResMut<Recorder>>,
|
recorder: Option<ResMut<Recorder>>,
|
||||||
mut events: EventReader<ReceiveLoginPacketEvent>,
|
mut events: MessageReader<ReceiveLoginPacketEvent>,
|
||||||
) {
|
) {
|
||||||
if let Some(mut recorder) = recorder {
|
if let Some(mut recorder) = recorder {
|
||||||
for event in events.read() {
|
for event in events.read() {
|
||||||
@@ -54,7 +53,7 @@ fn record_login_packets(
|
|||||||
|
|
||||||
fn record_configuration_packets(
|
fn record_configuration_packets(
|
||||||
recorder: Option<ResMut<Recorder>>,
|
recorder: Option<ResMut<Recorder>>,
|
||||||
mut events: EventReader<ReceiveConfigPacketEvent>,
|
mut events: MessageReader<ReceiveConfigPacketEvent>,
|
||||||
) {
|
) {
|
||||||
if let Some(mut recorder) = recorder {
|
if let Some(mut recorder) = recorder {
|
||||||
for event in events.read() {
|
for event in events.read() {
|
||||||
@@ -67,7 +66,7 @@ fn record_configuration_packets(
|
|||||||
|
|
||||||
fn record_game_packets(
|
fn record_game_packets(
|
||||||
recorder: Option<ResMut<Recorder>>,
|
recorder: Option<ResMut<Recorder>>,
|
||||||
mut events: EventReader<ReceiveGamePacketEvent>,
|
mut events: MessageReader<ReceiveGamePacketEvent>,
|
||||||
) {
|
) {
|
||||||
if let Some(mut recorder) = recorder {
|
if let Some(mut recorder) = recorder {
|
||||||
for event in events.read() {
|
for event in events.read() {
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ use std::{
|
|||||||
|
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use azalea::{
|
use azalea::{
|
||||||
buf::AzaleaWriteVar,
|
buf::AzBufVar,
|
||||||
prelude::Resource,
|
prelude::Resource,
|
||||||
protocol::packets::{PROTOCOL_VERSION, ProtocolPacket, VERSION_NAME},
|
protocol::packets::{PROTOCOL_VERSION, ProtocolPacket, VERSION_NAME},
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user