mirror of
https://github.com/mat-1/azalea.git
synced 2025-08-02 14:26:04 +00:00
add data for EntityEffect particle to fix set_entity_data errors on hypixel
This commit is contained in:
parent
67c053638c
commit
ef25e77e52
2 changed files with 37 additions and 4 deletions
|
@ -8,7 +8,7 @@ use bevy_ecs::component::Component;
|
||||||
// the order of this enum must be kept in sync with ParticleKind, otherwise
|
// the order of this enum must be kept in sync with ParticleKind, otherwise
|
||||||
// we get errors parsing particles.
|
// we get errors parsing particles.
|
||||||
/// A [`ParticleKind`] with data potentially attached to it.
|
/// A [`ParticleKind`] with data potentially attached to it.
|
||||||
#[derive(Component, Clone, Debug, AzBuf, Default)]
|
#[derive(Component, Clone, Debug, AzBuf)]
|
||||||
pub enum Particle {
|
pub enum Particle {
|
||||||
AngryVillager,
|
AngryVillager,
|
||||||
Block(BlockParticle),
|
Block(BlockParticle),
|
||||||
|
@ -30,8 +30,7 @@ pub enum Particle {
|
||||||
EnchantedHit,
|
EnchantedHit,
|
||||||
Enchant,
|
Enchant,
|
||||||
EndRod,
|
EndRod,
|
||||||
#[default]
|
EntityEffect(ColorParticle),
|
||||||
EntityEffect,
|
|
||||||
ExplosionEmitter,
|
ExplosionEmitter,
|
||||||
Explosion,
|
Explosion,
|
||||||
Gust,
|
Gust,
|
||||||
|
@ -154,7 +153,7 @@ impl From<ParticleKind> for Particle {
|
||||||
ParticleKind::EnchantedHit => Self::EnchantedHit,
|
ParticleKind::EnchantedHit => Self::EnchantedHit,
|
||||||
ParticleKind::Enchant => Self::Enchant,
|
ParticleKind::Enchant => Self::Enchant,
|
||||||
ParticleKind::EndRod => Self::EndRod,
|
ParticleKind::EndRod => Self::EndRod,
|
||||||
ParticleKind::EntityEffect => Self::EntityEffect,
|
ParticleKind::EntityEffect => Self::EntityEffect(ColorParticle::default()),
|
||||||
ParticleKind::ExplosionEmitter => Self::ExplosionEmitter,
|
ParticleKind::ExplosionEmitter => Self::ExplosionEmitter,
|
||||||
ParticleKind::Explosion => Self::Explosion,
|
ParticleKind::Explosion => Self::Explosion,
|
||||||
ParticleKind::Gust => Self::Gust,
|
ParticleKind::Gust => Self::Gust,
|
||||||
|
@ -250,6 +249,12 @@ impl From<ParticleKind> for Particle {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Default for Particle {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self::EntityEffect(ColorParticle::default())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, AzBuf, Default)]
|
#[derive(Debug, Clone, AzBuf, Default)]
|
||||||
pub struct BlockParticle {
|
pub struct BlockParticle {
|
||||||
pub block_state: BlockState,
|
pub block_state: BlockState,
|
||||||
|
@ -269,6 +274,11 @@ pub struct DustColorTransitionParticle {
|
||||||
pub scale: f32,
|
pub scale: f32,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, AzBuf, Default)]
|
||||||
|
pub struct ColorParticle {
|
||||||
|
pub color: RgbColor,
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, AzBuf, Default)]
|
#[derive(Debug, Clone, AzBuf, Default)]
|
||||||
pub struct ItemParticle {
|
pub struct ItemParticle {
|
||||||
pub item: ItemStack,
|
pub item: ItemStack,
|
||||||
|
|
|
@ -8,3 +8,26 @@ pub struct ClientboundSetEntityData {
|
||||||
pub id: u32,
|
pub id: u32,
|
||||||
pub packed_items: EntityMetadataItems,
|
pub packed_items: EntityMetadataItems,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use std::io::Cursor;
|
||||||
|
|
||||||
|
use azalea_buf::AzaleaRead;
|
||||||
|
|
||||||
|
use super::*;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_read_write_container_set_content() {
|
||||||
|
let contents = [161, 226, 1, 10, 18, 1, 20, 38, 124, 175, 198, 255];
|
||||||
|
let mut buf = Cursor::new(contents.as_slice());
|
||||||
|
let packet = ClientboundSetEntityData::azalea_read(&mut buf).unwrap();
|
||||||
|
println!("{:?}", packet);
|
||||||
|
|
||||||
|
assert_eq!(buf.position(), contents.len() as u64);
|
||||||
|
|
||||||
|
let mut buf = Vec::new();
|
||||||
|
packet.write(&mut buf).unwrap();
|
||||||
|
assert_eq!(buf, contents);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue