mirror of
https://github.com/mat-1/azalea.git
synced 2024-09-19 14:42:32 +00:00
fix for hypixel limbo
This commit is contained in:
parent
69f7eebcb3
commit
038807e607
23 changed files with 89 additions and 66 deletions
|
@ -8,7 +8,7 @@ use quote::quote;
|
|||
use std::collections::HashMap;
|
||||
use std::fmt::Write;
|
||||
use syn::{
|
||||
self, braced,
|
||||
braced,
|
||||
ext::IdentExt,
|
||||
parenthesized,
|
||||
parse::{Parse, ParseStream, Result},
|
||||
|
|
|
@ -3,7 +3,7 @@ mod write;
|
|||
|
||||
use proc_macro::TokenStream;
|
||||
use quote::quote;
|
||||
use syn::{self, parse_macro_input, DeriveInput};
|
||||
use syn::{parse_macro_input, DeriveInput};
|
||||
|
||||
#[proc_macro_derive(McBufReadable, attributes(var))]
|
||||
pub fn derive_mcbufreadable(input: TokenStream) -> TokenStream {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use quote::{quote, ToTokens};
|
||||
use syn::{self, punctuated::Punctuated, token::Comma, Data, Field, FieldsNamed, Ident};
|
||||
use syn::{punctuated::Punctuated, token::Comma, Data, Field, FieldsNamed, Ident};
|
||||
|
||||
fn read_named_fields(
|
||||
named: &Punctuated<Field, Comma>,
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use proc_macro2::Span;
|
||||
use quote::{quote, ToTokens};
|
||||
use syn::{self, punctuated::Punctuated, token::Comma, Data, Field, FieldsNamed, Ident};
|
||||
use syn::{punctuated::Punctuated, token::Comma, Data, Field, FieldsNamed, Ident};
|
||||
|
||||
fn write_named_fields(
|
||||
named: &Punctuated<Field, Comma>,
|
||||
|
|
|
@ -29,7 +29,6 @@ fn handle_in_configuration_state(
|
|||
mut send_packet_events: EventWriter<SendConfigurationPacketEvent>,
|
||||
) {
|
||||
for (entity, client_information) in query.iter() {
|
||||
// quickly send the brand here
|
||||
let mut brand_data = Vec::new();
|
||||
// they don't have to know :)
|
||||
"vanilla".write_into(&mut brand_data).unwrap();
|
||||
|
|
|
@ -5,7 +5,7 @@ use azalea_core::game_type::GameMode;
|
|||
use azalea_entity::Dead;
|
||||
use azalea_protocol::packets::game::clientbound_player_abilities_packet::ClientboundPlayerAbilitiesPacket;
|
||||
use azalea_world::{Instance, PartialInstance};
|
||||
use bevy_ecs::{component::Component, entity::Entity, prelude::*, query::Added, system::Query};
|
||||
use bevy_ecs::{component::Component, prelude::*};
|
||||
use derive_more::{Deref, DerefMut};
|
||||
use parking_lot::RwLock;
|
||||
use thiserror::Error;
|
||||
|
|
|
@ -8,7 +8,7 @@ use parse_macro::{DeclareMenus, Field};
|
|||
use proc_macro::TokenStream;
|
||||
use proc_macro2::Span;
|
||||
use quote::quote;
|
||||
use syn::{self, parse_macro_input, Ident};
|
||||
use syn::{parse_macro_input, Ident};
|
||||
|
||||
#[proc_macro]
|
||||
pub fn declare_menus(input: TokenStream) -> TokenStream {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use syn::{
|
||||
self, braced,
|
||||
braced,
|
||||
parse::{Parse, ParseStream, Result},
|
||||
Ident, LitInt, Token,
|
||||
};
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use std::{cmp::Ordering, convert::TryInto};
|
||||
use std::cmp::Ordering;
|
||||
|
||||
use super::CubePointRange;
|
||||
use azalea_core::math::{gcd, lcm, EPSILON};
|
||||
|
|
|
@ -424,10 +424,9 @@ fn jump_boost_power() -> f64 {
|
|||
mod tests {
|
||||
|
||||
use super::*;
|
||||
use azalea_core::{position::ChunkPos, resource_location::ResourceLocation, tick::GameTick};
|
||||
use azalea_core::{position::ChunkPos, resource_location::ResourceLocation};
|
||||
use azalea_entity::{EntityBundle, EntityPlugin};
|
||||
use azalea_world::{Chunk, MinecraftEntityId, PartialInstance};
|
||||
use bevy_app::App;
|
||||
use uuid::Uuid;
|
||||
|
||||
/// You need an app to spawn entities in the world and do updates.
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use proc_macro::TokenStream;
|
||||
use quote::quote;
|
||||
use syn::{
|
||||
self, braced,
|
||||
braced,
|
||||
parse::{Parse, ParseStream, Result},
|
||||
parse_macro_input, DeriveInput, Ident, LitInt, Token,
|
||||
};
|
||||
|
|
|
@ -40,7 +40,7 @@ static PROXY_FAVICON: Lazy<Option<String>> = Lazy::new(|| None);
|
|||
|
||||
static PROXY_VERSION: Lazy<Version> = Lazy::new(|| Version {
|
||||
name: "1.19.3".to_string(),
|
||||
protocol: PROTOCOL_VERSION as i32,
|
||||
protocol: PROTOCOL_VERSION,
|
||||
});
|
||||
|
||||
const PROXY_PLAYERS: Players = Players {
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -119,8 +119,6 @@ pub struct AdvancementHolder {
|
|||
mod tests {
|
||||
use super::*;
|
||||
use azalea_buf::{McBufReadable, McBufWritable};
|
||||
use azalea_core::resource_location::ResourceLocation;
|
||||
use std::io::Cursor;
|
||||
|
||||
#[test]
|
||||
fn test() {
|
||||
|
|
|
@ -17,6 +17,7 @@ use std::{
|
|||
use thiserror::Error;
|
||||
use tokio::io::AsyncRead;
|
||||
use tokio_util::codec::{BytesCodec, FramedRead};
|
||||
use tracing::trace;
|
||||
|
||||
#[derive(Error, Debug)]
|
||||
pub enum ReadPacketError {
|
||||
|
@ -348,15 +349,17 @@ where
|
|||
}
|
||||
|
||||
if log::log_enabled!(log::Level::Trace) {
|
||||
const EXTRA_LARGE_LOGS: bool = false;
|
||||
|
||||
let buf_string: String = {
|
||||
if buf.len() > 500 {
|
||||
if !EXTRA_LARGE_LOGS && buf.len() > 500 {
|
||||
let cut_off_buf = &buf[..500];
|
||||
format!("{cut_off_buf:?}...")
|
||||
} else {
|
||||
format!("{buf:?}")
|
||||
}
|
||||
};
|
||||
tracing::trace!("Reading packet with bytes: {buf_string}");
|
||||
trace!("Reading packet with bytes: {buf_string}");
|
||||
};
|
||||
|
||||
Ok(Some(buf))
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use proc_macro::TokenStream;
|
||||
use quote::quote;
|
||||
use syn::{
|
||||
self, braced,
|
||||
braced,
|
||||
parse::{Parse, ParseStream, Result},
|
||||
parse_macro_input,
|
||||
punctuated::Punctuated,
|
||||
|
|
|
@ -114,8 +114,7 @@ impl BitStorage {
|
|||
}
|
||||
}
|
||||
|
||||
// vanilla has this assert but it's not always true for some reason??
|
||||
// assert!(bits >= 1 && bits <= 32);
|
||||
debug_assert!((1..=32).contains(&bits));
|
||||
|
||||
let values_per_long = 64 / bits;
|
||||
let magic_index = values_per_long - 1;
|
||||
|
|
|
@ -450,9 +450,8 @@ impl McBufReadable for Section {
|
|||
for i in 0..states.storage.size() {
|
||||
if !BlockState::is_valid_state(states.storage.get(i) as u32) {
|
||||
return Err(BufReadError::Custom(format!(
|
||||
"Invalid block state {} (index {}) found in section.",
|
||||
states.storage.get(i),
|
||||
i
|
||||
"Invalid block state {} (index {i}) found in section.",
|
||||
states.storage.get(i)
|
||||
)));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
use azalea_buf::{BufReadError, McBufReadable, McBufVarReadable, McBufVarWritable, McBufWritable};
|
||||
use azalea_core::math;
|
||||
use std::io::{Cursor, Write};
|
||||
use tracing::warn;
|
||||
|
||||
use crate::BitStorage;
|
||||
|
||||
|
@ -41,17 +43,39 @@ impl PalettedContainer {
|
|||
buf: &mut Cursor<&[u8]>,
|
||||
container_type: &'static PalettedContainerKind,
|
||||
) -> Result<Self, BufReadError> {
|
||||
let bits_per_entry = u8::read_from(buf)?;
|
||||
let palette_type = PaletteKind::from_bits_and_type(bits_per_entry, container_type);
|
||||
let server_bits_per_entry = u8::read_from(buf)?;
|
||||
let palette_type = PaletteKind::from_bits_and_type(server_bits_per_entry, container_type);
|
||||
let palette = palette_type.read(buf)?;
|
||||
let size = container_type.size();
|
||||
|
||||
let data = Vec::<u64>::read_from(buf)?;
|
||||
|
||||
// if there's too much data that the bits per entry would be global, we have to
|
||||
// figure out the bits per entry ourselves by checking the number of bits in the
|
||||
// length of the data.
|
||||
// this almost never matters, except on some custom servers like hypixel limbo
|
||||
let calculated_bits_per_entry = math::ceil_log2(data.len() as u32) as u8;
|
||||
let calculated_bits_per_entry_palette_kind =
|
||||
PaletteKind::from_bits_and_type(calculated_bits_per_entry, container_type);
|
||||
let bits_per_entry = if calculated_bits_per_entry_palette_kind == PaletteKind::Global {
|
||||
server_bits_per_entry
|
||||
} else {
|
||||
calculated_bits_per_entry
|
||||
};
|
||||
|
||||
debug_assert!(
|
||||
bits_per_entry != 0 || data.is_empty(),
|
||||
"Bits per entry is 0 but data is not empty."
|
||||
);
|
||||
let storage = BitStorage::new(bits_per_entry.into(), size, Some(data)).unwrap();
|
||||
|
||||
let storage = match BitStorage::new(bits_per_entry.into(), size, Some(data)) {
|
||||
Ok(storage) => storage,
|
||||
Err(e) => {
|
||||
warn!("Failed to create bit storage: {:?}", e);
|
||||
return Err(BufReadError::Custom(
|
||||
"Failed to create bit storage".to_string(),
|
||||
));
|
||||
}
|
||||
};
|
||||
|
||||
Ok(PalettedContainer {
|
||||
bits_per_entry,
|
||||
|
|
|
@ -16,6 +16,7 @@ use criterion::{criterion_group, criterion_main, Bencher, Criterion};
|
|||
use parking_lot::RwLock;
|
||||
use rand::{rngs::StdRng, Rng, SeedableRng};
|
||||
|
||||
#[allow(dead_code)]
|
||||
fn generate_bedrock_world(
|
||||
partial_chunks: &mut PartialChunkStorage,
|
||||
size: u32,
|
||||
|
@ -87,7 +88,7 @@ fn generate_mining_world(
|
|||
}
|
||||
}
|
||||
|
||||
let mut rng = StdRng::seed_from_u64(0);
|
||||
// let mut rng = StdRng::seed_from_u64(0);
|
||||
|
||||
for chunk_x in -size..size {
|
||||
for chunk_z in -size..size {
|
||||
|
|
|
@ -4,7 +4,6 @@ pub mod movement;
|
|||
|
||||
use azalea::brigadier::prelude::*;
|
||||
use azalea::chat::ChatPacket;
|
||||
use azalea::ecs::prelude::Entity;
|
||||
use azalea::ecs::prelude::*;
|
||||
use azalea::entity::metadata::Player;
|
||||
use azalea::Client;
|
||||
|
|
|
@ -15,7 +15,7 @@ mod commands;
|
|||
pub mod killaura;
|
||||
|
||||
use azalea::pathfinder::PathfinderDebugParticles;
|
||||
use azalea::{Account, ClientInformation};
|
||||
use azalea::ClientInformation;
|
||||
|
||||
use azalea::brigadier::command_dispatcher::CommandDispatcher;
|
||||
use azalea::ecs::prelude::*;
|
||||
|
@ -136,7 +136,7 @@ async fn handle(bot: Client, event: azalea::Event, state: State) -> anyhow::Resu
|
|||
let command = if chat.is_whisper() {
|
||||
Some(content)
|
||||
} else {
|
||||
content.strip_prefix("!").map(|s| s.to_owned())
|
||||
content.strip_prefix('!').map(|s| s.to_owned())
|
||||
};
|
||||
if let Some(command) = command {
|
||||
match state.commands.execute(
|
||||
|
@ -163,7 +163,7 @@ async fn handle(bot: Client, event: azalea::Event, state: State) -> anyhow::Resu
|
|||
azalea::Event::Tick => {
|
||||
killaura::tick(bot.clone(), state.clone())?;
|
||||
|
||||
let task = state.task.lock().clone();
|
||||
let task = *state.task.lock();
|
||||
match task {
|
||||
BotTask::None => {}
|
||||
}
|
||||
|
|
|
@ -489,13 +489,9 @@ pub fn is_block_state_solid(block: BlockState) -> bool {
|
|||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use std::sync::Arc;
|
||||
|
||||
use super::*;
|
||||
use azalea_block::BlockState;
|
||||
use azalea_core::position::ChunkPos;
|
||||
use azalea_world::{Chunk, ChunkStorage, PartialInstance};
|
||||
use parking_lot::RwLock;
|
||||
|
||||
#[test]
|
||||
fn test_is_passable() {
|
||||
|
|
Loading…
Reference in a new issue