azalea_client/plugins/
brand.rs

1use azalea_buf::AzaleaWrite;
2use azalea_protocol::packets::config::s_custom_payload::ServerboundCustomPayload;
3use bevy_app::prelude::*;
4use bevy_ecs::prelude::*;
5
6use super::packet::config::SendConfigPacketEvent;
7use crate::{client_information::send_client_information, packet::login::InLoginState};
8
9/// Send a [`ServerboundCustomPayload`] with "vanilla" as the brand on join.
10///
11/// You can [disable this plugin](https://azalea.matdoes.dev/azalea/struct.ClientBuilder.html#method.new_without_plugins)
12/// and register your own system if you'd like to send a different brand.
13pub struct BrandPlugin;
14impl Plugin for BrandPlugin {
15    fn build(&self, app: &mut App) {
16        app.add_systems(Update, send_brand.before(send_client_information));
17    }
18}
19
20pub fn send_brand(mut commands: Commands, mut removed: RemovedComponents<InLoginState>) {
21    for entity in removed.read() {
22        let mut brand_data = Vec::new();
23        // pretend to be vanilla
24        "vanilla".azalea_write(&mut brand_data).unwrap();
25        commands.trigger(SendConfigPacketEvent::new(
26            entity,
27            ServerboundCustomPayload {
28                identifier: "brand".into(),
29                data: brand_data.into(),
30            },
31        ));
32    }
33}