mirror of
https://github.com/mat-1/azalea.git
synced 2025-08-02 14:26:04 +00:00
fix ping packet, explosion packet, and panic less
This commit is contained in:
parent
0aa439d5ca
commit
cfbfdd77b4
5 changed files with 27 additions and 13 deletions
|
@ -74,9 +74,9 @@ fn travel(
|
||||||
jumping,
|
jumping,
|
||||||
) in &mut query
|
) in &mut query
|
||||||
{
|
{
|
||||||
let world_lock = instance_container
|
let Some(world_lock) = instance_container.get(world_name) else {
|
||||||
.get(world_name)
|
continue;
|
||||||
.expect("All entities should be in a valid world");
|
};
|
||||||
let world = world_lock.read();
|
let world = world_lock.read();
|
||||||
// if !self.is_effective_ai() && !self.is_controlled_by_local_instance() {
|
// if !self.is_effective_ai() && !self.is_controlled_by_local_instance() {
|
||||||
// // this.calculateEntityAnimation(this, this instanceof FlyingAnimal);
|
// // this.calculateEntityAnimation(this, this instanceof FlyingAnimal);
|
||||||
|
|
|
@ -1,9 +1,12 @@
|
||||||
use std::io::{Cursor, Write};
|
use std::{
|
||||||
|
io::{Cursor, Write},
|
||||||
|
str::FromStr,
|
||||||
|
};
|
||||||
|
|
||||||
use azalea_buf::{
|
use azalea_buf::{
|
||||||
BufReadError, McBuf, McBufReadable, McBufVarReadable, McBufVarWritable, McBufWritable,
|
BufReadError, McBuf, McBufReadable, McBufVarReadable, McBufVarWritable, McBufWritable,
|
||||||
};
|
};
|
||||||
use azalea_core::position::BlockPos;
|
use azalea_core::{position::BlockPos, resource_location::ResourceLocation};
|
||||||
use azalea_protocol_macros::ClientboundGamePacket;
|
use azalea_protocol_macros::ClientboundGamePacket;
|
||||||
use azalea_registry::{ParticleKind, SoundEvent};
|
use azalea_registry::{ParticleKind, SoundEvent};
|
||||||
|
|
||||||
|
@ -59,7 +62,14 @@ impl McBufReadable for ClientboundExplodePacket {
|
||||||
let block_interaction = BlockInteraction::read_from(buf)?;
|
let block_interaction = BlockInteraction::read_from(buf)?;
|
||||||
let small_explosion_particles = ParticleKind::read_from(buf)?;
|
let small_explosion_particles = ParticleKind::read_from(buf)?;
|
||||||
let large_explosion_particles = ParticleKind::read_from(buf)?;
|
let large_explosion_particles = ParticleKind::read_from(buf)?;
|
||||||
let explosion_sound = SoundEvent::read_from(buf)?;
|
|
||||||
|
let sound_event_resource_location = ResourceLocation::read_from(buf)?.to_string();
|
||||||
|
let explosion_sound =
|
||||||
|
SoundEvent::from_str(&sound_event_resource_location).map_err(|_| {
|
||||||
|
BufReadError::UnexpectedStringEnumVariant {
|
||||||
|
id: sound_event_resource_location,
|
||||||
|
}
|
||||||
|
})?;
|
||||||
|
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
x,
|
x,
|
||||||
|
@ -108,7 +118,10 @@ impl McBufWritable for ClientboundExplodePacket {
|
||||||
self.block_interaction.write_into(buf)?;
|
self.block_interaction.write_into(buf)?;
|
||||||
self.small_explosion_particles.write_into(buf)?;
|
self.small_explosion_particles.write_into(buf)?;
|
||||||
self.large_explosion_particles.write_into(buf)?;
|
self.large_explosion_particles.write_into(buf)?;
|
||||||
self.explosion_sound.write_into(buf)?;
|
|
||||||
|
let sound_event_resource_location =
|
||||||
|
ResourceLocation::new(&self.explosion_sound.to_string());
|
||||||
|
sound_event_resource_location.write_into(buf)?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,5 @@ use azalea_protocol_macros::ClientboundGamePacket;
|
||||||
|
|
||||||
#[derive(Clone, Debug, McBuf, ClientboundGamePacket)]
|
#[derive(Clone, Debug, McBuf, ClientboundGamePacket)]
|
||||||
pub struct ClientboundPingPacket {
|
pub struct ClientboundPingPacket {
|
||||||
#[var]
|
|
||||||
pub id: u32,
|
pub id: u32,
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
//! - Run `cargo r --example testbot`
|
//! - Run `cargo r --example testbot`
|
||||||
//! - Commands are prefixed with `!` in chat. You can send them either in public
|
//! - Commands are prefixed with `!` in chat. You can send them either in public
|
||||||
//! chat or as a /msg.
|
//! chat or as a /msg.
|
||||||
//! - Some commands to try are `!goto`, `!killaura`, `!down`. Check the
|
//! - Some commands to try are `!goto`, `!killaura true`, `!down`. Check the
|
||||||
//! `commands` directory to see all of them.
|
//! `commands` directory to see all of them.
|
||||||
|
|
||||||
#![feature(async_closure)]
|
#![feature(async_closure)]
|
||||||
|
@ -31,7 +31,7 @@ const ADDRESS: &str = "localhost";
|
||||||
/// Whether the bot should run /particle a ton of times to show where it's
|
/// Whether the bot should run /particle a ton of times to show where it's
|
||||||
/// pathfinding to. You should only have this on if the bot has operator
|
/// pathfinding to. You should only have this on if the bot has operator
|
||||||
/// permissions, otherwise it'll just spam the server console unnecessarily.
|
/// permissions, otherwise it'll just spam the server console unnecessarily.
|
||||||
const PATHFINDER_DEBUG_PARTICLES: bool = true;
|
const PATHFINDER_DEBUG_PARTICLES: bool = false;
|
||||||
|
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
async fn main() {
|
async fn main() {
|
||||||
|
|
|
@ -208,9 +208,11 @@ fn goto_listener(
|
||||||
let thread_pool = AsyncComputeTaskPool::get();
|
let thread_pool = AsyncComputeTaskPool::get();
|
||||||
|
|
||||||
for event in events.read() {
|
for event in events.read() {
|
||||||
let (mut pathfinder, executing_path, position, instance_name, inventory) = query
|
let Ok((mut pathfinder, executing_path, position, instance_name, inventory)) =
|
||||||
.get_mut(event.entity)
|
query.get_mut(event.entity)
|
||||||
.expect("Called goto on an entity that's not in the world");
|
else {
|
||||||
|
continue;
|
||||||
|
};
|
||||||
|
|
||||||
if event.goal.success(BlockPos::from(position)) {
|
if event.goal.success(BlockPos::from(position)) {
|
||||||
// we're already at the goal, nothing to do
|
// we're already at the goal, nothing to do
|
||||||
|
|
Loading…
Add table
Reference in a new issue