refactor: bring azalea-hax crate in-tree
This commit is contained in:
20
src/hacks/anti_knockback.rs
Normal file
20
src/hacks/anti_knockback.rs
Normal file
@@ -0,0 +1,20 @@
|
||||
use azalea::{
|
||||
Vec3,
|
||||
movement::{KnockbackEvent, KnockbackType},
|
||||
prelude::Component,
|
||||
};
|
||||
use bevy_ecs::{event::EventMutator, query::With, system::Query};
|
||||
|
||||
#[derive(Component)]
|
||||
pub struct AntiKnockback;
|
||||
|
||||
pub fn anti_knockback(
|
||||
mut events: EventMutator<KnockbackEvent>,
|
||||
entity_query: Query<(), With<AntiKnockback>>,
|
||||
) {
|
||||
for event in events.read() {
|
||||
if entity_query.get(event.entity).is_ok() {
|
||||
event.knockback = KnockbackType::Add(Vec3::default());
|
||||
}
|
||||
}
|
||||
}
|
21
src/hacks/mod.rs
Normal file
21
src/hacks/mod.rs
Normal file
@@ -0,0 +1,21 @@
|
||||
#![allow(clippy::needless_pass_by_value)]
|
||||
|
||||
pub mod anti_knockback;
|
||||
|
||||
use anti_knockback::anti_knockback;
|
||||
use azalea::{movement::handle_knockback, packet_handling::game::process_packet_events};
|
||||
use bevy_app::{App, Plugin, PreUpdate};
|
||||
use bevy_ecs::schedule::IntoSystemConfigs;
|
||||
|
||||
pub struct HacksPlugin;
|
||||
|
||||
impl Plugin for HacksPlugin {
|
||||
fn build(&self, app: &mut App) {
|
||||
app.add_systems(
|
||||
PreUpdate,
|
||||
anti_knockback
|
||||
.after(process_packet_events)
|
||||
.before(handle_knockback),
|
||||
);
|
||||
}
|
||||
}
|
@@ -1,3 +1,5 @@
|
||||
use crate::hacks::anti_knockback::AntiKnockback;
|
||||
|
||||
use super::Client;
|
||||
use azalea::{
|
||||
ClientInformation,
|
||||
@@ -5,7 +7,6 @@ use azalea::{
|
||||
pathfinder::PathfinderDebugParticles,
|
||||
protocol::common::client_information::ModelCustomization,
|
||||
};
|
||||
use azalea_hax::AntiKnockback;
|
||||
use mlua::{Error, Lua, Result, Table, UserDataRef};
|
||||
|
||||
pub fn air_supply(_lua: &Lua, client: &Client) -> Result<i32> {
|
||||
|
@@ -4,6 +4,7 @@ mod arguments;
|
||||
mod build_info;
|
||||
mod commands;
|
||||
mod events;
|
||||
mod hacks;
|
||||
mod http;
|
||||
mod lua;
|
||||
mod particle;
|
||||
@@ -17,7 +18,6 @@ use arguments::Arguments;
|
||||
use azalea::{
|
||||
DefaultBotPlugins, DefaultPlugins, brigadier::prelude::CommandDispatcher, prelude::*,
|
||||
};
|
||||
use azalea_hax::HaxPlugin;
|
||||
use bevy_app::PluginGroup;
|
||||
use bevy_log::{
|
||||
LogPlugin,
|
||||
@@ -27,6 +27,7 @@ use clap::Parser;
|
||||
use commands::{CommandSource, register};
|
||||
use futures::lock::Mutex;
|
||||
use futures_locks::RwLock;
|
||||
use hacks::HacksPlugin;
|
||||
use log::debug;
|
||||
use mlua::{Function, Lua, Table};
|
||||
use replay::{plugin::RecordPlugin, recorder::Recorder};
|
||||
@@ -130,7 +131,7 @@ async fn main() -> anyhow::Result<()> {
|
||||
|
||||
let Err(error) = ClientBuilder::new_without_plugins()
|
||||
.add_plugins(DefaultBotPlugins)
|
||||
.add_plugins(HaxPlugin)
|
||||
.add_plugins(HacksPlugin)
|
||||
.add_plugins(default_plugins)
|
||||
.add_plugins(record_plugin)
|
||||
.set_handler(events::handle_event)
|
||||
|
Reference in New Issue
Block a user