mirror of
https://github.com/mat-1/azalea.git
synced 2024-09-16 13:32:33 +00:00
fix ClientboundLevelParticlesPacket errors and pathfinder /particle errors
This commit is contained in:
parent
13afc1d6a4
commit
dec544a52b
4 changed files with 50 additions and 34 deletions
|
@ -4,30 +4,19 @@ use azalea_inventory::ItemSlot;
|
|||
use azalea_registry::ParticleKind;
|
||||
use bevy_ecs::component::Component;
|
||||
|
||||
#[derive(Component, Debug, Clone, McBuf, Default)]
|
||||
pub struct Particle {
|
||||
#[var]
|
||||
pub id: i32,
|
||||
pub data: ParticleData,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, McBuf, Default)]
|
||||
pub enum ParticleData {
|
||||
// the order of this enum must be kept in-sync with ParticleKind, otherwise
|
||||
// we get errors parsing particles.
|
||||
/// A [`ParticleKind`] with data potentially attached to it.
|
||||
#[derive(Component, Clone, Debug, McBuf, Default)]
|
||||
pub enum Particle {
|
||||
AngryVillager,
|
||||
BlockMarker(BlockParticle),
|
||||
Block(BlockParticle),
|
||||
BlockMarker(BlockParticle),
|
||||
Bubble,
|
||||
BubbleColumnUp,
|
||||
BubblePop,
|
||||
CampfireCosySmoke,
|
||||
CampfireSignalSmoke,
|
||||
Cloud,
|
||||
Composter,
|
||||
Crit,
|
||||
CurrentDown,
|
||||
DamageIndicator,
|
||||
DragonBreath,
|
||||
Dolphin,
|
||||
DrippingLava,
|
||||
FallingLava,
|
||||
LandingLava,
|
||||
|
@ -44,33 +33,35 @@ pub enum ParticleData {
|
|||
EntityEffect,
|
||||
ExplosionEmitter,
|
||||
Explosion,
|
||||
SonicBoom,
|
||||
FallingDust(BlockParticle),
|
||||
Gust,
|
||||
SmallGust,
|
||||
GustEmitterLarge,
|
||||
GustEmitterSmall,
|
||||
SonicBoom,
|
||||
FallingDust(BlockParticle),
|
||||
Firework,
|
||||
Fishing,
|
||||
Flame,
|
||||
Infested,
|
||||
CherryLeaves,
|
||||
SculkSoul,
|
||||
SculkCharge(SculkChargeParticle),
|
||||
SculkChargePop,
|
||||
Soul,
|
||||
SoulFireFlame,
|
||||
Soul,
|
||||
Flash,
|
||||
HappyVillager,
|
||||
Composter,
|
||||
Heart,
|
||||
InstantEffect,
|
||||
Item(ItemParticle),
|
||||
Vibration(VibrationParticle),
|
||||
ItemSlime,
|
||||
ItemCobweb,
|
||||
ItemSnowball,
|
||||
LargeSmoke,
|
||||
Lava,
|
||||
Mycelium,
|
||||
Nautilus,
|
||||
Note,
|
||||
Poof,
|
||||
Portal,
|
||||
|
@ -78,35 +69,40 @@ pub enum ParticleData {
|
|||
Smoke,
|
||||
WhiteSmoke,
|
||||
Sneeze,
|
||||
Snowflake,
|
||||
Spit,
|
||||
SquidInk,
|
||||
SweepAttack,
|
||||
TotemOfUndying,
|
||||
SquidInk,
|
||||
Underwater,
|
||||
Splash,
|
||||
Witch,
|
||||
BubblePop,
|
||||
CurrentDown,
|
||||
BubbleColumnUp,
|
||||
Nautilus,
|
||||
Dolphin,
|
||||
CampfireCosySmoke,
|
||||
CampfireSignalSmoke,
|
||||
DrippingHoney,
|
||||
FallingHoney,
|
||||
LandingHoney,
|
||||
FallingNectar,
|
||||
FallingSporeBlossom,
|
||||
SporeBlossomAir,
|
||||
Ash,
|
||||
CrimsonSpore,
|
||||
WarpedSpore,
|
||||
SporeBlossomAir,
|
||||
DrippingObsidianTear,
|
||||
FallingObsidianTear,
|
||||
LandingObsidianTear,
|
||||
ReversePortal,
|
||||
WhiteAsh,
|
||||
SmallFlame,
|
||||
DrippingDripstoneWater,
|
||||
FallingDripstoneWater,
|
||||
CherryLeaves,
|
||||
Snowflake,
|
||||
DrippingDripstoneLava,
|
||||
FallingDripstoneLava,
|
||||
Vibration(VibrationParticle),
|
||||
DrippingDripstoneWater,
|
||||
FallingDripstoneWater,
|
||||
GlowSquidInk,
|
||||
Glow,
|
||||
WaxOn,
|
||||
|
@ -120,12 +116,12 @@ pub enum ParticleData {
|
|||
TrialSpawnerDetectionOminous,
|
||||
VaultConnection,
|
||||
DustPillar,
|
||||
OminousSpawning,
|
||||
RaidOmen,
|
||||
TrialOmen,
|
||||
OminousSpawning,
|
||||
}
|
||||
|
||||
impl From<ParticleKind> for ParticleData {
|
||||
impl From<ParticleKind> for Particle {
|
||||
/// Convert a particle kind into particle data. If the particle has data
|
||||
/// attached (like block particles), then it's set to the default.
|
||||
fn from(kind: ParticleKind) -> Self {
|
||||
|
|
|
@ -15,3 +15,25 @@ pub struct ClientboundLevelParticlesPacket {
|
|||
pub count: u32,
|
||||
pub particle: Particle,
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use std::io::Cursor;
|
||||
|
||||
use azalea_buf::McBufReadable;
|
||||
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn test_clientbound_level_particles_packet() {
|
||||
let slice = &[
|
||||
0, 64, 139, 10, 0, 0, 0, 0, 0, 192, 26, 0, 0, 0, 0, 0, 0, 64, 144, 58, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 13, 63, 128, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 63, 128, 0, 0,
|
||||
][..];
|
||||
let mut bytes = Cursor::new(slice);
|
||||
|
||||
let _packet = ClientboundLevelParticlesPacket::read_from(&mut bytes).unwrap();
|
||||
assert_eq!(bytes.position(), slice.len() as u64);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@ fn main() {
|
|||
// stable & beta
|
||||
panic!("Azalea currently requires nightly Rust. You can use `rustup override set nightly` to set the toolchain for this directory.");
|
||||
}
|
||||
Ok(_) => return, // nightly
|
||||
Ok(_) => {} // nightly
|
||||
Err(_) => {
|
||||
// probably not installed via rustup, run rustc and parse its output
|
||||
let rustc_command = env::var("RUSTC")
|
||||
|
|
|
@ -55,8 +55,6 @@ pub fn debug_render_path_with_particles(
|
|||
|
||||
let mut start = executing_path.last_reached_node;
|
||||
for (i, movement) in executing_path.path.iter().enumerate() {
|
||||
// /particle dust 0 1 1 1 ~ ~ ~ 0 0 0.2 0 100
|
||||
|
||||
let end = movement.target;
|
||||
|
||||
let start_vec3 = start.center();
|
||||
|
@ -91,7 +89,7 @@ pub fn debug_render_path_with_particles(
|
|||
z: start_vec3.z + (end_vec3.z - start_vec3.z) * percent,
|
||||
};
|
||||
let particle_command = format!(
|
||||
"/particle dust {r} {g} {b} {size} {start_x} {start_y} {start_z} {delta_x} {delta_y} {delta_z} 0 {count}",
|
||||
"/particle dust{{color:[{r},{g},{b}],scale:{size}}} {start_x} {start_y} {start_z} {delta_x} {delta_y} {delta_z} 0 {count}",
|
||||
size = 1,
|
||||
start_x = pos.x,
|
||||
start_y = pos.y,
|
||||
|
|
Loading…
Reference in a new issue