├── azalea-brigadier ├── tests │ ├── tree │ │ ├── mod.rs │ │ ├── root_command_node_test.rs │ │ ├── abstract_command_node_test.rs │ │ ├── argument_command_node_test.rs │ │ └── literal_command_node_test.rs │ ├── context │ │ ├── command_context_test.rs │ │ ├── parsed_argument_test.rs │ │ └── mod.rs │ ├── arguments │ │ ├── bool_argument_type_test.rs │ │ ├── double_argument_type_test.rs │ │ ├── float_argument_type_test.rs │ │ ├── integer_argument_type_test.rs │ │ ├── long_argument_type_test.rs │ │ ├── string_argument_type_test.rs │ │ └── mod.rs │ ├── builder │ │ ├── literal_argument_builder_test.rs │ │ ├── required_argument_builder_test.rs │ │ └── mod.rs │ ├── exceptions │ │ ├── simple_command_syntax_exception_type_test.rs │ │ ├── dynamic_command_syntax_exception_type_test.rs │ │ └── mod.rs │ ├── suggestion │ │ └── mod.rs │ └── mod.rs ├── src │ ├── builder │ │ ├── mod.rs │ │ └── literal_argument_builder.rs │ ├── errors │ │ └── mod.rs │ ├── modifier.rs │ ├── context │ │ ├── parsed_argument.rs │ │ ├── suggestion_context.rs │ │ ├── mod.rs │ │ ├── parsed_command_node.rs │ │ └── string_range.rs │ ├── arguments │ │ ├── mod.rs │ │ ├── argument_type.rs │ │ └── bool_argument_type.rs │ ├── suggestion │ │ └── suggestion_provider.rs │ ├── result_consumer.rs │ ├── parse_results.rs │ └── lib.rs ├── Cargo.toml └── README.md ├── azalea-client ├── tests │ ├── main.rs │ └── simulation │ │ ├── client_disconnect.rs │ │ ├── receive_start_config_packet.rs │ │ ├── mod.rs │ │ ├── ticks_alive.rs │ │ └── receive_spawn_entity_and_start_config_packet.rs ├── src │ ├── test_utils │ │ └── mod.rs │ ├── lib.rs │ └── plugins │ │ ├── respawn.rs │ │ ├── tick_end.rs │ │ ├── pong.rs │ │ ├── tick_counter.rs │ │ └── brand.rs └── README.md ├── azalea-buf ├── azalea-buf-macros │ ├── README.md │ ├── Cargo.toml │ └── src │ │ └── lib.rs ├── README.md ├── Cargo.toml └── src │ └── definitions.rs ├── rust-toolchain.toml ├── codegen ├── .gitignore ├── genitemcomponents.py ├── lib │ └── code │ │ └── language.py ├── genlanguage.py ├── genpackets.py ├── genentities.py ├── newpacket.py └── genblocks.py ├── azalea-block ├── azalea-block-macros │ ├── src │ │ └── property │ │ │ └── mod.rs │ └── Cargo.toml ├── .gitignore └── Cargo.toml ├── .github ├── FUNDING.yml └── workflows │ ├── ci.yml │ └── doc.yml ├── azalea-crypto ├── README.md ├── src │ └── offline.rs ├── benches │ └── my_benchmark.rs └── Cargo.toml ├── azalea-physics ├── README.md └── Cargo.toml ├── azalea-world ├── README.md ├── src │ └── lib.rs ├── Cargo.toml └── benches │ └── chunks.rs ├── azalea-entity ├── README.md └── Cargo.toml ├── azalea-inventory ├── README.md ├── azalea-inventory-macros │ ├── Cargo.toml │ └── src │ │ └── lib.rs ├── src │ ├── default_components │ │ └── mod.rs │ └── item │ │ └── mod.rs └── Cargo.toml ├── azalea-core ├── README.md ├── src │ ├── registry_holder │ │ ├── block_predicate.rs │ │ └── block_state_provider.rs │ ├── sound.rs │ ├── tick.rs │ ├── objectives.rs │ ├── attribute_modifier_operation.rs │ ├── lib.rs │ └── color.rs └── Cargo.toml ├── rustfmt.toml ├── azalea ├── src │ ├── swarm │ │ ├── prelude.rs │ │ └── events.rs │ ├── prelude.rs │ └── auto_respawn.rs ├── examples │ ├── todo │ │ └── README.md │ ├── echo.rs │ └── testbot │ │ ├── commands │ │ └── combat.rs │ │ └── commands.rs └── benches │ └── checks.rs ├── typos.toml ├── azalea-language ├── README.md ├── Cargo.toml └── src │ └── lib.rs ├── azalea-protocol ├── README.md ├── src │ ├── packets │ │ ├── config │ │ │ ├── c_reset_chat.rs │ │ │ ├── c_clear_dialog.rs │ │ │ ├── c_finish_configuration.rs │ │ │ ├── c_ping.rs │ │ │ ├── s_finish_configuration.rs │ │ │ ├── s_pong.rs │ │ │ ├── s_accept_code_of_conduct.rs │ │ │ ├── c_keep_alive.rs │ │ │ ├── s_keep_alive.rs │ │ │ ├── c_code_of_conduct.rs │ │ │ ├── c_show_dialog.rs │ │ │ ├── c_resource_pack_pop.rs │ │ │ ├── c_disconnect.rs │ │ │ ├── c_transfer.rs │ │ │ ├── c_update_tags.rs │ │ │ ├── c_cookie_request.rs │ │ │ ├── c_custom_report_details.rs │ │ │ ├── c_server_links.rs │ │ │ ├── c_update_enabled_features.rs │ │ │ ├── c_select_known_packs.rs │ │ │ ├── c_store_cookie.rs │ │ │ ├── s_cookie_response.rs │ │ │ ├── s_client_information.rs │ │ │ ├── c_custom_payload.rs │ │ │ ├── s_custom_payload.rs │ │ │ ├── s_custom_click_action.rs │ │ │ ├── c_registry_data.rs │ │ │ ├── c_resource_pack_push.rs │ │ │ ├── s_select_known_packs.rs │ │ │ ├── s_resource_pack.rs │ │ │ └── mod.rs │ │ ├── game │ │ │ ├── c_clear_dialog.rs │ │ │ ├── s_player_loaded.rs │ │ │ ├── c_bundle_delimiter.rs │ │ │ ├── s_client_tick_end.rs │ │ │ ├── c_chunk_batch_start.rs │ │ │ ├── c_ping.rs │ │ │ ├── s_pong.rs │ │ │ ├── c_start_configuration.rs │ │ │ ├── c_keep_alive.rs │ │ │ ├── s_configuration_acknowledged.rs │ │ │ ├── s_keep_alive.rs │ │ │ ├── c_pong_response.rs │ │ │ ├── s_ping_request.rs │ │ │ ├── s_rename_item.rs │ │ │ ├── c_clear_titles.rs │ │ │ ├── c_set_border_size.rs │ │ │ ├── s_chat_command.rs │ │ │ ├── s_set_carried_item.rs │ │ │ ├── c_player_combat_enter.rs │ │ │ ├── s_chat_ack.rs │ │ │ ├── s_lock_difficulty.rs │ │ │ ├── c_set_held_slot.rs │ │ │ ├── s_select_trade.rs │ │ │ ├── c_block_changed_ack.rs │ │ │ ├── c_ticking_step.rs │ │ │ ├── s_paddle_boat.rs │ │ │ ├── c_container_close.rs │ │ │ ├── s_accept_teleportation.rs │ │ │ ├── s_chat_preview.rs │ │ │ ├── s_container_close.rs │ │ │ ├── s_pick_item_from_block.rs │ │ │ ├── s_teleport_to_entity.rs │ │ │ ├── c_chunk_batch_finished.rs │ │ │ ├── c_recipe_book_remove.rs │ │ │ ├── c_resource_pack_pop.rs │ │ │ ├── c_set_chunk_cache_radius.rs │ │ │ ├── c_ticking_state.rs │ │ │ ├── s_chunk_batch_received.rs │ │ │ ├── c_disconnect.rs │ │ │ ├── c_player_info_remove.rs │ │ │ ├── c_reset_score.rs │ │ │ ├── c_set_border_center.rs │ │ │ ├── c_set_border_warning_delay.rs │ │ │ ├── c_transfer.rs │ │ │ ├── c_set_border_warning_distance.rs │ │ │ ├── c_set_cursor_item.rs │ │ │ ├── c_set_simulation_distance.rs │ │ │ ├── c_set_title_text.rs │ │ │ ├── c_update_tags.rs │ │ │ ├── c_forget_level_chunk.rs │ │ │ ├── c_set_action_bar_text.rs │ │ │ ├── c_set_subtitle_text.rs │ │ │ ├── s_change_game_mode.rs │ │ │ ├── c_cookie_request.rs │ │ │ ├── c_open_book.rs │ │ │ ├── c_set_time.rs │ │ │ ├── s_change_difficulty.rs │ │ │ ├── s_command_suggestion.rs │ │ │ ├── s_swing.rs │ │ │ ├── c_set_chunk_cache_center.rs │ │ │ ├── c_set_health.rs │ │ │ ├── c_set_titles_animation.rs │ │ │ ├── s_recipe_book_seen_recipe.rs │ │ │ ├── c_player_combat_end.rs │ │ │ ├── c_set_camera.rs │ │ │ ├── c_select_advancements_tab.rs │ │ │ ├── c_tag_query.rs │ │ │ ├── s_edit_book.rs │ │ │ ├── s_move_player_status_only.rs │ │ │ ├── s_set_beacon.rs │ │ │ ├── c_container_set_data.rs │ │ │ ├── c_delete_chat.rs │ │ │ ├── c_cooldown.rs │ │ │ ├── c_entity_event.rs │ │ │ ├── c_open_sign_editor.rs │ │ │ ├── c_remove_entities.rs │ │ │ ├── c_server_data.rs │ │ │ ├── c_store_cookie.rs │ │ │ ├── s_bundle_item_selected.rs │ │ │ ├── s_container_button_click.rs │ │ │ ├── c_debug_event.rs │ │ │ ├── c_player_rotation.rs │ │ │ ├── c_set_border_lerp_size.rs │ │ │ ├── c_change_difficulty.rs │ │ │ ├── c_hurt_animation.rs │ │ │ ├── c_show_dialog.rs │ │ │ ├── s_debug_subscription_request.rs │ │ │ ├── s_set_command_minecart.rs │ │ │ ├── s_set_creative_mode_slot.rs │ │ │ ├── c_respawn.rs │ │ │ ├── c_rotate_head.rs │ │ │ ├── c_set_player_inventory.rs │ │ │ ├── s_cookie_response.rs │ │ │ ├── c_set_entity_link.rs │ │ │ ├── s_client_information.rs │ │ │ ├── c_game_test_highlight_pos.rs │ │ │ ├── s_block_entity_tag_query.rs │ │ │ ├── s_sign_update.rs │ │ │ ├── c_block_update.rs │ │ │ ├── c_projectile_power.rs │ │ │ ├── s_pick_item_from_entity.rs │ │ │ ├── c_custom_payload.rs │ │ │ ├── c_move_vehicle.rs │ │ │ ├── c_set_experience.rs │ │ │ ├── s_custom_click_action.rs │ │ │ ├── s_custom_payload.rs │ │ │ ├── s_move_vehicle.rs │ │ │ ├── c_set_default_spawn_position.rs │ │ │ ├── s_container_slot_state_changed.rs │ │ │ ├── s_jigsaw_generate.rs │ │ │ ├── s_move_player_pos.rs │ │ │ ├── c_level_event.rs │ │ │ ├── c_place_ghost_recipe.rs │ │ │ ├── s_entity_tag_query.rs │ │ │ ├── s_place_recipe.rs │ │ │ ├── c_set_entity_motion.rs │ │ │ ├── c_set_passengers.rs │ │ │ ├── c_test_instance_block_status.rs │ │ │ ├── s_move_player_rot.rs │ │ │ ├── s_client_command.rs │ │ │ ├── c_move_entity_rot.rs │ │ │ ├── s_use_item.rs │ │ │ ├── c_remove_mob_effect.rs │ │ │ ├── c_take_item_entity.rs │ │ │ ├── c_mount_screen_open.rs │ │ │ ├── c_open_screen.rs │ │ │ ├── c_block_event.rs │ │ │ ├── c_debug_block_value.rs │ │ │ ├── c_debug_chunk_value.rs │ │ │ ├── c_debug_sample.rs │ │ │ ├── c_debug_entity_value.rs │ │ │ ├── c_move_entity_pos.rs │ │ │ ├── c_resource_pack_push.rs │ │ │ ├── c_player_combat_kill.rs │ │ │ ├── c_block_entity_data.rs │ │ │ ├── c_custom_chat_completions.rs │ │ │ ├── c_player_position.rs │ │ │ ├── s_move_player_pos_rot.rs │ │ │ ├── c_chunks_biomes.rs │ │ │ ├── c_entity_position_sync.rs │ │ │ ├── c_set_score.rs │ │ │ ├── c_update_mob_effect.rs │ │ │ ├── c_custom_report_details.rs │ │ │ ├── c_teleport_entity.rs │ │ │ ├── c_block_destruction.rs │ │ │ ├── s_recipe_book_change_settings.rs │ │ │ ├── s_set_test_block.rs │ │ │ ├── c_initialize_border.rs │ │ │ ├── c_level_particles.rs │ │ │ ├── s_resource_pack.rs │ │ │ ├── c_move_entity_pos_rot.rs │ │ │ ├── c_container_set_slot.rs │ │ │ ├── c_sound_entity.rs │ │ │ ├── c_player_look_at.rs │ │ │ ├── s_player_command.rs │ │ │ ├── c_move_minecart_along_track.rs │ │ │ ├── c_update_attributes.rs │ │ │ ├── s_chat_session_update.rs │ │ │ ├── s_chat_command_signed.rs │ │ │ ├── s_player_action.rs │ │ │ ├── c_animate.rs │ │ │ ├── c_recipe_book_settings.rs │ │ │ ├── s_chat.rs │ │ │ ├── c_light_update.rs │ │ │ ├── c_award_stats.rs │ │ │ ├── c_game_event.rs │ │ │ ├── c_set_display_objective.rs │ │ │ ├── c_recipe_book_add.rs │ │ │ ├── c_update_recipes.rs │ │ │ ├── c_explode.rs │ │ │ ├── c_login.rs │ │ │ ├── s_player_abilities.rs │ │ │ ├── c_set_entity_data.rs │ │ │ ├── c_command_suggestions.rs │ │ │ ├── s_test_instance_block_action.rs │ │ │ ├── s_seen_advancements.rs │ │ │ ├── c_server_links.rs │ │ │ ├── c_damage_event.rs │ │ │ ├── c_container_set_content.rs │ │ │ └── c_level_chunk_with_light.rs │ │ ├── status │ │ │ ├── s_status_request.rs │ │ │ ├── c_pong_response.rs │ │ │ ├── s_ping_request.rs │ │ │ └── mod.rs │ │ ├── login │ │ │ ├── s_login_acknowledged.rs │ │ │ ├── s_key.rs │ │ │ ├── c_cookie_request.rs │ │ │ ├── c_login_finished.rs │ │ │ ├── c_login_compression.rs │ │ │ ├── s_cookie_response.rs │ │ │ ├── c_hello.rs │ │ │ ├── s_custom_query_answer.rs │ │ │ ├── c_custom_query.rs │ │ │ ├── mod.rs │ │ │ └── s_hello.rs │ │ ├── handshake │ │ │ ├── mod.rs │ │ │ └── s_intention.rs │ │ └── common.rs │ └── common │ │ ├── mod.rs │ │ └── server_links.rs └── azalea-protocol-macros │ └── Cargo.toml ├── .cargo └── config.toml ├── azalea-chat ├── src │ └── lib.rs ├── README.md └── Cargo.toml ├── azalea-auth ├── src │ └── lib.rs ├── examples │ ├── auth.rs │ ├── certificates.rs │ └── auth_manual.rs ├── README.md └── Cargo.toml ├── azalea-registry ├── README.md ├── azalea-registry-macros │ └── Cargo.toml ├── src │ └── tags │ │ └── fluids.rs └── Cargo.toml ├── .gitignore ├── docs-rs └── README.md └── LICENSE.md /azalea-brigadier/tests/tree/mod.rs: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /azalea-client/tests/main.rs: -------------------------------------------------------------------------------- 1 | mod simulation; 2 | -------------------------------------------------------------------------------- /azalea-brigadier/tests/tree/root_command_node_test.rs: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /azalea-brigadier/tests/tree/abstract_command_node_test.rs: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /azalea-brigadier/tests/tree/argument_command_node_test.rs: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /azalea-brigadier/tests/tree/literal_command_node_test.rs: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /azalea-brigadier/tests/context/command_context_test.rs: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /azalea-brigadier/tests/context/parsed_argument_test.rs: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /azalea-buf/azalea-buf-macros/README.md: -------------------------------------------------------------------------------- 1 | Only used in azalea-buf. -------------------------------------------------------------------------------- /rust-toolchain.toml: -------------------------------------------------------------------------------- 1 | [toolchain] 2 | channel = "nightly" 3 | -------------------------------------------------------------------------------- /azalea-brigadier/tests/arguments/bool_argument_type_test.rs: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /azalea-brigadier/tests/arguments/double_argument_type_test.rs: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /azalea-brigadier/tests/arguments/float_argument_type_test.rs: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /azalea-brigadier/tests/arguments/integer_argument_type_test.rs: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /azalea-brigadier/tests/arguments/long_argument_type_test.rs: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /azalea-brigadier/tests/arguments/string_argument_type_test.rs: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /azalea-brigadier/tests/builder/literal_argument_builder_test.rs: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /azalea-brigadier/tests/builder/required_argument_builder_test.rs: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /azalea-brigadier/tests/exceptions/simple_command_syntax_exception_type_test.rs: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /azalea-brigadier/tests/exceptions/dynamic_command_syntax_exception_type_test.rs: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /codegen/.gitignore: -------------------------------------------------------------------------------- 1 | __pycache__ 2 | *.tmp 3 | 4 | downloads 5 | __cache__ 6 | venv 7 | -------------------------------------------------------------------------------- /azalea-block/azalea-block-macros/src/property/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod generate; 2 | pub mod parse; 3 | -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | ko_fi: matdoesdev 4 | -------------------------------------------------------------------------------- /azalea-brigadier/tests/context/mod.rs: -------------------------------------------------------------------------------- 1 | mod command_context_test; 2 | mod parsed_argument_test; 3 | -------------------------------------------------------------------------------- /azalea-crypto/README.md: -------------------------------------------------------------------------------- 1 | # `azalea-crypto` 2 | 3 | Cryptography features used in Minecraft. 4 | -------------------------------------------------------------------------------- /azalea-physics/README.md: -------------------------------------------------------------------------------- 1 | # `azalea-physics` 2 | 3 | Accurate physics for Minecraft entities. 4 | -------------------------------------------------------------------------------- /azalea-world/README.md: -------------------------------------------------------------------------------- 1 | # `azalea-world` 2 | 3 | The Minecraft world representation used by Azalea. 4 | -------------------------------------------------------------------------------- /azalea-block/.gitignore: -------------------------------------------------------------------------------- 1 | # cargo expand generated -p azalea-block > azalea-block/out.rs 2 | /out.rs 3 | 4 | -------------------------------------------------------------------------------- /azalea-entity/README.md: -------------------------------------------------------------------------------- 1 | # `azalea-entity` 2 | 3 | Features related to Minecraft entities used by Azalea. 4 | -------------------------------------------------------------------------------- /azalea-brigadier/tests/suggestion/mod.rs: -------------------------------------------------------------------------------- 1 | mod suggestion_test; 2 | mod suggestions_builder_test; 3 | mod suggestions_test; 4 | -------------------------------------------------------------------------------- /azalea-inventory/README.md: -------------------------------------------------------------------------------- 1 | # `azalea-inventory` 2 | 3 | Representations of various inventory data structures from Minecraft. 4 | -------------------------------------------------------------------------------- /azalea-brigadier/tests/mod.rs: -------------------------------------------------------------------------------- 1 | mod arguments; 2 | mod builder; 3 | mod context; 4 | mod exceptions; 5 | mod suggestion; 6 | mod tree; 7 | -------------------------------------------------------------------------------- /azalea-brigadier/src/builder/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod argument_builder; 2 | pub mod literal_argument_builder; 3 | pub mod required_argument_builder; 4 | -------------------------------------------------------------------------------- /azalea-brigadier/tests/exceptions/mod.rs: -------------------------------------------------------------------------------- 1 | mod dynamic_command_syntax_exception_type_test; 2 | mod simple_command_syntax_exception_type_test; 3 | -------------------------------------------------------------------------------- /azalea-core/README.md: -------------------------------------------------------------------------------- 1 | # `azalea-core` 2 | 3 | Random miscellaneous things like `bitsets` and `Vec3` that don't deserve their own crate. 4 | -------------------------------------------------------------------------------- /azalea-brigadier/tests/builder/mod.rs: -------------------------------------------------------------------------------- 1 | mod argument_builder_test; 2 | mod literal_argument_builder_test; 3 | mod required_argument_builder_test; 4 | -------------------------------------------------------------------------------- /rustfmt.toml: -------------------------------------------------------------------------------- 1 | wrap_comments = true 2 | group_imports = "StdExternalCrate" 3 | imports_granularity = "Crate" 4 | format_code_in_doc_comments = true 5 | -------------------------------------------------------------------------------- /azalea/src/swarm/prelude.rs: -------------------------------------------------------------------------------- 1 | //! A prelude that re-exports common swarm types in Azalea. 2 | 3 | pub use crate::swarm::{Swarm, SwarmBuilder, SwarmEvent}; 4 | -------------------------------------------------------------------------------- /azalea-core/src/registry_holder/block_predicate.rs: -------------------------------------------------------------------------------- 1 | /// TODO: unimplemented 2 | #[derive(Clone, Debug, simdnbt::Deserialize)] 3 | pub struct BlockPredicate {} 4 | -------------------------------------------------------------------------------- /azalea-client/src/test_utils/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod simulation; 2 | pub mod tracing; 3 | 4 | pub mod prelude { 5 | pub use super::{simulation::*, tracing::*}; 6 | } 7 | -------------------------------------------------------------------------------- /azalea/examples/todo/README.md: -------------------------------------------------------------------------------- 1 | These examples don't work yet and were only written to help design APIs. They will work in the future (probably with minor changes). 2 | -------------------------------------------------------------------------------- /typos.toml: -------------------------------------------------------------------------------- 1 | [files] 2 | extend-exclude = ['azalea-language/src/en_us.json'] 3 | 4 | [default] 5 | extend-ignore-re = ['Hel', 'inout', 'Shs', 'shs', '"CONVERTABLE"'] 6 | -------------------------------------------------------------------------------- /azalea-core/src/registry_holder/block_state_provider.rs: -------------------------------------------------------------------------------- 1 | /// TODO: unimplemented 2 | #[derive(Clone, Debug, simdnbt::Deserialize)] 3 | pub struct BlockStateProvider {} 4 | -------------------------------------------------------------------------------- /azalea-brigadier/src/errors/mod.rs: -------------------------------------------------------------------------------- 1 | mod builtin_errors; 2 | mod command_syntax_error; 3 | 4 | pub use builtin_errors::BuiltInError; 5 | pub use command_syntax_error::CommandSyntaxError; 6 | -------------------------------------------------------------------------------- /azalea-client/README.md: -------------------------------------------------------------------------------- 1 | # `azalea-client` 2 | 3 | A library that can mimic everything that a normal Minecraft client can do. 4 | 5 | To make a bot with higher-level functions, consider using the `azalea` crate instead. 6 | -------------------------------------------------------------------------------- /azalea-language/README.md: -------------------------------------------------------------------------------- 1 | # `azalea-language` 2 | 3 | Translate Minecraft strings from their IDs. 4 | 5 | # Examples 6 | 7 | ``` 8 | assert_eq!(azalea_language::get("translation.test.none"), Some("Hello, world!")); 9 | ``` -------------------------------------------------------------------------------- /azalea-protocol/README.md: -------------------------------------------------------------------------------- 1 | # `azalea-protocol` 2 | 3 | A low-level crate for sending and receiving Minecraft packets. 4 | 5 | Only the latest Minecraft version is supported. 6 | 7 | See [`crate::connect::Connection`] for usage. 8 | -------------------------------------------------------------------------------- /codegen/genitemcomponents.py: -------------------------------------------------------------------------------- 1 | import lib.code.data_components 2 | import lib.code.version 3 | 4 | if __name__ == "__main__": 5 | version_id = lib.code.version.get_version_id() 6 | lib.code.data_components.generate(version_id) 7 | -------------------------------------------------------------------------------- /azalea-brigadier/tests/arguments/mod.rs: -------------------------------------------------------------------------------- 1 | mod bool_argument_type_test; 2 | mod double_argument_type_test; 3 | mod float_argument_type_test; 4 | mod integer_argument_type_test; 5 | mod long_argument_type_test; 6 | mod string_argument_type_test; 7 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/config/c_reset_chat.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | use azalea_protocol_macros::ClientboundConfigPacket; 3 | 4 | #[derive(AzBuf, ClientboundConfigPacket, Clone, Debug, PartialEq)] 5 | pub struct ClientboundResetChat; 6 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/game/c_clear_dialog.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | use azalea_protocol_macros::ClientboundGamePacket; 3 | 4 | #[derive(AzBuf, ClientboundGamePacket, Clone, Debug, PartialEq)] 5 | pub struct ClientboundClearDialog; 6 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/game/s_player_loaded.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | use azalea_protocol_macros::ServerboundGamePacket; 3 | 4 | #[derive(AzBuf, Clone, Debug, PartialEq, ServerboundGamePacket)] 5 | pub struct ServerboundPlayerLoaded; 6 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/config/c_clear_dialog.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | use azalea_protocol_macros::ClientboundConfigPacket; 3 | 4 | #[derive(AzBuf, ClientboundConfigPacket, Clone, Debug, PartialEq)] 5 | pub struct ClientboundClearDialog; 6 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/game/c_bundle_delimiter.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | use azalea_protocol_macros::ClientboundGamePacket; 3 | 4 | #[derive(AzBuf, ClientboundGamePacket, Clone, Debug, PartialEq)] 5 | pub struct ClientboundBundleDelimiter; 6 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/game/s_client_tick_end.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | use azalea_protocol_macros::ServerboundGamePacket; 3 | 4 | #[derive(AzBuf, Clone, Debug, PartialEq, ServerboundGamePacket)] 5 | pub struct ServerboundClientTickEnd; 6 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/game/c_chunk_batch_start.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | use azalea_protocol_macros::ClientboundGamePacket; 3 | 4 | #[derive(AzBuf, ClientboundGamePacket, Clone, Debug, PartialEq)] 5 | pub struct ClientboundChunkBatchStart; 6 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/game/c_ping.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | use azalea_protocol_macros::ClientboundGamePacket; 3 | 4 | #[derive(AzBuf, ClientboundGamePacket, Clone, Debug, PartialEq)] 5 | pub struct ClientboundPing { 6 | pub id: u32, 7 | } 8 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/game/s_pong.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | use azalea_protocol_macros::ServerboundGamePacket; 3 | 4 | #[derive(AzBuf, Clone, Debug, PartialEq, ServerboundGamePacket)] 5 | pub struct ServerboundPong { 6 | pub id: u32, 7 | } 8 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/status/s_status_request.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | use azalea_protocol_macros::ServerboundStatusPacket; 3 | 4 | #[derive(AzBuf, Clone, Debug, PartialEq, ServerboundStatusPacket)] 5 | pub struct ServerboundStatusRequest; 6 | -------------------------------------------------------------------------------- /azalea-protocol/src/common/mod.rs: -------------------------------------------------------------------------------- 1 | //! Some serializable data types that are used by several packets. 2 | 3 | pub mod client_information; 4 | pub mod debug_subscription; 5 | pub mod movements; 6 | pub mod recipe; 7 | pub mod server_links; 8 | pub mod tags; 9 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/game/c_start_configuration.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | use azalea_protocol_macros::ClientboundGamePacket; 3 | 4 | #[derive(AzBuf, ClientboundGamePacket, Clone, Debug, PartialEq)] 5 | pub struct ClientboundStartConfiguration; 6 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/login/s_login_acknowledged.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | use azalea_protocol_macros::ServerboundLoginPacket; 3 | 4 | #[derive(AzBuf, Clone, Debug, PartialEq, ServerboundLoginPacket)] 5 | pub struct ServerboundLoginAcknowledged; 6 | -------------------------------------------------------------------------------- /azalea-brigadier/src/modifier.rs: -------------------------------------------------------------------------------- 1 | use std::sync::Arc; 2 | 3 | use crate::{context::CommandContext, errors::CommandSyntaxError}; 4 | 5 | pub type RedirectModifier = 6 | dyn Fn(&CommandContext) -> Result>, CommandSyntaxError> + Send + Sync; 7 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/config/c_finish_configuration.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | use azalea_protocol_macros::ClientboundConfigPacket; 3 | 4 | #[derive(AzBuf, ClientboundConfigPacket, Clone, Debug, PartialEq)] 5 | pub struct ClientboundFinishConfiguration; 6 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/config/c_ping.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | use azalea_protocol_macros::ClientboundConfigPacket; 3 | 4 | #[derive(AzBuf, ClientboundConfigPacket, Clone, Debug, PartialEq)] 5 | pub struct ClientboundPing { 6 | pub id: u32, 7 | } 8 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/config/s_finish_configuration.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | use azalea_protocol_macros::ServerboundConfigPacket; 3 | 4 | #[derive(AzBuf, Clone, Debug, PartialEq, ServerboundConfigPacket)] 5 | pub struct ServerboundFinishConfiguration; 6 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/config/s_pong.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | use azalea_protocol_macros::ServerboundConfigPacket; 3 | 4 | #[derive(AzBuf, Clone, Debug, PartialEq, ServerboundConfigPacket)] 5 | pub struct ServerboundPong { 6 | pub id: u32, 7 | } 8 | -------------------------------------------------------------------------------- /.cargo/config.toml: -------------------------------------------------------------------------------- 1 | [build] 2 | rustflags = ["--cfg", "docsrs_dep"] 3 | rustdocflags = [ 4 | "--html-after-content", 5 | "docs-rs/trait-tags.html", 6 | "--cfg", 7 | "docsrs_dep", 8 | ] 9 | 10 | [unstable] 11 | rustdoc-scrape-examples = true 12 | -------------------------------------------------------------------------------- /azalea-brigadier/src/context/parsed_argument.rs: -------------------------------------------------------------------------------- 1 | use std::{any::Any, sync::Arc}; 2 | 3 | use super::string_range::StringRange; 4 | 5 | #[derive(Clone)] 6 | pub struct ParsedArgument { 7 | pub range: StringRange, 8 | pub result: Arc, 9 | } 10 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/config/s_accept_code_of_conduct.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | use azalea_protocol_macros::ServerboundConfigPacket; 3 | 4 | #[derive(AzBuf, Clone, Debug, PartialEq, ServerboundConfigPacket)] 5 | pub struct ServerboundAcceptCodeOfConduct; 6 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/game/c_keep_alive.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | use azalea_protocol_macros::ClientboundGamePacket; 3 | 4 | #[derive(AzBuf, ClientboundGamePacket, Clone, Debug, PartialEq)] 5 | pub struct ClientboundKeepAlive { 6 | pub id: u64, 7 | } 8 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/game/s_configuration_acknowledged.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | use azalea_protocol_macros::ServerboundGamePacket; 3 | 4 | #[derive(AzBuf, Clone, Debug, PartialEq, ServerboundGamePacket)] 5 | pub struct ServerboundConfigurationAcknowledged; 6 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/game/s_keep_alive.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | use azalea_protocol_macros::ServerboundGamePacket; 3 | 4 | #[derive(AzBuf, Clone, Debug, PartialEq, ServerboundGamePacket)] 5 | pub struct ServerboundKeepAlive { 6 | pub id: u64, 7 | } 8 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/config/c_keep_alive.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | use azalea_protocol_macros::ClientboundConfigPacket; 3 | 4 | #[derive(AzBuf, ClientboundConfigPacket, Clone, Debug, PartialEq)] 5 | pub struct ClientboundKeepAlive { 6 | pub id: u64, 7 | } 8 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/config/s_keep_alive.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | use azalea_protocol_macros::ServerboundConfigPacket; 3 | 4 | #[derive(AzBuf, Clone, Debug, PartialEq, ServerboundConfigPacket)] 5 | pub struct ServerboundKeepAlive { 6 | pub id: u64, 7 | } 8 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/game/c_pong_response.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | use azalea_protocol_macros::ClientboundGamePacket; 3 | 4 | #[derive(AzBuf, ClientboundGamePacket, Clone, Debug, PartialEq)] 5 | pub struct ClientboundPongResponse { 6 | pub time: u64, 7 | } 8 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/game/s_ping_request.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | use azalea_protocol_macros::ServerboundGamePacket; 3 | 4 | #[derive(AzBuf, Clone, Debug, PartialEq, ServerboundGamePacket)] 5 | pub struct ServerboundPingRequest { 6 | pub time: u64, 7 | } 8 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/game/s_rename_item.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | use azalea_protocol_macros::ServerboundGamePacket; 3 | 4 | #[derive(AzBuf, Clone, Debug, PartialEq, ServerboundGamePacket)] 5 | pub struct ServerboundRenameItem { 6 | pub name: String, 7 | } 8 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/game/c_clear_titles.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | use azalea_protocol_macros::ClientboundGamePacket; 3 | 4 | #[derive(AzBuf, ClientboundGamePacket, Clone, Debug, PartialEq)] 5 | pub struct ClientboundClearTitles { 6 | pub reset_times: bool, 7 | } 8 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/game/c_set_border_size.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | use azalea_protocol_macros::ClientboundGamePacket; 3 | 4 | #[derive(AzBuf, ClientboundGamePacket, Clone, Debug, PartialEq)] 5 | pub struct ClientboundSetBorderSize { 6 | pub size: f64, 7 | } 8 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/game/s_chat_command.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | use azalea_protocol_macros::ServerboundGamePacket; 3 | 4 | #[derive(AzBuf, Clone, Debug, PartialEq, ServerboundGamePacket)] 5 | pub struct ServerboundChatCommand { 6 | pub command: String, 7 | } 8 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/game/s_set_carried_item.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | use azalea_protocol_macros::ServerboundGamePacket; 3 | 4 | #[derive(AzBuf, Clone, Debug, PartialEq, ServerboundGamePacket)] 5 | pub struct ServerboundSetCarriedItem { 6 | pub slot: u16, 7 | } 8 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/status/c_pong_response.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | use azalea_protocol_macros::ClientboundStatusPacket; 3 | 4 | #[derive(AzBuf, ClientboundStatusPacket, Clone, Debug, PartialEq)] 5 | pub struct ClientboundPongResponse { 6 | pub time: u64, 7 | } 8 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/status/s_ping_request.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | use azalea_protocol_macros::ServerboundStatusPacket; 3 | 4 | #[derive(AzBuf, Clone, Debug, PartialEq, ServerboundStatusPacket)] 5 | pub struct ServerboundPingRequest { 6 | pub time: u64, 7 | } 8 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/game/c_player_combat_enter.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | use azalea_protocol_macros::ClientboundGamePacket; 3 | 4 | /// Unused in vanilla. 5 | #[derive(AzBuf, ClientboundGamePacket, Clone, Debug, PartialEq)] 6 | pub struct ClientboundPlayerCombatEnter; 7 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/game/s_chat_ack.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | use azalea_protocol_macros::ServerboundGamePacket; 3 | 4 | #[derive(AzBuf, Clone, Debug, PartialEq, ServerboundGamePacket)] 5 | pub struct ServerboundChatAck { 6 | #[var] 7 | pub messages: u32, 8 | } 9 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/game/s_lock_difficulty.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | use azalea_protocol_macros::ServerboundGamePacket; 3 | 4 | #[derive(AzBuf, Clone, Debug, PartialEq, ServerboundGamePacket)] 5 | pub struct ServerboundLockDifficulty { 6 | pub locked: bool, 7 | } 8 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/game/c_set_held_slot.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | use azalea_protocol_macros::ClientboundGamePacket; 3 | 4 | #[derive(AzBuf, ClientboundGamePacket, Clone, Debug, PartialEq)] 5 | pub struct ClientboundSetHeldSlot { 6 | #[var] 7 | pub slot: u32, 8 | } 9 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/game/s_select_trade.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | use azalea_protocol_macros::ServerboundGamePacket; 3 | 4 | #[derive(AzBuf, Clone, Debug, PartialEq, ServerboundGamePacket)] 5 | pub struct ServerboundSelectTrade { 6 | #[var] 7 | pub item: u32, 8 | } 9 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/game/c_block_changed_ack.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | use azalea_protocol_macros::ClientboundGamePacket; 3 | 4 | #[derive(AzBuf, ClientboundGamePacket, Clone, Debug, PartialEq)] 5 | pub struct ClientboundBlockChangedAck { 6 | #[var] 7 | pub seq: u32, 8 | } 9 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/game/c_ticking_step.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | use azalea_protocol_macros::ClientboundGamePacket; 3 | 4 | #[derive(AzBuf, ClientboundGamePacket, Clone, Debug, PartialEq)] 5 | pub struct ClientboundTickingStep { 6 | #[var] 7 | pub tick_steps: u32, 8 | } 9 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/config/c_code_of_conduct.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | use azalea_protocol_macros::ClientboundConfigPacket; 3 | 4 | #[derive(AzBuf, ClientboundConfigPacket, Clone, Debug, PartialEq)] 5 | pub struct ClientboundCodeOfConduct { 6 | pub code_of_conduct: String, 7 | } 8 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/game/s_paddle_boat.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | use azalea_protocol_macros::ServerboundGamePacket; 3 | 4 | #[derive(AzBuf, Clone, Debug, PartialEq, ServerboundGamePacket)] 5 | pub struct ServerboundPaddleBoat { 6 | pub left: bool, 7 | pub right: bool, 8 | } 9 | -------------------------------------------------------------------------------- /azalea-brigadier/src/context/suggestion_context.rs: -------------------------------------------------------------------------------- 1 | use std::sync::Arc; 2 | 3 | use parking_lot::RwLock; 4 | 5 | use crate::tree::CommandNode; 6 | 7 | #[derive(Debug)] 8 | pub struct SuggestionContext { 9 | pub parent: Arc>>, 10 | pub start_pos: usize, 11 | } 12 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/game/c_container_close.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | use azalea_protocol_macros::ClientboundGamePacket; 3 | 4 | #[derive(AzBuf, ClientboundGamePacket, Clone, Debug, PartialEq)] 5 | pub struct ClientboundContainerClose { 6 | #[var] 7 | pub container_id: i32, 8 | } 9 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/game/s_accept_teleportation.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | use azalea_protocol_macros::ServerboundGamePacket; 3 | 4 | #[derive(AzBuf, Clone, Debug, PartialEq, ServerboundGamePacket)] 5 | pub struct ServerboundAcceptTeleportation { 6 | #[var] 7 | pub id: u32, 8 | } 9 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/game/s_chat_preview.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | use azalea_protocol_macros::ServerboundGamePacket; 3 | 4 | #[derive(AzBuf, Clone, Debug, PartialEq, ServerboundGamePacket)] 5 | pub struct ServerboundChatPreview { 6 | pub query_id: i32, 7 | pub query: String, 8 | } 9 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/game/s_container_close.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | use azalea_protocol_macros::ServerboundGamePacket; 3 | 4 | #[derive(AzBuf, Clone, Debug, PartialEq, ServerboundGamePacket)] 5 | pub struct ServerboundContainerClose { 6 | #[var] 7 | pub container_id: i32, 8 | } 9 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/game/s_pick_item_from_block.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | use azalea_protocol_macros::ServerboundGamePacket; 3 | 4 | #[derive(AzBuf, Clone, Debug, PartialEq, ServerboundGamePacket)] 5 | pub struct ServerboundPickItemFromBlock { 6 | #[var] 7 | pub slot: u32, 8 | } 9 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/game/s_teleport_to_entity.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | use azalea_protocol_macros::ServerboundGamePacket; 3 | use uuid::Uuid; 4 | 5 | #[derive(AzBuf, Clone, Debug, PartialEq, ServerboundGamePacket)] 6 | pub struct ServerboundTeleportToEntity { 7 | pub uuid: Uuid, 8 | } 9 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/config/c_show_dialog.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | use azalea_protocol_macros::ClientboundConfigPacket; 3 | use simdnbt::owned::Nbt; 4 | 5 | #[derive(AzBuf, ClientboundConfigPacket, Clone, Debug, PartialEq)] 6 | pub struct ClientboundShowDialog { 7 | pub dialog: Nbt, 8 | } 9 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/game/c_chunk_batch_finished.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | use azalea_protocol_macros::ClientboundGamePacket; 3 | 4 | #[derive(AzBuf, ClientboundGamePacket, Clone, Debug, PartialEq)] 5 | pub struct ClientboundChunkBatchFinished { 6 | #[var] 7 | pub batch_size: u32, 8 | } 9 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/game/c_recipe_book_remove.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | use azalea_protocol_macros::ClientboundGamePacket; 3 | 4 | #[derive(AzBuf, ClientboundGamePacket, Clone, Debug, PartialEq)] 5 | pub struct ClientboundRecipeBookRemove { 6 | #[var] 7 | pub recipes: Vec, 8 | } 9 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/game/c_resource_pack_pop.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | use azalea_protocol_macros::ClientboundGamePacket; 3 | use uuid::Uuid; 4 | 5 | #[derive(AzBuf, ClientboundGamePacket, Clone, Debug, PartialEq)] 6 | pub struct ClientboundResourcePackPop { 7 | pub id: Option, 8 | } 9 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/game/c_set_chunk_cache_radius.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | use azalea_protocol_macros::ClientboundGamePacket; 3 | 4 | #[derive(AzBuf, ClientboundGamePacket, Clone, Debug, PartialEq)] 5 | pub struct ClientboundSetChunkCacheRadius { 6 | #[var] 7 | pub radius: u32, 8 | } 9 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/game/c_ticking_state.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | use azalea_protocol_macros::ClientboundGamePacket; 3 | 4 | #[derive(AzBuf, ClientboundGamePacket, Clone, Debug, PartialEq)] 5 | pub struct ClientboundTickingState { 6 | pub tick_rate: f32, 7 | pub is_frozen: bool, 8 | } 9 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/game/s_chunk_batch_received.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | use azalea_protocol_macros::ServerboundGamePacket; 3 | 4 | #[derive(AzBuf, Clone, Debug, PartialEq, ServerboundGamePacket)] 5 | pub struct ServerboundChunkBatchReceived { 6 | pub desired_chunks_per_tick: f32, 7 | } 8 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/login/s_key.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | use azalea_protocol_macros::ServerboundLoginPacket; 3 | 4 | #[derive(AzBuf, Clone, Debug, PartialEq, ServerboundLoginPacket)] 5 | pub struct ServerboundKey { 6 | pub key_bytes: Vec, 7 | pub encrypted_challenge: Vec, 8 | } 9 | -------------------------------------------------------------------------------- /azalea-brigadier/src/arguments/mod.rs: -------------------------------------------------------------------------------- 1 | mod argument_type; 2 | pub mod bool_argument_type; 3 | pub mod double_argument_type; 4 | pub mod float_argument_type; 5 | pub mod integer_argument_type; 6 | pub mod long_argument_type; 7 | pub mod string_argument_type; 8 | 9 | pub use argument_type::ArgumentType; 10 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/config/c_resource_pack_pop.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | use azalea_protocol_macros::ClientboundConfigPacket; 3 | use uuid::Uuid; 4 | 5 | #[derive(AzBuf, ClientboundConfigPacket, Clone, Debug, PartialEq)] 6 | pub struct ClientboundResourcePackPop { 7 | pub id: Option, 8 | } 9 | -------------------------------------------------------------------------------- /azalea-core/src/sound.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | use azalea_registry::identifier::Identifier; 3 | use serde::Serialize; 4 | 5 | #[derive(AzBuf, Clone, Debug, simdnbt::Deserialize, PartialEq, Serialize)] 6 | pub struct CustomSound { 7 | pub sound_id: Identifier, 8 | pub range: Option, 9 | } 10 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/game/c_disconnect.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | use azalea_chat::FormattedText; 3 | use azalea_protocol_macros::ClientboundGamePacket; 4 | 5 | #[derive(AzBuf, ClientboundGamePacket, Clone, Debug, PartialEq)] 6 | pub struct ClientboundDisconnect { 7 | pub reason: FormattedText, 8 | } 9 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/game/c_player_info_remove.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | use azalea_protocol_macros::ClientboundGamePacket; 3 | use uuid::Uuid; 4 | 5 | #[derive(AzBuf, ClientboundGamePacket, Clone, Debug, PartialEq)] 6 | pub struct ClientboundPlayerInfoRemove { 7 | pub profile_ids: Vec, 8 | } 9 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/game/c_reset_score.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | use azalea_protocol_macros::ClientboundGamePacket; 3 | 4 | #[derive(AzBuf, ClientboundGamePacket, Clone, Debug, PartialEq)] 5 | pub struct ClientboundResetScore { 6 | pub owner: String, 7 | pub objective_name: Option, 8 | } 9 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/game/c_set_border_center.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | use azalea_protocol_macros::ClientboundGamePacket; 3 | 4 | #[derive(AzBuf, ClientboundGamePacket, Clone, Debug, PartialEq)] 5 | pub struct ClientboundSetBorderCenter { 6 | pub new_center_x: f64, 7 | pub new_center_z: f64, 8 | } 9 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/game/c_set_border_warning_delay.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | use azalea_protocol_macros::ClientboundGamePacket; 3 | 4 | #[derive(AzBuf, ClientboundGamePacket, Clone, Debug, PartialEq)] 5 | pub struct ClientboundSetBorderWarningDelay { 6 | #[var] 7 | pub warning_delay: u32, 8 | } 9 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/game/c_transfer.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | use azalea_protocol_macros::ClientboundGamePacket; 3 | 4 | #[derive(AzBuf, ClientboundGamePacket, Clone, Debug, PartialEq)] 5 | pub struct ClientboundTransfer { 6 | pub host: String, 7 | #[var] 8 | pub port: u32, 9 | } 10 | -------------------------------------------------------------------------------- /codegen/lib/code/language.py: -------------------------------------------------------------------------------- 1 | from lib.utils import get_dir_location 2 | import json 3 | 4 | LANGUAGE_DIR = get_dir_location("../azalea-language/src/en_us.json") 5 | 6 | 7 | def write_language(contents: dict): 8 | with open(LANGUAGE_DIR, "w") as f: 9 | f.write(json.dumps(contents, indent=" ")) 10 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/config/c_disconnect.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | use azalea_chat::FormattedText; 3 | use azalea_protocol_macros::ClientboundConfigPacket; 4 | 5 | #[derive(AzBuf, ClientboundConfigPacket, Clone, Debug, PartialEq)] 6 | pub struct ClientboundDisconnect { 7 | pub reason: FormattedText, 8 | } 9 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/config/c_transfer.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | use azalea_protocol_macros::ClientboundConfigPacket; 3 | 4 | #[derive(AzBuf, ClientboundConfigPacket, Clone, Debug, PartialEq)] 5 | pub struct ClientboundTransfer { 6 | pub host: String, 7 | #[var] 8 | pub port: u32, 9 | } 10 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/game/c_set_border_warning_distance.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | use azalea_protocol_macros::ClientboundGamePacket; 3 | 4 | #[derive(AzBuf, ClientboundGamePacket, Clone, Debug, PartialEq)] 5 | pub struct ClientboundSetBorderWarningDistance { 6 | #[var] 7 | pub warning_blocks: u32, 8 | } 9 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/game/c_set_cursor_item.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | use azalea_inventory::ItemStack; 3 | use azalea_protocol_macros::ClientboundGamePacket; 4 | 5 | #[derive(AzBuf, ClientboundGamePacket, Clone, Debug, PartialEq)] 6 | pub struct ClientboundSetCursorItem { 7 | pub contents: ItemStack, 8 | } 9 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/game/c_set_simulation_distance.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | use azalea_protocol_macros::ClientboundGamePacket; 3 | 4 | #[derive(AzBuf, ClientboundGamePacket, Clone, Debug, PartialEq)] 5 | pub struct ClientboundSetSimulationDistance { 6 | #[var] 7 | pub simulation_distance: u32, 8 | } 9 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/game/c_set_title_text.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | use azalea_chat::FormattedText; 3 | use azalea_protocol_macros::ClientboundGamePacket; 4 | 5 | #[derive(AzBuf, ClientboundGamePacket, Clone, Debug, PartialEq)] 6 | pub struct ClientboundSetTitleText { 7 | pub text: FormattedText, 8 | } 9 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/game/c_update_tags.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | use azalea_protocol_macros::ClientboundGamePacket; 3 | 4 | use crate::common::tags::TagMap; 5 | 6 | #[derive(AzBuf, ClientboundGamePacket, Clone, Debug, PartialEq)] 7 | pub struct ClientboundUpdateTags { 8 | pub tags: TagMap, 9 | } 10 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/game/c_forget_level_chunk.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | use azalea_core::position::ChunkPos; 3 | use azalea_protocol_macros::ClientboundGamePacket; 4 | 5 | #[derive(AzBuf, ClientboundGamePacket, Clone, Debug, PartialEq)] 6 | pub struct ClientboundForgetLevelChunk { 7 | pub pos: ChunkPos, 8 | } 9 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/game/c_set_action_bar_text.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | use azalea_chat::FormattedText; 3 | use azalea_protocol_macros::ClientboundGamePacket; 4 | 5 | #[derive(AzBuf, ClientboundGamePacket, Clone, Debug, PartialEq)] 6 | pub struct ClientboundSetActionBarText { 7 | pub text: FormattedText, 8 | } 9 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/game/c_set_subtitle_text.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | use azalea_chat::FormattedText; 3 | use azalea_protocol_macros::ClientboundGamePacket; 4 | 5 | #[derive(AzBuf, ClientboundGamePacket, Clone, Debug, PartialEq)] 6 | pub struct ClientboundSetSubtitleText { 7 | pub text: FormattedText, 8 | } 9 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/game/s_change_game_mode.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | use azalea_core::game_type::GameMode; 3 | use azalea_protocol_macros::ServerboundGamePacket; 4 | 5 | #[derive(AzBuf, Clone, Debug, PartialEq, ServerboundGamePacket)] 6 | pub struct ServerboundChangeGameMode { 7 | pub mode: GameMode, 8 | } 9 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/config/c_update_tags.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | use azalea_protocol_macros::ClientboundConfigPacket; 3 | 4 | use crate::common::tags::TagMap; 5 | 6 | #[derive(AzBuf, ClientboundConfigPacket, Clone, Debug, PartialEq)] 7 | pub struct ClientboundUpdateTags { 8 | pub tags: TagMap, 9 | } 10 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/game/c_cookie_request.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | use azalea_registry::identifier::Identifier; 3 | use azalea_protocol_macros::ClientboundGamePacket; 4 | 5 | #[derive(AzBuf, ClientboundGamePacket, Clone, Debug, PartialEq)] 6 | pub struct ClientboundCookieRequest { 7 | pub key: Identifier, 8 | } 9 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/login/c_cookie_request.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | use azalea_registry::identifier::Identifier; 3 | use azalea_protocol_macros::ClientboundLoginPacket; 4 | 5 | #[derive(AzBuf, ClientboundLoginPacket, Clone, Debug, PartialEq)] 6 | pub struct ClientboundCookieRequest { 7 | pub key: Identifier, 8 | } 9 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/config/c_cookie_request.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | use azalea_registry::identifier::Identifier; 3 | use azalea_protocol_macros::ClientboundConfigPacket; 4 | 5 | #[derive(AzBuf, ClientboundConfigPacket, Clone, Debug, PartialEq)] 6 | pub struct ClientboundCookieRequest { 7 | pub key: Identifier, 8 | } 9 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/game/c_open_book.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | use azalea_protocol_macros::ClientboundGamePacket; 3 | 4 | use super::s_interact::InteractionHand; 5 | 6 | #[derive(AzBuf, ClientboundGamePacket, Clone, Debug, PartialEq)] 7 | pub struct ClientboundOpenBook { 8 | pub hand: InteractionHand, 9 | } 10 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/game/c_set_time.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | use azalea_protocol_macros::ClientboundGamePacket; 3 | 4 | #[derive(AzBuf, ClientboundGamePacket, Clone, Debug, PartialEq)] 5 | pub struct ClientboundSetTime { 6 | pub game_time: u64, 7 | pub day_time: u64, 8 | pub tick_day_time: bool, 9 | } 10 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/game/s_change_difficulty.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | use azalea_core::difficulty::Difficulty; 3 | use azalea_protocol_macros::ServerboundGamePacket; 4 | 5 | #[derive(AzBuf, Clone, Debug, PartialEq, ServerboundGamePacket)] 6 | pub struct ServerboundChangeDifficulty { 7 | pub difficulty: Difficulty, 8 | } 9 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/game/s_command_suggestion.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | use azalea_protocol_macros::ServerboundGamePacket; 3 | 4 | #[derive(AzBuf, Clone, Debug, PartialEq, ServerboundGamePacket)] 5 | pub struct ServerboundCommandSuggestion { 6 | #[var] 7 | pub id: u32, 8 | pub command: String, 9 | } 10 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/game/s_swing.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | use azalea_protocol_macros::ServerboundGamePacket; 3 | 4 | use crate::packets::game::s_interact::InteractionHand; 5 | 6 | #[derive(AzBuf, Clone, Debug, PartialEq, ServerboundGamePacket)] 7 | pub struct ServerboundSwing { 8 | pub hand: InteractionHand, 9 | } 10 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/login/c_login_finished.rs: -------------------------------------------------------------------------------- 1 | use azalea_auth::game_profile::GameProfile; 2 | use azalea_buf::AzBuf; 3 | use azalea_protocol_macros::ClientboundLoginPacket; 4 | 5 | #[derive(AzBuf, ClientboundLoginPacket, Clone, Debug, PartialEq)] 6 | pub struct ClientboundLoginFinished { 7 | pub game_profile: GameProfile, 8 | } 9 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/config/c_custom_report_details.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | use azalea_protocol_macros::ClientboundConfigPacket; 3 | use indexmap::IndexMap; 4 | 5 | #[derive(AzBuf, ClientboundConfigPacket, Clone, Debug, PartialEq)] 6 | pub struct ClientboundCustomReportDetails { 7 | pub details: IndexMap, 8 | } 9 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/game/c_set_chunk_cache_center.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | use azalea_protocol_macros::ClientboundGamePacket; 3 | 4 | #[derive(AzBuf, ClientboundGamePacket, Clone, Debug, PartialEq)] 5 | pub struct ClientboundSetChunkCacheCenter { 6 | #[var] 7 | pub x: i32, 8 | #[var] 9 | pub z: i32, 10 | } 11 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/game/c_set_health.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | use azalea_protocol_macros::ClientboundGamePacket; 3 | 4 | #[derive(AzBuf, ClientboundGamePacket, Clone, Debug, PartialEq)] 5 | pub struct ClientboundSetHealth { 6 | pub health: f32, 7 | #[var] 8 | pub food: u32, 9 | pub saturation: f32, 10 | } 11 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/game/c_set_titles_animation.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | use azalea_protocol_macros::ClientboundGamePacket; 3 | 4 | #[derive(AzBuf, ClientboundGamePacket, Clone, Debug, PartialEq)] 5 | pub struct ClientboundSetTitlesAnimation { 6 | pub fade_in: u32, 7 | pub stay: u32, 8 | pub fade_out: u32, 9 | } 10 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/game/s_recipe_book_seen_recipe.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | use azalea_registry::identifier::Identifier; 3 | use azalea_protocol_macros::ServerboundGamePacket; 4 | 5 | #[derive(AzBuf, Clone, Debug, PartialEq, ServerboundGamePacket)] 6 | pub struct ServerboundRecipeBookSeenRecipe { 7 | pub recipe: Identifier, 8 | } 9 | -------------------------------------------------------------------------------- /azalea-brigadier/src/suggestion/suggestion_provider.rs: -------------------------------------------------------------------------------- 1 | use super::{Suggestions, SuggestionsBuilder}; 2 | use crate::context::CommandContext; 3 | 4 | pub trait SuggestionProvider { 5 | fn get_suggestions( 6 | &self, 7 | context: CommandContext, 8 | builder: SuggestionsBuilder, 9 | ) -> Suggestions; 10 | } 11 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/game/c_player_combat_end.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | use azalea_protocol_macros::ClientboundGamePacket; 3 | 4 | /// Unused by the client in vanilla. 5 | #[derive(AzBuf, ClientboundGamePacket, Clone, Debug, PartialEq)] 6 | pub struct ClientboundPlayerCombatEnd { 7 | #[var] 8 | pub duration: u32, 9 | } 10 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/game/c_set_camera.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | use azalea_protocol_macros::ClientboundGamePacket; 3 | use azalea_world::MinecraftEntityId; 4 | 5 | #[derive(AzBuf, ClientboundGamePacket, Clone, Debug, PartialEq)] 6 | pub struct ClientboundSetCamera { 7 | #[var] 8 | pub camera_id: MinecraftEntityId, 9 | } 10 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/game/c_select_advancements_tab.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | use azalea_registry::identifier::Identifier; 3 | use azalea_protocol_macros::ClientboundGamePacket; 4 | 5 | #[derive(AzBuf, ClientboundGamePacket, Clone, Debug, PartialEq)] 6 | pub struct ClientboundSelectAdvancementsTab { 7 | pub tab: Option, 8 | } 9 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/game/c_tag_query.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | use azalea_protocol_macros::ClientboundGamePacket; 3 | use simdnbt::owned::NbtTag; 4 | 5 | #[derive(AzBuf, ClientboundGamePacket, Clone, Debug, PartialEq)] 6 | pub struct ClientboundTagQuery { 7 | #[var] 8 | pub transaction_id: u32, 9 | pub tag: NbtTag, 10 | } 11 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/game/s_edit_book.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | use azalea_protocol_macros::ServerboundGamePacket; 3 | 4 | #[derive(AzBuf, Clone, Debug, PartialEq, ServerboundGamePacket)] 5 | pub struct ServerboundEditBook { 6 | #[var] 7 | pub slot: u32, 8 | pub pages: Vec, 9 | pub title: Option, 10 | } 11 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/game/s_move_player_status_only.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | use azalea_protocol_macros::ServerboundGamePacket; 3 | 4 | use crate::common::movements::MoveFlags; 5 | 6 | #[derive(AzBuf, Clone, Debug, PartialEq, ServerboundGamePacket)] 7 | pub struct ServerboundMovePlayerStatusOnly { 8 | pub flags: MoveFlags, 9 | } 10 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/game/s_set_beacon.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | use azalea_protocol_macros::ServerboundGamePacket; 3 | 4 | #[derive(AzBuf, Clone, Debug, PartialEq, ServerboundGamePacket)] 5 | pub struct ServerboundSetBeacon { 6 | #[var] 7 | pub primary: Option, 8 | #[var] 9 | pub secondary: Option, 10 | } 11 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/config/c_server_links.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | use azalea_protocol_macros::ClientboundConfigPacket; 3 | 4 | use crate::common::server_links::ServerLinkEntry; 5 | 6 | #[derive(AzBuf, ClientboundConfigPacket, Clone, Debug, PartialEq)] 7 | pub struct ClientboundServerLinks { 8 | pub links: Vec, 9 | } 10 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/config/c_update_enabled_features.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | use azalea_registry::identifier::Identifier; 3 | use azalea_protocol_macros::ClientboundConfigPacket; 4 | 5 | #[derive(AzBuf, ClientboundConfigPacket, Clone, Debug, PartialEq)] 6 | pub struct ClientboundUpdateEnabledFeatures { 7 | pub features: Vec, 8 | } 9 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/game/c_container_set_data.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | use azalea_protocol_macros::ClientboundGamePacket; 3 | 4 | #[derive(AzBuf, ClientboundGamePacket, Clone, Debug, PartialEq)] 5 | pub struct ClientboundContainerSetData { 6 | #[var] 7 | pub container_id: i32, 8 | pub id: u16, 9 | pub value: u16, 10 | } 11 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/game/c_delete_chat.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | use azalea_protocol_macros::ClientboundGamePacket; 3 | 4 | use super::c_player_chat::PackedMessageSignature; 5 | 6 | #[derive(AzBuf, ClientboundGamePacket, Clone, Debug, PartialEq)] 7 | pub struct ClientboundDeleteChat { 8 | pub signature: PackedMessageSignature, 9 | } 10 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/login/c_login_compression.rs: -------------------------------------------------------------------------------- 1 | use std::hash::Hash; 2 | 3 | use azalea_buf::AzBuf; 4 | use azalea_protocol_macros::ClientboundLoginPacket; 5 | 6 | #[derive(AzBuf, ClientboundLoginPacket, Clone, Debug, Hash, PartialEq)] 7 | pub struct ClientboundLoginCompression { 8 | #[var] 9 | pub compression_threshold: i32, 10 | } 11 | -------------------------------------------------------------------------------- /azalea-chat/src/lib.rs: -------------------------------------------------------------------------------- 1 | #![doc = include_str!("../README.md")] 2 | 3 | pub mod base_component; 4 | mod click_event; 5 | mod component; 6 | pub mod hover_event; 7 | #[cfg(feature = "numbers")] 8 | pub mod numbers; 9 | pub mod style; 10 | pub mod text_component; 11 | pub mod translatable_component; 12 | 13 | pub use component::{DEFAULT_STYLE, FormattedText}; 14 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/config/c_select_known_packs.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | use azalea_protocol_macros::ClientboundConfigPacket; 3 | 4 | use super::s_select_known_packs::KnownPack; 5 | 6 | #[derive(AzBuf, ClientboundConfigPacket, Clone, Debug, PartialEq)] 7 | pub struct ClientboundSelectKnownPacks { 8 | pub known_packs: Vec, 9 | } 10 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/game/c_cooldown.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | use azalea_protocol_macros::ClientboundGamePacket; 3 | use azalea_registry::builtin::ItemKind; 4 | 5 | #[derive(AzBuf, ClientboundGamePacket, Clone, Debug, PartialEq)] 6 | pub struct ClientboundCooldown { 7 | pub item: ItemKind, 8 | #[var] 9 | pub duration: u32, 10 | } 11 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/game/c_entity_event.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | use azalea_protocol_macros::ClientboundGamePacket; 3 | use azalea_world::MinecraftEntityId; 4 | 5 | #[derive(AzBuf, ClientboundGamePacket, Clone, Debug, PartialEq)] 6 | pub struct ClientboundEntityEvent { 7 | pub entity_id: MinecraftEntityId, 8 | pub event_id: u8, 9 | } 10 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/game/c_open_sign_editor.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | use azalea_core::position::BlockPos; 3 | use azalea_protocol_macros::ClientboundGamePacket; 4 | 5 | #[derive(AzBuf, ClientboundGamePacket, Clone, Debug, PartialEq)] 6 | pub struct ClientboundOpenSignEditor { 7 | pub pos: BlockPos, 8 | pub is_front_text: bool, 9 | } 10 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/game/c_remove_entities.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | use azalea_protocol_macros::ClientboundGamePacket; 3 | use azalea_world::MinecraftEntityId; 4 | 5 | #[derive(AzBuf, ClientboundGamePacket, Clone, Debug, PartialEq)] 6 | pub struct ClientboundRemoveEntities { 7 | #[var] 8 | pub entity_ids: Vec, 9 | } 10 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/game/c_server_data.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | use azalea_chat::FormattedText; 3 | use azalea_protocol_macros::ClientboundGamePacket; 4 | 5 | #[derive(AzBuf, ClientboundGamePacket, Clone, Debug, PartialEq)] 6 | pub struct ClientboundServerData { 7 | pub motd: FormattedText, 8 | pub icon_bytes: Option>, 9 | } 10 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/game/c_store_cookie.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | use azalea_registry::identifier::Identifier; 3 | use azalea_protocol_macros::ClientboundGamePacket; 4 | 5 | #[derive(AzBuf, ClientboundGamePacket, Clone, Debug, PartialEq)] 6 | pub struct ClientboundStoreCookie { 7 | pub key: Identifier, 8 | pub payload: Vec, 9 | } 10 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/game/s_bundle_item_selected.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | use azalea_protocol_macros::ServerboundGamePacket; 3 | 4 | #[derive(AzBuf, Clone, Debug, PartialEq, ServerboundGamePacket)] 5 | pub struct ServerboundBundleItemSelected { 6 | #[var] 7 | pub slot_id: i32, 8 | #[var] 9 | pub selected_item_index: u32, 10 | } 11 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/game/s_container_button_click.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | use azalea_protocol_macros::ServerboundGamePacket; 3 | 4 | #[derive(AzBuf, Clone, Debug, PartialEq, ServerboundGamePacket)] 5 | pub struct ServerboundContainerButtonClick { 6 | #[var] 7 | pub container_id: i32, 8 | #[var] 9 | pub button_id: u32, 10 | } 11 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/handshake/mod.rs: -------------------------------------------------------------------------------- 1 | // NOTE: This file is @generated automatically by codegen/packet.py. 2 | // Don't edit it directly! 3 | 4 | use azalea_protocol_macros::declare_state_packets; 5 | 6 | declare_state_packets!(HandshakePacket, 7 | Clientbound => [ 8 | ], 9 | Serverbound => [ 10 | intention, 11 | ] 12 | ); 13 | -------------------------------------------------------------------------------- /codegen/genlanguage.py: -------------------------------------------------------------------------------- 1 | import lib.code.language 2 | import lib.code.version 3 | import lib.code.utils 4 | import lib.download 5 | import lib.extract 6 | import lib.utils 7 | 8 | version_id = lib.code.version.get_version_id() 9 | language = lib.extract.get_en_us_lang(version_id) 10 | 11 | lib.code.language.write_language(language) 12 | 13 | print('Done!') 14 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/config/c_store_cookie.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | use azalea_registry::identifier::Identifier; 3 | use azalea_protocol_macros::ClientboundConfigPacket; 4 | 5 | #[derive(AzBuf, ClientboundConfigPacket, Clone, Debug, PartialEq)] 6 | pub struct ClientboundStoreCookie { 7 | pub key: Identifier, 8 | pub payload: Vec, 9 | } 10 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/game/c_debug_event.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | use azalea_protocol_macros::ClientboundGamePacket; 3 | 4 | use crate::common::debug_subscription::DebugSubscriptionEvent; 5 | 6 | #[derive(AzBuf, ClientboundGamePacket, Clone, Debug, PartialEq)] 7 | pub struct ClientboundDebugEvent { 8 | pub event: DebugSubscriptionEvent, 9 | } 10 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/game/c_player_rotation.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | use azalea_protocol_macros::ClientboundGamePacket; 3 | 4 | #[derive(AzBuf, ClientboundGamePacket, Clone, Debug, PartialEq)] 5 | pub struct ClientboundPlayerRotation { 6 | pub y_rot: f32, 7 | pub relative_y: bool, 8 | pub x_rot: f32, 9 | pub relative_x: bool, 10 | } 11 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/game/c_set_border_lerp_size.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | use azalea_protocol_macros::ClientboundGamePacket; 3 | 4 | #[derive(AzBuf, ClientboundGamePacket, Clone, Debug, PartialEq)] 5 | pub struct ClientboundSetBorderLerpSize { 6 | pub old_size: f64, 7 | pub new_size: f64, 8 | #[var] 9 | pub lerp_time: u64, 10 | } 11 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/game/c_change_difficulty.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | use azalea_core::difficulty::Difficulty; 3 | use azalea_protocol_macros::ClientboundGamePacket; 4 | 5 | #[derive(AzBuf, ClientboundGamePacket, Clone, Debug, PartialEq)] 6 | pub struct ClientboundChangeDifficulty { 7 | pub difficulty: Difficulty, 8 | pub locked: bool, 9 | } 10 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/game/c_hurt_animation.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | use azalea_protocol_macros::ClientboundGamePacket; 3 | use azalea_world::MinecraftEntityId; 4 | 5 | #[derive(AzBuf, ClientboundGamePacket, Clone, Debug, PartialEq)] 6 | pub struct ClientboundHurtAnimation { 7 | #[var] 8 | pub id: MinecraftEntityId, 9 | pub yaw: f32, 10 | } 11 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/game/c_show_dialog.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | use azalea_protocol_macros::ClientboundGamePacket; 3 | use azalea_registry::{Holder, data::Dialog}; 4 | use simdnbt::owned::Nbt; 5 | 6 | #[derive(AzBuf, ClientboundGamePacket, Clone, Debug, PartialEq)] 7 | pub struct ClientboundShowDialog { 8 | pub dialog: Holder, 9 | } 10 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/game/s_debug_subscription_request.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | use azalea_protocol_macros::ServerboundGamePacket; 3 | use azalea_registry::builtin::DebugSubscription; 4 | 5 | #[derive(AzBuf, Clone, Debug, PartialEq, ServerboundGamePacket)] 6 | pub struct ServerboundDebugSubscriptionRequest { 7 | pub subscriptions: Vec, 8 | } 9 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/game/s_set_command_minecart.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | use azalea_protocol_macros::ServerboundGamePacket; 3 | 4 | #[derive(AzBuf, Clone, Debug, PartialEq, ServerboundGamePacket)] 5 | pub struct ServerboundSetCommandMinecart { 6 | #[var] 7 | pub entity: u32, 8 | pub command: String, 9 | pub track_output: bool, 10 | } 11 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/game/s_set_creative_mode_slot.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | use azalea_inventory::ItemStack; 3 | use azalea_protocol_macros::ServerboundGamePacket; 4 | 5 | #[derive(AzBuf, Clone, Debug, PartialEq, ServerboundGamePacket)] 6 | pub struct ServerboundSetCreativeModeSlot { 7 | pub slot_num: u16, 8 | pub item_stack: ItemStack, 9 | } 10 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/game/c_respawn.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | use azalea_protocol_macros::ClientboundGamePacket; 3 | 4 | use crate::packets::common::CommonPlayerSpawnInfo; 5 | 6 | #[derive(AzBuf, ClientboundGamePacket, Clone, Debug, PartialEq)] 7 | pub struct ClientboundRespawn { 8 | pub common: CommonPlayerSpawnInfo, 9 | pub data_to_keep: u8, 10 | } 11 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/game/c_rotate_head.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | use azalea_protocol_macros::ClientboundGamePacket; 3 | use azalea_world::MinecraftEntityId; 4 | 5 | #[derive(AzBuf, ClientboundGamePacket, Clone, Debug, PartialEq)] 6 | pub struct ClientboundRotateHead { 7 | #[var] 8 | pub entity_id: MinecraftEntityId, 9 | pub y_head_rot: i8, 10 | } 11 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/game/c_set_player_inventory.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | use azalea_inventory::ItemStack; 3 | use azalea_protocol_macros::ClientboundGamePacket; 4 | 5 | #[derive(AzBuf, ClientboundGamePacket, Clone, Debug, PartialEq)] 6 | pub struct ClientboundSetPlayerInventory { 7 | #[var] 8 | pub slot: u32, 9 | pub contents: ItemStack, 10 | } 11 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/game/s_cookie_response.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | use azalea_registry::identifier::Identifier; 3 | use azalea_protocol_macros::ServerboundGamePacket; 4 | 5 | #[derive(AzBuf, Clone, Debug, PartialEq, ServerboundGamePacket)] 6 | pub struct ServerboundCookieResponse { 7 | pub key: Identifier, 8 | pub payload: Option>, 9 | } 10 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/login/s_cookie_response.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | use azalea_registry::identifier::Identifier; 3 | use azalea_protocol_macros::ServerboundLoginPacket; 4 | 5 | #[derive(AzBuf, Clone, Debug, PartialEq, ServerboundLoginPacket)] 6 | pub struct ServerboundCookieResponse { 7 | pub key: Identifier, 8 | pub payload: Option>, 9 | } 10 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/config/s_cookie_response.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | use azalea_registry::identifier::Identifier; 3 | use azalea_protocol_macros::ServerboundConfigPacket; 4 | 5 | #[derive(AzBuf, Clone, Debug, PartialEq, ServerboundConfigPacket)] 6 | pub struct ServerboundCookieResponse { 7 | pub key: Identifier, 8 | pub payload: Option>, 9 | } 10 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/game/c_set_entity_link.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | use azalea_protocol_macros::ClientboundGamePacket; 3 | use azalea_world::MinecraftEntityId; 4 | 5 | #[derive(AzBuf, ClientboundGamePacket, Clone, Debug, PartialEq)] 6 | pub struct ClientboundSetEntityLink { 7 | pub source_id: MinecraftEntityId, 8 | pub dest_id: MinecraftEntityId, 9 | } 10 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/game/s_client_information.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | use azalea_protocol_macros::ServerboundGamePacket; 3 | 4 | use crate::common::client_information::ClientInformation; 5 | 6 | #[derive(AzBuf, Clone, Debug, PartialEq, ServerboundGamePacket)] 7 | pub struct ServerboundClientInformation { 8 | pub client_information: ClientInformation, 9 | } 10 | -------------------------------------------------------------------------------- /azalea-auth/src/lib.rs: -------------------------------------------------------------------------------- 1 | #![doc = include_str!("../README.md")] 2 | 3 | #[cfg(feature = "online-mode")] 4 | mod auth; 5 | #[cfg(feature = "online-mode")] 6 | pub mod cache; 7 | #[cfg(feature = "online-mode")] 8 | pub mod certs; 9 | #[cfg(feature = "online-mode")] 10 | pub mod sessionserver; 11 | #[cfg(feature = "online-mode")] 12 | pub use auth::*; 13 | 14 | pub mod game_profile; 15 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/config/s_client_information.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | use azalea_protocol_macros::ServerboundConfigPacket; 3 | 4 | use crate::common::client_information::ClientInformation; 5 | 6 | #[derive(AzBuf, Clone, Debug, Eq, PartialEq, ServerboundConfigPacket)] 7 | pub struct ServerboundClientInformation { 8 | pub information: ClientInformation, 9 | } 10 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/game/c_game_test_highlight_pos.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | use azalea_core::position::BlockPos; 3 | use azalea_protocol_macros::ClientboundGamePacket; 4 | 5 | #[derive(AzBuf, ClientboundGamePacket, Clone, Debug, PartialEq)] 6 | pub struct ClientboundGameTestHighlightPos { 7 | pub absolute_pos: BlockPos, 8 | pub relative_pos: BlockPos, 9 | } 10 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/game/s_block_entity_tag_query.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | use azalea_core::position::BlockPos; 3 | use azalea_protocol_macros::ServerboundGamePacket; 4 | 5 | #[derive(AzBuf, Clone, Debug, PartialEq, ServerboundGamePacket)] 6 | pub struct ServerboundBlockEntityTagQuery { 7 | #[var] 8 | pub transaction_id: u32, 9 | pub pos: BlockPos, 10 | } 11 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/game/s_sign_update.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | use azalea_core::position::BlockPos; 3 | use azalea_protocol_macros::ServerboundGamePacket; 4 | 5 | #[derive(AzBuf, Clone, Debug, PartialEq, ServerboundGamePacket)] 6 | pub struct ServerboundSignUpdate { 7 | pub pos: BlockPos, 8 | pub is_front_text: bool, 9 | pub lines: [String; 4], 10 | } 11 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/game/c_block_update.rs: -------------------------------------------------------------------------------- 1 | use azalea_block::BlockState; 2 | use azalea_buf::AzBuf; 3 | use azalea_core::position::BlockPos; 4 | use azalea_protocol_macros::ClientboundGamePacket; 5 | 6 | #[derive(AzBuf, ClientboundGamePacket, Clone, Debug, PartialEq)] 7 | pub struct ClientboundBlockUpdate { 8 | pub pos: BlockPos, 9 | pub block_state: BlockState, 10 | } 11 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/game/c_projectile_power.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | use azalea_protocol_macros::ClientboundGamePacket; 3 | use azalea_world::MinecraftEntityId; 4 | 5 | #[derive(AzBuf, ClientboundGamePacket, Clone, Debug, PartialEq)] 6 | pub struct ClientboundProjectilePower { 7 | #[var] 8 | pub id: MinecraftEntityId, 9 | pub acceleration_power: f64, 10 | } 11 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/game/s_pick_item_from_entity.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | use azalea_protocol_macros::ServerboundGamePacket; 3 | use azalea_world::MinecraftEntityId; 4 | 5 | #[derive(AzBuf, Clone, Debug, PartialEq, ServerboundGamePacket)] 6 | pub struct ServerboundPickItemFromEntity { 7 | #[var] 8 | pub id: MinecraftEntityId, 9 | pub include_data: bool, 10 | } 11 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/game/c_custom_payload.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::{AzBuf, UnsizedByteArray}; 2 | use azalea_registry::identifier::Identifier; 3 | use azalea_protocol_macros::ClientboundGamePacket; 4 | 5 | #[derive(AzBuf, ClientboundGamePacket, Clone, Debug, PartialEq)] 6 | pub struct ClientboundCustomPayload { 7 | pub identifier: Identifier, 8 | pub data: UnsizedByteArray, 9 | } 10 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/game/c_move_vehicle.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | use azalea_core::position::Vec3; 3 | use azalea_entity::LookDirection; 4 | use azalea_protocol_macros::ClientboundGamePacket; 5 | 6 | #[derive(AzBuf, ClientboundGamePacket, Clone, Debug, PartialEq)] 7 | pub struct ClientboundMoveVehicle { 8 | pub pos: Vec3, 9 | pub look_direction: LookDirection, 10 | } 11 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/game/c_set_experience.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | use azalea_protocol_macros::ClientboundGamePacket; 3 | 4 | #[derive(AzBuf, ClientboundGamePacket, Clone, Debug, PartialEq)] 5 | pub struct ClientboundSetExperience { 6 | pub experience_progress: f32, 7 | #[var] 8 | pub experience_level: u32, 9 | #[var] 10 | pub total_experience: u32, 11 | } 12 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/game/s_custom_click_action.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | use azalea_registry::identifier::Identifier; 3 | use azalea_protocol_macros::ServerboundGamePacket; 4 | use simdnbt::owned::Nbt; 5 | 6 | #[derive(AzBuf, Clone, Debug, PartialEq, ServerboundGamePacket)] 7 | pub struct ServerboundCustomClickAction { 8 | pub id: Identifier, 9 | pub payload: Nbt, 10 | } 11 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/game/s_custom_payload.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::{AzBuf, UnsizedByteArray}; 2 | use azalea_registry::identifier::Identifier; 3 | use azalea_protocol_macros::ServerboundGamePacket; 4 | 5 | #[derive(AzBuf, Clone, Debug, PartialEq, ServerboundGamePacket)] 6 | pub struct ServerboundCustomPayload { 7 | pub identifier: Identifier, 8 | pub data: UnsizedByteArray, 9 | } 10 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/game/s_move_vehicle.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | use azalea_core::position::Vec3; 3 | use azalea_entity::LookDirection; 4 | use azalea_protocol_macros::ServerboundGamePacket; 5 | 6 | #[derive(AzBuf, Clone, Debug, PartialEq, ServerboundGamePacket)] 7 | pub struct ServerboundMoveVehicle { 8 | pub pos: Vec3, 9 | pub look_direction: LookDirection, 10 | } 11 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/config/c_custom_payload.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::{AzBuf, UnsizedByteArray}; 2 | use azalea_registry::identifier::Identifier; 3 | use azalea_protocol_macros::ClientboundConfigPacket; 4 | 5 | #[derive(AzBuf, ClientboundConfigPacket, Clone, Debug, PartialEq)] 6 | pub struct ClientboundCustomPayload { 7 | pub identifier: Identifier, 8 | pub data: UnsizedByteArray, 9 | } 10 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/config/s_custom_payload.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::{AzBuf, UnsizedByteArray}; 2 | use azalea_registry::identifier::Identifier; 3 | use azalea_protocol_macros::ServerboundConfigPacket; 4 | 5 | #[derive(AzBuf, Clone, Debug, PartialEq, ServerboundConfigPacket)] 6 | pub struct ServerboundCustomPayload { 7 | pub identifier: Identifier, 8 | pub data: UnsizedByteArray, 9 | } 10 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/game/c_set_default_spawn_position.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | use azalea_core::position::GlobalPos; 3 | use azalea_protocol_macros::ClientboundGamePacket; 4 | 5 | #[derive(AzBuf, ClientboundGamePacket, Clone, Debug, PartialEq)] 6 | pub struct ClientboundSetDefaultSpawnPosition { 7 | pub global_pos: GlobalPos, 8 | pub yaw: f32, 9 | pub pitch: f32, 10 | } 11 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/game/s_container_slot_state_changed.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | use azalea_protocol_macros::ServerboundGamePacket; 3 | 4 | #[derive(AzBuf, Clone, Debug, PartialEq, ServerboundGamePacket)] 5 | pub struct ServerboundContainerSlotStateChanged { 6 | #[var] 7 | pub slot_id: u32, 8 | #[var] 9 | pub container_id: i32, 10 | pub new_state: bool, 11 | } 12 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/game/s_jigsaw_generate.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | use azalea_core::position::BlockPos; 3 | use azalea_protocol_macros::ServerboundGamePacket; 4 | 5 | #[derive(AzBuf, Clone, Debug, PartialEq, ServerboundGamePacket)] 6 | pub struct ServerboundJigsawGenerate { 7 | pub pos: BlockPos, 8 | #[var] 9 | pub levels: u32, 10 | pub keep_jigsaws: bool, 11 | } 12 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/game/s_move_player_pos.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | use azalea_core::position::Vec3; 3 | use azalea_protocol_macros::ServerboundGamePacket; 4 | 5 | use crate::common::movements::MoveFlags; 6 | 7 | #[derive(AzBuf, Clone, Debug, PartialEq, ServerboundGamePacket)] 8 | pub struct ServerboundMovePlayerPos { 9 | pub pos: Vec3, 10 | pub flags: MoveFlags, 11 | } 12 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/login/c_hello.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | use azalea_protocol_macros::ClientboundLoginPacket; 3 | 4 | #[derive(AzBuf, ClientboundLoginPacket, Clone, Debug, PartialEq)] 5 | pub struct ClientboundHello { 6 | #[limit(20)] 7 | pub server_id: String, 8 | pub public_key: Vec, 9 | pub challenge: Vec, 10 | pub should_authenticate: bool, 11 | } 12 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/config/s_custom_click_action.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | use azalea_registry::identifier::Identifier; 3 | use azalea_protocol_macros::ServerboundConfigPacket; 4 | use simdnbt::owned::Nbt; 5 | 6 | #[derive(AzBuf, Clone, Debug, PartialEq, ServerboundConfigPacket)] 7 | pub struct ServerboundCustomClickAction { 8 | pub id: Identifier, 9 | pub payload: Nbt, 10 | } 11 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/game/c_level_event.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | use azalea_core::position::BlockPos; 3 | use azalea_protocol_macros::ClientboundGamePacket; 4 | 5 | #[derive(AzBuf, ClientboundGamePacket, Clone, Debug, PartialEq)] 6 | pub struct ClientboundLevelEvent { 7 | pub event_type: u32, 8 | pub pos: BlockPos, 9 | pub data: u32, 10 | pub global_event: bool, 11 | } 12 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/game/c_place_ghost_recipe.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | use azalea_protocol_macros::ClientboundGamePacket; 3 | 4 | use crate::common::recipe::RecipeDisplayData; 5 | 6 | #[derive(AzBuf, ClientboundGamePacket, Clone, Debug, PartialEq)] 7 | pub struct ClientboundPlaceGhostRecipe { 8 | #[var] 9 | pub container_id: i32, 10 | pub recipe: RecipeDisplayData, 11 | } 12 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/game/s_entity_tag_query.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | use azalea_protocol_macros::ServerboundGamePacket; 3 | use azalea_world::MinecraftEntityId; 4 | 5 | #[derive(AzBuf, Clone, Debug, PartialEq, ServerboundGamePacket)] 6 | pub struct ServerboundEntityTagQuery { 7 | #[var] 8 | pub transaction_id: u32, 9 | #[var] 10 | pub entity_id: MinecraftEntityId, 11 | } 12 | -------------------------------------------------------------------------------- /azalea-registry/README.md: -------------------------------------------------------------------------------- 1 | # `azalea-registry` 2 | 3 | Minecraft's registries are a system that give identifiers to certain enums the game. 4 | 5 | Some registries, defined in [`crate::builtin`], are static for the client and server. This includes blocks and items. 6 | 7 | Other registries, defined in [`crate::data`], are sent to us by the server. This includes things such as enchantments and biomes. 8 | 9 | -------------------------------------------------------------------------------- /azalea-language/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "azalea-language" 3 | description = "Translate Minecraft strings from their id." 4 | version.workspace = true 5 | edition.workspace = true 6 | license.workspace = true 7 | repository.workspace = true 8 | 9 | [dependencies] 10 | compact_str = { workspace = true, features = ["serde"] } 11 | serde_json.workspace = true 12 | 13 | [lints] 14 | workspace = true 15 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/game/s_place_recipe.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | use azalea_registry::identifier::Identifier; 3 | use azalea_protocol_macros::ServerboundGamePacket; 4 | 5 | #[derive(AzBuf, Clone, Debug, PartialEq, ServerboundGamePacket)] 6 | pub struct ServerboundPlaceRecipe { 7 | #[var] 8 | pub container_id: i32, 9 | pub recipe: Identifier, 10 | pub shift_down: bool, 11 | } 12 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/game/c_set_entity_motion.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | use azalea_core::delta::LpVec3; 3 | use azalea_protocol_macros::ClientboundGamePacket; 4 | use azalea_world::MinecraftEntityId; 5 | 6 | #[derive(AzBuf, ClientboundGamePacket, Clone, Debug, PartialEq)] 7 | pub struct ClientboundSetEntityMotion { 8 | #[var] 9 | pub id: MinecraftEntityId, 10 | pub delta: LpVec3, 11 | } 12 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/game/c_set_passengers.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | use azalea_protocol_macros::ClientboundGamePacket; 3 | use azalea_world::MinecraftEntityId; 4 | 5 | #[derive(AzBuf, ClientboundGamePacket, Clone, Debug, PartialEq)] 6 | pub struct ClientboundSetPassengers { 7 | #[var] 8 | pub vehicle: MinecraftEntityId, 9 | #[var] 10 | pub passengers: Vec, 11 | } 12 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/login/s_custom_query_answer.rs: -------------------------------------------------------------------------------- 1 | use std::hash::Hash; 2 | 3 | use azalea_buf::{AzBuf, UnsizedByteArray}; 4 | use azalea_protocol_macros::ServerboundLoginPacket; 5 | 6 | #[derive(AzBuf, Clone, Debug, Hash, PartialEq, ServerboundLoginPacket)] 7 | pub struct ServerboundCustomQueryAnswer { 8 | #[var] 9 | pub transaction_id: u32, 10 | pub data: Option, 11 | } 12 | -------------------------------------------------------------------------------- /azalea-block/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "azalea-block" 3 | description = "Representation of Minecraft block states." 4 | version.workspace = true 5 | edition.workspace = true 6 | license.workspace = true 7 | repository.workspace = true 8 | 9 | [dependencies] 10 | azalea-block-macros.workspace = true 11 | azalea-buf.workspace = true 12 | azalea-registry.workspace = true 13 | 14 | [lints] 15 | workspace = true 16 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/game/c_test_instance_block_status.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | use azalea_chat::FormattedText; 3 | use azalea_core::position::Vec3; 4 | use azalea_protocol_macros::ClientboundGamePacket; 5 | 6 | #[derive(AzBuf, ClientboundGamePacket, Clone, Debug, PartialEq)] 7 | pub struct ClientboundTestInstanceBlockStatus { 8 | pub status: FormattedText, 9 | pub size: Option, 10 | } 11 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/game/s_move_player_rot.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | use azalea_entity::LookDirection; 3 | use azalea_protocol_macros::ServerboundGamePacket; 4 | 5 | use crate::common::movements::MoveFlags; 6 | 7 | #[derive(AzBuf, Clone, Debug, PartialEq, ServerboundGamePacket)] 8 | pub struct ServerboundMovePlayerRot { 9 | pub look_direction: LookDirection, 10 | pub flags: MoveFlags, 11 | } 12 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/game/s_client_command.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | use azalea_protocol_macros::ServerboundGamePacket; 3 | 4 | #[derive(AzBuf, Clone, Debug, PartialEq, ServerboundGamePacket)] 5 | pub struct ServerboundClientCommand { 6 | pub action: Action, 7 | } 8 | 9 | #[derive(AzBuf, Clone, Copy, Debug, PartialEq)] 10 | pub enum Action { 11 | PerformRespawn = 0, 12 | RequestStats = 1, 13 | } 14 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/game/c_move_entity_rot.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | use azalea_protocol_macros::ClientboundGamePacket; 3 | use azalea_world::MinecraftEntityId; 4 | 5 | #[derive(AzBuf, ClientboundGamePacket, Clone, Debug, PartialEq)] 6 | pub struct ClientboundMoveEntityRot { 7 | #[var] 8 | pub entity_id: MinecraftEntityId, 9 | pub y_rot: i8, 10 | pub x_rot: i8, 11 | pub on_ground: bool, 12 | } 13 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/game/s_use_item.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | use azalea_protocol_macros::ServerboundGamePacket; 3 | 4 | use crate::packets::game::s_interact::InteractionHand; 5 | 6 | #[derive(AzBuf, Clone, Debug, PartialEq, ServerboundGamePacket)] 7 | pub struct ServerboundUseItem { 8 | pub hand: InteractionHand, 9 | #[var] 10 | pub seq: u32, 11 | pub y_rot: f32, 12 | pub x_rot: f32, 13 | } 14 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/game/c_remove_mob_effect.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | use azalea_protocol_macros::ClientboundGamePacket; 3 | use azalea_registry::builtin::MobEffect; 4 | use azalea_world::MinecraftEntityId; 5 | 6 | #[derive(AzBuf, ClientboundGamePacket, Clone, Debug, PartialEq)] 7 | pub struct ClientboundRemoveMobEffect { 8 | #[var] 9 | pub entity_id: MinecraftEntityId, 10 | pub effect: MobEffect, 11 | } 12 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/game/c_take_item_entity.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | use azalea_protocol_macros::ClientboundGamePacket; 3 | use azalea_world::MinecraftEntityId; 4 | 5 | #[derive(AzBuf, ClientboundGamePacket, Clone, Debug, PartialEq)] 6 | pub struct ClientboundTakeItemEntity { 7 | #[var] 8 | pub item_id: u32, 9 | #[var] 10 | pub player_id: MinecraftEntityId, 11 | #[var] 12 | pub amount: u32, 13 | } 14 | -------------------------------------------------------------------------------- /azalea-core/src/tick.rs: -------------------------------------------------------------------------------- 1 | use bevy_ecs::schedule::ScheduleLabel; 2 | 3 | /// A Bevy schedule that runs every Minecraft game tick, i.e. every 50ms. 4 | /// 5 | /// Many client systems run on this schedule, the most important one being 6 | /// physics. 7 | /// 8 | /// This schedule runs either zero or one times after every Bevy `Update`. 9 | #[derive(Clone, Copy, Debug, Default, Eq, Hash, PartialEq, ScheduleLabel)] 10 | pub struct GameTick; 11 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/config/c_registry_data.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | use azalea_registry::identifier::Identifier; 3 | use azalea_protocol_macros::ClientboundConfigPacket; 4 | use simdnbt::owned::NbtCompound; 5 | 6 | #[derive(AzBuf, ClientboundConfigPacket, Clone, Debug, PartialEq)] 7 | pub struct ClientboundRegistryData { 8 | pub registry_id: Identifier, 9 | pub entries: Vec<(Identifier, Option)>, 10 | } 11 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/game/c_mount_screen_open.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | use azalea_protocol_macros::ClientboundGamePacket; 3 | use azalea_world::MinecraftEntityId; 4 | 5 | #[derive(AzBuf, ClientboundGamePacket, Clone, Debug, PartialEq)] 6 | pub struct ClientboundMountScreenOpen { 7 | #[var] 8 | pub container_id: i32, 9 | #[var] 10 | pub inventory_columns: u32, 11 | pub entity_id: MinecraftEntityId, 12 | } 13 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/game/c_open_screen.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | use azalea_chat::FormattedText; 3 | use azalea_protocol_macros::ClientboundGamePacket; 4 | use azalea_registry::builtin::MenuKind; 5 | 6 | #[derive(AzBuf, ClientboundGamePacket, Clone, Debug, PartialEq)] 7 | pub struct ClientboundOpenScreen { 8 | #[var] 9 | pub container_id: i32, 10 | pub menu_type: MenuKind, 11 | pub title: FormattedText, 12 | } 13 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/status/mod.rs: -------------------------------------------------------------------------------- 1 | // NOTE: This file is @generated automatically by codegen/packet.py. 2 | // Don't edit it directly! 3 | 4 | use azalea_protocol_macros::declare_state_packets; 5 | 6 | declare_state_packets!(StatusPacket, 7 | Clientbound => [ 8 | status_response, 9 | pong_response, 10 | ], 11 | Serverbound => [ 12 | status_request, 13 | ping_request, 14 | ] 15 | ); 16 | -------------------------------------------------------------------------------- /azalea-block/azalea-block-macros/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "azalea-block-macros" 3 | description = "Proc macros used by azalea-block." 4 | version.workspace = true 5 | edition.workspace = true 6 | license.workspace = true 7 | repository.workspace = true 8 | 9 | [lib] 10 | proc-macro = true 11 | 12 | [dependencies] 13 | proc-macro2.workspace = true 14 | quote.workspace = true 15 | syn.workspace = true 16 | 17 | [lints] 18 | workspace = true 19 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/game/c_block_event.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | use azalea_core::position::BlockPos; 3 | use azalea_protocol_macros::ClientboundGamePacket; 4 | use azalea_registry::builtin::BlockKind; 5 | 6 | #[derive(AzBuf, ClientboundGamePacket, Clone, Debug, PartialEq)] 7 | pub struct ClientboundBlockEvent { 8 | pub pos: BlockPos, 9 | pub action_id: u8, 10 | pub action_parameter: u8, 11 | pub block: BlockKind, 12 | } 13 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/game/c_debug_block_value.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | use azalea_core::position::BlockPos; 3 | use azalea_protocol_macros::ClientboundGamePacket; 4 | 5 | use crate::common::debug_subscription::DebugSubscriptionUpdate; 6 | 7 | #[derive(AzBuf, ClientboundGamePacket, Clone, Debug, PartialEq)] 8 | pub struct ClientboundDebugBlockValue { 9 | pub block_pos: BlockPos, 10 | pub update: DebugSubscriptionUpdate, 11 | } 12 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/game/c_debug_chunk_value.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | use azalea_core::position::ChunkPos; 3 | use azalea_protocol_macros::ClientboundGamePacket; 4 | 5 | use crate::common::debug_subscription::DebugSubscriptionUpdate; 6 | 7 | #[derive(AzBuf, ClientboundGamePacket, Clone, Debug, PartialEq)] 8 | pub struct ClientboundDebugChunkValue { 9 | pub chunk_pos: ChunkPos, 10 | pub update: DebugSubscriptionUpdate, 11 | } 12 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/game/c_debug_sample.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | use azalea_protocol_macros::ClientboundGamePacket; 3 | 4 | #[derive(AzBuf, ClientboundGamePacket, Clone, Debug, PartialEq)] 5 | pub struct ClientboundDebugSample { 6 | pub sample: Vec, 7 | pub debug_sample_type: RemoteDebugSampleType, 8 | } 9 | 10 | #[derive(AzBuf, Clone, Copy, Debug, PartialEq)] 11 | pub enum RemoteDebugSampleType { 12 | TickTime, 13 | } 14 | -------------------------------------------------------------------------------- /azalea-brigadier/src/result_consumer.rs: -------------------------------------------------------------------------------- 1 | use std::rc::Rc; 2 | 3 | use crate::context::CommandContext; 4 | 5 | pub trait ResultConsumer { 6 | fn on_command_complete(&self, context: Rc>, success: bool, result: i32); 7 | } 8 | 9 | pub struct DefaultResultConsumer; 10 | impl ResultConsumer for DefaultResultConsumer { 11 | fn on_command_complete(&self, _context: Rc>, _success: bool, _result: i32) {} 12 | } 13 | -------------------------------------------------------------------------------- /azalea-buf/azalea-buf-macros/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "azalea-buf-macros" 3 | description = "#[derive(AzBuf)]" 4 | version.workspace = true 5 | edition.workspace = true 6 | license.workspace = true 7 | repository.workspace = true 8 | 9 | [lib] 10 | proc-macro = true 11 | 12 | [dependencies] 13 | proc-macro2.workspace = true 14 | quote.workspace = true 15 | syn = { workspace = true, features = ["extra-traits"] } 16 | 17 | [lints] 18 | workspace = true 19 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/game/c_debug_entity_value.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | use azalea_protocol_macros::ClientboundGamePacket; 3 | use azalea_world::MinecraftEntityId; 4 | 5 | use crate::common::debug_subscription::DebugSubscriptionUpdate; 6 | 7 | #[derive(AzBuf, ClientboundGamePacket, Clone, Debug, PartialEq)] 8 | pub struct ClientboundDebugEntityValue { 9 | pub entity_id: MinecraftEntityId, 10 | pub update: DebugSubscriptionUpdate, 11 | } 12 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/game/c_move_entity_pos.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | use azalea_core::delta::PositionDelta8; 3 | use azalea_protocol_macros::ClientboundGamePacket; 4 | use azalea_world::MinecraftEntityId; 5 | 6 | #[derive(AzBuf, ClientboundGamePacket, Clone, Debug, PartialEq)] 7 | pub struct ClientboundMoveEntityPos { 8 | #[var] 9 | pub entity_id: MinecraftEntityId, 10 | pub delta: PositionDelta8, 11 | pub on_ground: bool, 12 | } 13 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/game/c_resource_pack_push.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | use azalea_chat::FormattedText; 3 | use azalea_protocol_macros::ClientboundGamePacket; 4 | use uuid::Uuid; 5 | 6 | #[derive(AzBuf, ClientboundGamePacket, Clone, Debug, PartialEq)] 7 | pub struct ClientboundResourcePackPush { 8 | pub id: Uuid, 9 | pub url: String, 10 | pub hash: String, 11 | pub required: bool, 12 | pub prompt: Option, 13 | } 14 | -------------------------------------------------------------------------------- /azalea-world/src/lib.rs: -------------------------------------------------------------------------------- 1 | #![doc = include_str!("../README.md")] 2 | #![feature(error_generic_member_access)] 3 | 4 | mod bit_storage; 5 | pub mod chunk_storage; 6 | mod container; 7 | pub mod find_blocks; 8 | pub mod heightmap; 9 | pub mod iterators; 10 | pub mod palette; 11 | mod world; 12 | 13 | pub use bit_storage::BitStorage; 14 | pub use chunk_storage::{Chunk, ChunkStorage, PartialChunkStorage, Section}; 15 | pub use container::*; 16 | pub use world::*; 17 | -------------------------------------------------------------------------------- /azalea-inventory/azalea-inventory-macros/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "azalea-inventory-macros" 3 | description = "Internal macros for azalea-inventory." 4 | version.workspace = true 5 | edition.workspace = true 6 | license.workspace = true 7 | repository.workspace = true 8 | 9 | [lib] 10 | proc-macro = true 11 | 12 | [dependencies] 13 | proc-macro2.workspace = true 14 | quote.workspace = true 15 | syn.workspace = true 16 | 17 | [lints] 18 | workspace = true 19 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/config/c_resource_pack_push.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | use azalea_chat::FormattedText; 3 | use azalea_protocol_macros::ClientboundConfigPacket; 4 | use uuid::Uuid; 5 | 6 | #[derive(AzBuf, ClientboundConfigPacket, Clone, Debug, PartialEq)] 7 | pub struct ClientboundResourcePackPush { 8 | pub id: Uuid, 9 | pub url: String, 10 | pub hash: String, 11 | pub required: bool, 12 | pub prompt: Option, 13 | } 14 | -------------------------------------------------------------------------------- /azalea-registry/azalea-registry-macros/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "azalea-registry-macros" 3 | description = "Macros internally used in azalea-registry." 4 | version.workspace = true 5 | edition.workspace = true 6 | license.workspace = true 7 | repository.workspace = true 8 | 9 | [lib] 10 | proc-macro = true 11 | 12 | [dependencies] 13 | #proc-macro2.workspace = true 14 | quote.workspace = true 15 | syn.workspace = true 16 | 17 | [features] 18 | serde = [] 19 | -------------------------------------------------------------------------------- /azalea-protocol/azalea-protocol-macros/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "azalea-protocol-macros" 3 | description = "Macros internally used in azalea-protocol." 4 | version.workspace = true 5 | edition.workspace = true 6 | license.workspace = true 7 | repository.workspace = true 8 | 9 | [lib] 10 | proc-macro = true 11 | 12 | [dependencies] 13 | proc-macro2.workspace = true 14 | quote.workspace = true 15 | syn.workspace = true 16 | 17 | [lints] 18 | workspace = true 19 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/game/c_player_combat_kill.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | use azalea_chat::FormattedText; 3 | use azalea_protocol_macros::ClientboundGamePacket; 4 | use azalea_world::MinecraftEntityId; 5 | 6 | /// Used to send a respawn screen. 7 | #[derive(AzBuf, ClientboundGamePacket, Clone, Debug, PartialEq)] 8 | pub struct ClientboundPlayerCombatKill { 9 | #[var] 10 | pub player_id: MinecraftEntityId, 11 | pub message: FormattedText, 12 | } 13 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/config/s_select_known_packs.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | use azalea_protocol_macros::ServerboundConfigPacket; 3 | 4 | #[derive(AzBuf, Clone, Debug, PartialEq, ServerboundConfigPacket)] 5 | pub struct ServerboundSelectKnownPacks { 6 | pub known_packs: Vec, 7 | } 8 | 9 | #[derive(AzBuf, Clone, Debug, PartialEq)] 10 | pub struct KnownPack { 11 | pub namespace: String, 12 | pub id: String, 13 | pub version: String, 14 | } 15 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/game/c_block_entity_data.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | use azalea_core::position::BlockPos; 3 | use azalea_protocol_macros::ClientboundGamePacket; 4 | use azalea_registry::builtin::BlockEntityKind; 5 | use simdnbt::owned::Nbt; 6 | 7 | #[derive(AzBuf, ClientboundGamePacket, Clone, Debug, PartialEq)] 8 | pub struct ClientboundBlockEntityData { 9 | pub pos: BlockPos, 10 | pub block_entity_type: BlockEntityKind, 11 | pub tag: Nbt, 12 | } 13 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/game/c_custom_chat_completions.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | use azalea_protocol_macros::ClientboundGamePacket; 3 | 4 | #[derive(AzBuf, ClientboundGamePacket, Clone, Debug, PartialEq)] 5 | pub struct ClientboundCustomChatCompletions { 6 | pub action: Action, 7 | pub entries: Vec, 8 | } 9 | 10 | #[derive(AzBuf, Clone, Copy, Debug, PartialEq)] 11 | pub enum Action { 12 | Add = 0, 13 | Remove = 1, 14 | Set = 2, 15 | } 16 | -------------------------------------------------------------------------------- /codegen/genpackets.py: -------------------------------------------------------------------------------- 1 | import lib.code.version 2 | import lib.code.packet 3 | import lib.code.utils 4 | import lib.download 5 | import lib.extract 6 | 7 | def generate(): 8 | version_id = lib.code.version.get_version_id() 9 | packets_report = lib.extract.get_packets_report(version_id) 10 | 11 | lib.code.packet.set_packets(packets_report) 12 | 13 | lib.code.utils.fmt() 14 | 15 | print('Done!') 16 | 17 | if __name__ == '__main__': 18 | generate() 19 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/login/c_custom_query.rs: -------------------------------------------------------------------------------- 1 | use std::hash::Hash; 2 | 3 | use azalea_buf::{AzBuf, UnsizedByteArray}; 4 | use azalea_registry::identifier::Identifier; 5 | use azalea_protocol_macros::ClientboundLoginPacket; 6 | 7 | #[derive(AzBuf, ClientboundLoginPacket, Clone, Debug, Hash, PartialEq)] 8 | pub struct ClientboundCustomQuery { 9 | #[var] 10 | pub transaction_id: u32, 11 | pub identifier: Identifier, 12 | pub data: UnsizedByteArray, 13 | } 14 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/game/c_player_position.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | use azalea_protocol_macros::ClientboundGamePacket; 3 | 4 | use crate::common::movements::{PositionMoveRotation, RelativeMovements}; 5 | 6 | #[derive(AzBuf, ClientboundGamePacket, Clone, Debug, PartialEq)] 7 | pub struct ClientboundPlayerPosition { 8 | /// The teleport ID. 9 | #[var] 10 | pub id: u32, 11 | pub change: PositionMoveRotation, 12 | pub relative: RelativeMovements, 13 | } 14 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/game/s_move_player_pos_rot.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | use azalea_core::position::Vec3; 3 | use azalea_entity::LookDirection; 4 | use azalea_protocol_macros::ServerboundGamePacket; 5 | 6 | use crate::common::movements::MoveFlags; 7 | 8 | #[derive(AzBuf, Clone, Debug, PartialEq, ServerboundGamePacket)] 9 | pub struct ServerboundMovePlayerPosRot { 10 | pub pos: Vec3, 11 | pub look_direction: LookDirection, 12 | pub flags: MoveFlags, 13 | } 14 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/handshake/s_intention.rs: -------------------------------------------------------------------------------- 1 | use std::hash::Hash; 2 | 3 | use azalea_buf::AzBuf; 4 | use azalea_protocol_macros::ServerboundHandshakePacket; 5 | 6 | use crate::packets::ClientIntention; 7 | 8 | #[derive(AzBuf, Clone, Debug, Hash, PartialEq, ServerboundHandshakePacket)] 9 | pub struct ServerboundIntention { 10 | #[var] 11 | pub protocol_version: i32, 12 | pub hostname: String, 13 | pub port: u16, 14 | pub intention: ClientIntention, 15 | } 16 | -------------------------------------------------------------------------------- /azalea-registry/src/tags/fluids.rs: -------------------------------------------------------------------------------- 1 | // This file was @generated by codegen/lib/code/tags.py, don't edit it manually! 2 | 3 | use std::sync::LazyLock; 4 | 5 | use crate::{builtin::Fluid, tags::RegistryTag}; 6 | 7 | pub static LAVA: LazyLock> = 8 | LazyLock::new(|| RegistryTag::new(vec![Fluid::FlowingLava, Fluid::Lava])); 9 | pub static WATER: LazyLock> = 10 | LazyLock::new(|| RegistryTag::new(vec![Fluid::FlowingWater, Fluid::Water])); 11 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/game/c_chunks_biomes.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | use azalea_core::position::ChunkPos; 3 | use azalea_protocol_macros::ClientboundGamePacket; 4 | 5 | #[derive(AzBuf, ClientboundGamePacket, Clone, Debug, PartialEq)] 6 | pub struct ClientboundChunksBiomes { 7 | pub chunk_biome_data: Vec, 8 | } 9 | 10 | #[derive(AzBuf, Clone, Debug, PartialEq)] 11 | pub struct ChunkBiomeData { 12 | pub pos: ChunkPos, 13 | pub buffer: Vec, 14 | } 15 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/game/c_entity_position_sync.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | use azalea_protocol_macros::ClientboundGamePacket; 3 | use azalea_world::MinecraftEntityId; 4 | 5 | use crate::common::movements::PositionMoveRotation; 6 | 7 | #[derive(AzBuf, ClientboundGamePacket, Clone, Debug, PartialEq)] 8 | pub struct ClientboundEntityPositionSync { 9 | #[var] 10 | pub id: MinecraftEntityId, 11 | pub values: PositionMoveRotation, 12 | pub on_ground: bool, 13 | } 14 | -------------------------------------------------------------------------------- /azalea-buf/README.md: -------------------------------------------------------------------------------- 1 | # `azalea-buf` 2 | 3 | An implementation of Minecraft's `FriendlyByteBuf`. This is used frequently in the game for serialization and deserialization of data. 4 | 5 | Note that there are some minor implementation differences such as using unsigned integers in places where Minecraft uses signed integers. This doesn't cause issues normally, but does technically make usage of azalea-buf detectable if a server really wants to since it won't error in places where vanilla Minecraft would. 6 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/game/c_set_score.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | use azalea_chat::{numbers::NumberFormat, FormattedText}; 3 | use azalea_protocol_macros::ClientboundGamePacket; 4 | 5 | #[derive(AzBuf, ClientboundGamePacket, Clone, Debug, PartialEq)] 6 | pub struct ClientboundSetScore { 7 | pub owner: String, 8 | pub objective_name: String, 9 | #[var] 10 | pub score: u32, 11 | pub display: Option, 12 | pub number_format: Option, 13 | } 14 | -------------------------------------------------------------------------------- /azalea-auth/examples/auth.rs: -------------------------------------------------------------------------------- 1 | use std::path::PathBuf; 2 | 3 | #[tokio::main] 4 | async fn main() { 5 | env_logger::init(); 6 | 7 | let cache_file = PathBuf::from("example_cache.json"); 8 | 9 | let auth_result = azalea_auth::auth( 10 | "example@example.com", 11 | azalea_auth::AuthOpts { 12 | cache_file: Some(cache_file), 13 | ..Default::default() 14 | }, 15 | ) 16 | .await 17 | .unwrap(); 18 | println!("{auth_result:?}"); 19 | } 20 | -------------------------------------------------------------------------------- /azalea-brigadier/src/context/mod.rs: -------------------------------------------------------------------------------- 1 | mod command_context; 2 | mod command_context_builder; 3 | mod context_chain; 4 | mod parsed_argument; 5 | mod parsed_command_node; 6 | mod string_range; 7 | pub mod suggestion_context; 8 | 9 | pub use command_context::CommandContext; 10 | pub use command_context_builder::CommandContextBuilder; 11 | pub use context_chain::ContextChain; 12 | pub use parsed_argument::ParsedArgument; 13 | pub use parsed_command_node::ParsedCommandNode; 14 | pub use string_range::StringRange; 15 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/game/c_update_mob_effect.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | use azalea_entity::MobEffectData; 3 | use azalea_protocol_macros::ClientboundGamePacket; 4 | use azalea_registry::builtin::MobEffect; 5 | use azalea_world::MinecraftEntityId; 6 | 7 | #[derive(AzBuf, ClientboundGamePacket, Clone, Debug, PartialEq)] 8 | pub struct ClientboundUpdateMobEffect { 9 | #[var] 10 | pub entity_id: MinecraftEntityId, 11 | pub mob_effect: MobEffect, 12 | pub data: MobEffectData, 13 | } 14 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .idea/ 2 | .vscode/ 3 | doc/ 4 | target/ 5 | rustc-ice-* 6 | 7 | # created by azalea-auth/examples/auth, defined in the main .gitignore because 8 | # the example could be run from anywhere 9 | example_cache.json 10 | 11 | # not created by azalea itself, sometimes used for debugging since the docs specifically mentions using azalea.log 12 | azalea.log 13 | 14 | # these are created by profiling tools 15 | flamegraph.svg 16 | perf.data 17 | perf.data.old 18 | heaptrack.* 19 | *.mm_profdata 20 | chrome_profiler.json 21 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/game/c_custom_report_details.rs: -------------------------------------------------------------------------------- 1 | use std::collections::HashMap; 2 | 3 | use azalea_buf::AzBuf; 4 | use azalea_protocol_macros::ClientboundGamePacket; 5 | 6 | #[derive(AzBuf, ClientboundGamePacket, Clone, Debug, PartialEq)] 7 | pub struct ClientboundCustomReportDetails { 8 | // azalea doesn't implement max lengths yet 9 | 10 | // max length = 32 11 | // key string is limited to 128 bytes 12 | // value string is limited to 4096 bytes 13 | pub details: HashMap, 14 | } 15 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/game/c_teleport_entity.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | use azalea_protocol_macros::ClientboundGamePacket; 3 | use azalea_world::MinecraftEntityId; 4 | 5 | use crate::common::movements::{PositionMoveRotation, RelativeMovements}; 6 | 7 | #[derive(AzBuf, ClientboundGamePacket, Clone, Debug, PartialEq)] 8 | pub struct ClientboundTeleportEntity { 9 | #[var] 10 | pub id: MinecraftEntityId, 11 | pub change: PositionMoveRotation, 12 | pub relative: RelativeMovements, 13 | pub on_ground: bool, 14 | } 15 | -------------------------------------------------------------------------------- /azalea-brigadier/src/context/parsed_command_node.rs: -------------------------------------------------------------------------------- 1 | use std::sync::Arc; 2 | 3 | use parking_lot::RwLock; 4 | 5 | use super::string_range::StringRange; 6 | use crate::tree::CommandNode; 7 | 8 | #[derive(Debug)] 9 | pub struct ParsedCommandNode { 10 | pub node: Arc>>, 11 | pub range: StringRange, 12 | } 13 | 14 | impl Clone for ParsedCommandNode { 15 | fn clone(&self) -> Self { 16 | Self { 17 | node: self.node.clone(), 18 | range: self.range, 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/game/c_block_destruction.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | use azalea_core::position::BlockPos; 3 | use azalea_protocol_macros::ClientboundGamePacket; 4 | use azalea_world::MinecraftEntityId; 5 | 6 | #[derive(AzBuf, ClientboundGamePacket, Clone, Debug, PartialEq)] 7 | pub struct ClientboundBlockDestruction { 8 | /// The ID of the entity breaking the block. 9 | #[var] 10 | pub id: MinecraftEntityId, 11 | pub pos: BlockPos, 12 | /// 0–9 to set it, any other value to remove it. 13 | pub progress: u8, 14 | } 15 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/game/s_recipe_book_change_settings.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | use azalea_protocol_macros::ServerboundGamePacket; 3 | 4 | #[derive(AzBuf, Clone, Debug, PartialEq, ServerboundGamePacket)] 5 | pub struct ServerboundRecipeBookChangeSettings { 6 | pub book_type: RecipeBookType, 7 | pub is_open: bool, 8 | pub is_filtering: bool, 9 | } 10 | 11 | #[derive(AzBuf, Clone, Copy, Debug, PartialEq)] 12 | pub enum RecipeBookType { 13 | Crafting = 0, 14 | Furnace = 1, 15 | BlastFurnace = 2, 16 | Smoker = 3, 17 | } 18 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/game/s_set_test_block.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | use azalea_core::position::BlockPos; 3 | use azalea_protocol_macros::ServerboundGamePacket; 4 | 5 | #[derive(AzBuf, Clone, Debug, PartialEq, ServerboundGamePacket)] 6 | pub struct ServerboundSetTestBlock { 7 | pub position: BlockPos, 8 | pub mode: TestBlockMode, 9 | pub message: String, 10 | } 11 | 12 | #[derive(AzBuf, Clone, Copy, Debug, Default, PartialEq)] 13 | pub enum TestBlockMode { 14 | #[default] 15 | Start, 16 | Log, 17 | Fail, 18 | Accept, 19 | } 20 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/game/c_initialize_border.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | use azalea_protocol_macros::ClientboundGamePacket; 3 | 4 | #[derive(AzBuf, ClientboundGamePacket, Clone, Debug, PartialEq)] 5 | pub struct ClientboundInitializeBorder { 6 | pub new_center_x: f64, 7 | pub new_center_z: f64, 8 | pub old_size: f64, 9 | pub new_size: f64, 10 | #[var] 11 | pub lerp_time: u64, 12 | #[var] 13 | pub new_absolute_max_size: u32, 14 | #[var] 15 | pub warning_blocks: u32, 16 | #[var] 17 | pub warning_time: u32, 18 | } 19 | -------------------------------------------------------------------------------- /azalea-registry/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "azalea-registry" 3 | description = "Use Minecraft's registries." 4 | version.workspace = true 5 | edition.workspace = true 6 | license.workspace = true 7 | repository.workspace = true 8 | 9 | [dependencies] 10 | azalea-buf.workspace = true 11 | azalea-registry-macros.workspace = true 12 | serde = { workspace = true, optional = true, features = ["derive"] } 13 | simdnbt.workspace = true 14 | 15 | [features] 16 | serde = ["azalea-registry-macros/serde", "dep:serde"] 17 | default = ["serde"] 18 | 19 | [lints] 20 | workspace = true 21 | -------------------------------------------------------------------------------- /azalea/src/prelude.rs: -------------------------------------------------------------------------------- 1 | //! The Azalea prelude. Things that are necessary for a bare-bones bot are 2 | //! re-exported here. 3 | 4 | pub use azalea_client::{Account, Client, Event}; 5 | pub use azalea_core::tick::GameTick; 6 | pub use bevy_app::AppExit; 7 | 8 | // this is necessary to make the macros that reference bevy_ecs work 9 | pub use crate::ecs as bevy_ecs; 10 | pub use crate::{ 11 | ClientBuilder, 12 | bot::BotClientExt, 13 | container::ContainerClientExt, 14 | ecs::{component::Component, resource::Resource}, 15 | pathfinder::PathfinderClientExt, 16 | }; 17 | -------------------------------------------------------------------------------- /azalea-brigadier/src/arguments/argument_type.rs: -------------------------------------------------------------------------------- 1 | use std::{any::Any, sync::Arc}; 2 | 3 | use crate::{ 4 | errors::CommandSyntaxError, 5 | string_reader::StringReader, 6 | suggestion::{Suggestions, SuggestionsBuilder}, 7 | }; 8 | 9 | pub trait ArgumentType { 10 | fn parse(&self, reader: &mut StringReader) -> Result, CommandSyntaxError>; 11 | 12 | fn list_suggestions(&self, _builder: SuggestionsBuilder) -> Suggestions { 13 | Suggestions::default() 14 | } 15 | 16 | fn examples(&self) -> Vec { 17 | vec![] 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/game/c_level_particles.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | use azalea_core::position::Vec3; 3 | use azalea_entity::particle::Particle; 4 | use azalea_protocol_macros::ClientboundGamePacket; 5 | 6 | #[derive(AzBuf, ClientboundGamePacket, Clone, Debug, PartialEq)] 7 | pub struct ClientboundLevelParticles { 8 | pub override_limiter: bool, 9 | pub always_show: bool, 10 | pub pos: Vec3, 11 | pub x_dist: f32, 12 | pub y_dist: f32, 13 | pub z_dist: f32, 14 | pub max_speed: f32, 15 | pub count: u32, 16 | pub particle: Particle, 17 | } 18 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/game/s_resource_pack.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | use azalea_protocol_macros::ServerboundGamePacket; 3 | use uuid::Uuid; 4 | 5 | #[derive(AzBuf, Clone, Debug, PartialEq, ServerboundGamePacket)] 6 | pub struct ServerboundResourcePack { 7 | pub id: Uuid, 8 | pub action: Action, 9 | } 10 | 11 | #[derive(AzBuf, Clone, Copy, Debug, PartialEq)] 12 | pub enum Action { 13 | SuccessfullyLoaded = 0, 14 | Declined = 1, 15 | FailedDownload = 2, 16 | Accepted = 3, 17 | InvalidUrl = 4, 18 | FailedReload = 5, 19 | Discarded = 6, 20 | } 21 | -------------------------------------------------------------------------------- /azalea-crypto/src/offline.rs: -------------------------------------------------------------------------------- 1 | //! Offline-mode UUID generation. 2 | 3 | use md5::{Digest, Md5}; 4 | use uuid::Uuid; 5 | 6 | /// Return what the offline-mode UUIDv3 for the given username would be. 7 | pub fn generate_uuid(username: &str) -> Uuid { 8 | uuid::Builder::from_md5_bytes(hash(format!("OfflinePlayer:{username}").as_bytes())).into_uuid() 9 | } 10 | 11 | fn hash(data: &[u8]) -> [u8; 16] { 12 | let mut hasher = Md5::new(); 13 | 14 | hasher.update(data); 15 | 16 | let mut bytes = [0; 16]; 17 | bytes.copy_from_slice(&hasher.finalize()[..16]); 18 | 19 | bytes 20 | } 21 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/config/s_resource_pack.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | use azalea_protocol_macros::ServerboundConfigPacket; 3 | use uuid::Uuid; 4 | 5 | #[derive(AzBuf, Clone, Debug, PartialEq, ServerboundConfigPacket)] 6 | pub struct ServerboundResourcePack { 7 | pub id: Uuid, 8 | pub action: Action, 9 | } 10 | 11 | #[derive(AzBuf, Clone, Copy, Debug, Eq, PartialEq)] 12 | pub enum Action { 13 | SuccessfullyLoaded = 0, 14 | Declined = 1, 15 | FailedDownload = 2, 16 | Accepted = 3, 17 | InvalidUrl = 4, 18 | FailedReload = 5, 19 | Discarded = 6, 20 | } 21 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/game/c_move_entity_pos_rot.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | use azalea_core::delta::PositionDelta8; 3 | use azalea_protocol_macros::ClientboundGamePacket; 4 | use azalea_world::MinecraftEntityId; 5 | 6 | /// This packet is sent by the server when an entity moves less then 8 blocks. 7 | #[derive(AzBuf, ClientboundGamePacket, Clone, Debug, PartialEq)] 8 | pub struct ClientboundMoveEntityPosRot { 9 | #[var] 10 | pub entity_id: MinecraftEntityId, 11 | pub delta: PositionDelta8, 12 | pub y_rot: i8, 13 | pub x_rot: i8, 14 | pub on_ground: bool, 15 | } 16 | -------------------------------------------------------------------------------- /codegen/genentities.py: -------------------------------------------------------------------------------- 1 | import lib.code.version 2 | import lib.code.entity 3 | import lib.code.utils 4 | import lib.download 5 | import lib.extract 6 | 7 | version_id = lib.code.version.get_version_id() 8 | 9 | mappings = lib.download.get_mappings_for_version(version_id) 10 | burger_data = lib.extract.get_burger_data_for_version(version_id) 11 | 12 | burger_entities_data = burger_data[0]['entities'] 13 | 14 | lib.code.entity.generate_entity_metadata(burger_entities_data, mappings) 15 | lib.code.entity.generate_entity_dimensions(burger_entities_data) 16 | 17 | lib.code.utils.fmt() 18 | 19 | print('Done!') 20 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/login/mod.rs: -------------------------------------------------------------------------------- 1 | // NOTE: This file is @generated automatically by codegen/packet.py. 2 | // Don't edit it directly! 3 | 4 | use azalea_protocol_macros::declare_state_packets; 5 | 6 | declare_state_packets!(LoginPacket, 7 | Clientbound => [ 8 | login_disconnect, 9 | hello, 10 | login_finished, 11 | login_compression, 12 | custom_query, 13 | cookie_request, 14 | ], 15 | Serverbound => [ 16 | hello, 17 | key, 18 | custom_query_answer, 19 | login_acknowledged, 20 | cookie_response, 21 | ] 22 | ); 23 | -------------------------------------------------------------------------------- /azalea-chat/README.md: -------------------------------------------------------------------------------- 1 | # `azalea-chat` 2 | 3 | Things for working with Minecraft formatted text components. 4 | 5 | # Examples 6 | 7 | ``` 8 | // convert a Minecraft formatted text JSON into colored text that can be printed to the terminal. 9 | 10 | use azalea_chat::FormattedText; 11 | use serde_json::Value; 12 | use serde::Deserialize; 13 | 14 | let j: Value = serde_json::from_str( 15 | r#"{"text": "hello","color": "red","bold": true}"# 16 | ) 17 | .unwrap(); 18 | let text = FormattedText::deserialize(&j).unwrap(); 19 | assert_eq!( 20 | text.to_ansi(), 21 | "\u{1b}[1m\u{1b}[38;2;255;85;85mhello\u{1b}[m" 22 | ); 23 | ``` 24 | -------------------------------------------------------------------------------- /azalea-buf/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "azalea-buf" 3 | description = "Serialize and deserialize buffers from Minecraft." 4 | version.workspace = true 5 | edition.workspace = true 6 | license.workspace = true 7 | repository.workspace = true 8 | 9 | [dependencies] 10 | azalea-buf-macros.workspace = true 11 | byteorder.workspace = true 12 | indexmap.workspace = true 13 | serde_json = { workspace = true, optional = true } 14 | simdnbt.workspace = true 15 | thiserror.workspace = true 16 | tracing.workspace = true 17 | uuid.workspace = true 18 | 19 | [features] 20 | serde_json = ["dep:serde_json"] 21 | 22 | [lints] 23 | workspace = true 24 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/game/c_container_set_slot.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | use azalea_inventory::ItemStack; 3 | use azalea_protocol_macros::ClientboundGamePacket; 4 | 5 | #[derive(AzBuf, ClientboundGamePacket, Clone, Debug, PartialEq)] 6 | pub struct ClientboundContainerSetSlot { 7 | #[var] 8 | pub container_id: i32, 9 | /// An identifier used by the server to track client inventory desyncs. 10 | #[var] 11 | pub state_id: u32, 12 | /// The slot index. 13 | /// 14 | /// See . 15 | pub slot: u16, 16 | pub item_stack: ItemStack, 17 | } 18 | -------------------------------------------------------------------------------- /azalea-auth/examples/certificates.rs: -------------------------------------------------------------------------------- 1 | use std::path::PathBuf; 2 | 3 | #[tokio::main] 4 | async fn main() { 5 | env_logger::init(); 6 | 7 | let cache_file = PathBuf::from("example_cache.json"); 8 | 9 | let auth_result = azalea_auth::auth( 10 | "example@example.com", 11 | azalea_auth::AuthOpts { 12 | cache_file: Some(cache_file), 13 | ..Default::default() 14 | }, 15 | ) 16 | .await 17 | .unwrap(); 18 | 19 | let certs = azalea_auth::certs::fetch_certificates(&auth_result.access_token) 20 | .await 21 | .unwrap(); 22 | 23 | println!("{certs:?}"); 24 | } 25 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/game/c_sound_entity.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | use azalea_core::sound::CustomSound; 3 | use azalea_protocol_macros::ClientboundGamePacket; 4 | use azalea_registry::builtin::SoundEvent; 5 | use azalea_world::MinecraftEntityId; 6 | 7 | use super::c_sound::SoundSource; 8 | 9 | #[derive(AzBuf, ClientboundGamePacket, Clone, Debug, PartialEq)] 10 | pub struct ClientboundSoundEntity { 11 | pub sound: azalea_registry::Holder, 12 | pub source: SoundSource, 13 | #[var] 14 | pub id: MinecraftEntityId, 15 | pub volume: f32, 16 | pub pitch: f32, 17 | pub seed: u64, 18 | } 19 | -------------------------------------------------------------------------------- /azalea-buf/src/definitions.rs: -------------------------------------------------------------------------------- 1 | use std::ops::Deref; 2 | 3 | /// A `Vec` that isn't prefixed by a VarInt with the size. 4 | #[derive(Clone, Debug, Eq, Hash, PartialEq)] 5 | pub struct UnsizedByteArray(pub Vec); 6 | 7 | impl Deref for UnsizedByteArray { 8 | type Target = [u8]; 9 | 10 | fn deref(&self) -> &Self::Target { 11 | &self.0 12 | } 13 | } 14 | 15 | impl From> for UnsizedByteArray { 16 | fn from(vec: Vec) -> Self { 17 | Self(vec) 18 | } 19 | } 20 | 21 | impl From<&str> for UnsizedByteArray { 22 | fn from(s: &str) -> Self { 23 | Self(s.as_bytes().to_vec()) 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /azalea-client/tests/simulation/client_disconnect.rs: -------------------------------------------------------------------------------- 1 | use azalea_client::test_utils::prelude::*; 2 | use azalea_protocol::packets::ConnectionProtocol; 3 | use azalea_world::InstanceName; 4 | 5 | #[test] 6 | fn test_client_disconnect() { 7 | let _lock = init(); 8 | 9 | let mut simulation = Simulation::new(ConnectionProtocol::Game); 10 | 11 | simulation.disconnect(); 12 | simulation.tick(); 13 | 14 | // make sure we're disconnected 15 | let is_connected = simulation.has_component::(); 16 | assert!(!is_connected); 17 | 18 | // tick again to make sure nothing goes wrong 19 | simulation.tick(); 20 | } 21 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/game/c_player_look_at.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | use azalea_core::position::Vec3; 3 | use azalea_protocol_macros::ClientboundGamePacket; 4 | 5 | #[derive(AzBuf, ClientboundGamePacket, Clone, Debug, PartialEq)] 6 | pub struct ClientboundPlayerLookAt { 7 | pub from_anchor: Anchor, 8 | pub pos: Vec3, 9 | pub entity: Option, 10 | } 11 | 12 | #[derive(AzBuf, Clone, Copy, Debug, PartialEq)] 13 | pub enum Anchor { 14 | Feet = 0, 15 | Eyes = 1, 16 | } 17 | 18 | #[derive(AzBuf, Clone, Debug, PartialEq)] 19 | pub struct AtEntity { 20 | #[var] 21 | pub entity: u32, 22 | pub to_anchor: Anchor, 23 | } 24 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/game/s_player_command.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | use azalea_protocol_macros::ServerboundGamePacket; 3 | use azalea_world::MinecraftEntityId; 4 | 5 | #[derive(AzBuf, Clone, Debug, PartialEq, ServerboundGamePacket)] 6 | pub struct ServerboundPlayerCommand { 7 | #[var] 8 | pub id: MinecraftEntityId, 9 | pub action: Action, 10 | #[var] 11 | pub data: u32, 12 | } 13 | 14 | #[derive(AzBuf, Clone, Copy, Debug, PartialEq)] 15 | pub enum Action { 16 | StopSleeping, 17 | StartSprinting, 18 | StopSprinting, 19 | StartRidingJump, 20 | StopRidingJump, 21 | OpenInventory, 22 | StartFallFlying, 23 | } 24 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/game/c_move_minecart_along_track.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | use azalea_core::position::Vec3; 3 | use azalea_protocol_macros::ClientboundGamePacket; 4 | use azalea_world::MinecraftEntityId; 5 | 6 | #[derive(AzBuf, ClientboundGamePacket, Clone, Debug, PartialEq)] 7 | pub struct ClientboundMoveMinecartAlongTrack { 8 | #[var] 9 | pub entity_id: MinecraftEntityId, 10 | pub lerp_steps: Vec, 11 | } 12 | 13 | #[derive(AzBuf, Clone, Debug, PartialEq)] 14 | pub struct MinecartStep { 15 | pub position: Vec3, 16 | pub movement: Vec3, 17 | pub y_rot: u8, 18 | pub x_rot: u8, 19 | pub weight: f32, 20 | } 21 | -------------------------------------------------------------------------------- /azalea-brigadier/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "azalea-brigadier" 3 | description = "A port of Mojang's Brigadier command parsing and dispatching library." 4 | version.workspace = true 5 | edition.workspace = true 6 | license.workspace = true 7 | repository.workspace = true 8 | 9 | [dev-dependencies] 10 | bevy_app.workspace = true 11 | bevy_ecs.workspace = true 12 | 13 | [dependencies] 14 | azalea-buf = { workspace = true, optional = true } 15 | azalea-chat = { workspace = true, optional = true } 16 | parking_lot.workspace = true 17 | 18 | [features] 19 | azalea-buf = ["dep:azalea-buf", "dep:azalea-chat", "azalea-chat/azalea-buf"] 20 | 21 | [lints] 22 | workspace = true 23 | -------------------------------------------------------------------------------- /docs-rs/README.md: -------------------------------------------------------------------------------- 1 | ## Docs.rs Extensions 2 | 3 | This directory includes some templates and styling to extend and modify [rustdoc]'s output 4 | for Azalea's documentation on [docs.rs]. 5 | 6 | See [Bevy's documentation](https://github.com/bevyengine/bevy/tree/main/docs-rs) for more info. 7 | 8 | ## Local Testing 9 | 10 | Build the documentation with the extension enabled like this: 11 | 12 | ```bash 13 | RUSTDOCFLAGS="--html-after-content docs-rs/trait-tags.html --cfg docsrs_dep" RUSTFLAGS="--cfg docsrs_dep" cargo doc --no-deps --package 14 | ``` 15 | 16 | [rustdoc]: https://doc.rust-lang.org/rustdoc/what-is-rustdoc.html 17 | [docs.rs]: https://docs.rs 18 | -------------------------------------------------------------------------------- /azalea-physics/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "azalea-physics" 3 | description = "Physics for Minecraft entities." 4 | version.workspace = true 5 | edition.workspace = true 6 | license.workspace = true 7 | repository.workspace = true 8 | 9 | [dev-dependencies] 10 | uuid.workspace = true 11 | 12 | [dependencies] 13 | azalea-block.workspace = true 14 | azalea-core.workspace = true 15 | azalea-entity.workspace = true 16 | azalea-inventory.workspace = true 17 | azalea-registry.workspace = true 18 | azalea-world.workspace = true 19 | bevy_app.workspace = true 20 | bevy_ecs.workspace = true 21 | tracing.workspace = true 22 | parking_lot.workspace = true 23 | 24 | [lints] 25 | workspace = true 26 | -------------------------------------------------------------------------------- /azalea-protocol/src/common/server_links.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | use azalea_chat::FormattedText; 3 | 4 | #[derive(AzBuf, Clone, Debug, PartialEq)] 5 | pub struct ServerLinkEntry { 6 | pub kind: ServerLinkKind, 7 | pub link: String, 8 | } 9 | 10 | #[derive(AzBuf, Clone, Debug, PartialEq)] 11 | pub enum ServerLinkKind { 12 | Component(FormattedText), 13 | Known(KnownLinkKind), 14 | } 15 | 16 | #[derive(AzBuf, Clone, Copy, Debug, PartialEq)] 17 | pub enum KnownLinkKind { 18 | BugReport, 19 | CommunityGuidelines, 20 | Support, 21 | Status, 22 | Feedback, 23 | Community, 24 | Website, 25 | Forums, 26 | News, 27 | Announcements, 28 | } 29 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/game/c_update_attributes.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | use azalea_inventory::components::AttributeModifier; 3 | use azalea_protocol_macros::ClientboundGamePacket; 4 | use azalea_registry::builtin::Attribute; 5 | use azalea_world::MinecraftEntityId; 6 | 7 | #[derive(AzBuf, ClientboundGamePacket, Clone, Debug, PartialEq)] 8 | pub struct ClientboundUpdateAttributes { 9 | #[var] 10 | pub entity_id: MinecraftEntityId, 11 | pub values: Vec, 12 | } 13 | 14 | #[derive(AzBuf, Clone, Debug, PartialEq)] 15 | pub struct AttributeSnapshot { 16 | pub attribute: Attribute, 17 | pub base: f64, 18 | pub modifiers: Vec, 19 | } 20 | -------------------------------------------------------------------------------- /azalea-brigadier/README.md: -------------------------------------------------------------------------------- 1 | # `azalea-brigadier` 2 | 3 | A Rust port of Mojang's [Brigadier](https://github.com/Mojang/brigadier) command parsing and dispatching library. 4 | 5 | # Examples 6 | 7 | ```rust 8 | use azalea_brigadier::prelude::*; 9 | use std::sync::Arc; 10 | 11 | #[derive(Debug, PartialEq)] 12 | struct CommandSource {} 13 | 14 | let mut subject = CommandDispatcher::new(); 15 | subject.register(literal("foo").executes(|_| 42)); 16 | 17 | assert_eq!( 18 | subject 19 | .execute("foo", Arc::new(CommandSource {})) 20 | .unwrap(), 21 | 42 22 | ); 23 | ``` 24 | 25 | See the [tests](https://github.com/azalea-rs/azalea/tree/main/azalea-brigadier/tests) for more. 26 | 27 | -------------------------------------------------------------------------------- /.github/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | name: CI 2 | 3 | on: 4 | push: 5 | pull_request: 6 | types: [opened, reopened] 7 | 8 | env: 9 | CARGO_INCREMENTAL: 0 # required so ci doesn't run out of space 10 | CARGO_TERM_COLOR: always 11 | 12 | jobs: 13 | clippy_and_test: 14 | runs-on: ubuntu-latest 15 | steps: 16 | - uses: actions/checkout@v4 17 | 18 | - name: Install Nightly 19 | run: rustup update nightly && rustup default nightly && rustup component add clippy 20 | 21 | - name: Cache dependencies 22 | uses: Swatinem/rust-cache@v2 23 | 24 | - name: Clippy 25 | run: cargo clippy --all-features 26 | 27 | - name: Test 28 | run: cargo test 29 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/game/s_chat_session_update.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | use azalea_protocol_macros::ServerboundGamePacket; 3 | use uuid::Uuid; 4 | 5 | #[derive(AzBuf, Clone, Debug, PartialEq, ServerboundGamePacket)] 6 | pub struct ServerboundChatSessionUpdate { 7 | pub chat_session: RemoteChatSessionData, 8 | } 9 | 10 | #[derive(AzBuf, Clone, Debug, Eq, PartialEq)] 11 | pub struct RemoteChatSessionData { 12 | pub session_id: Uuid, 13 | pub profile_public_key: ProfilePublicKeyData, 14 | } 15 | 16 | #[derive(AzBuf, Clone, Debug, Eq, PartialEq)] 17 | pub struct ProfilePublicKeyData { 18 | pub expires_at: u64, 19 | pub key: Vec, 20 | pub key_signature: Vec, 21 | } 22 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/game/s_chat_command_signed.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | use azalea_crypto::signing::MessageSignature; 3 | use azalea_protocol_macros::ServerboundGamePacket; 4 | 5 | use super::s_chat::LastSeenMessagesUpdate; 6 | 7 | #[derive(AzBuf, Clone, Debug, PartialEq, ServerboundGamePacket)] 8 | pub struct ServerboundChatCommandSigned { 9 | pub command: String, 10 | pub timestamp: u64, 11 | pub salt: u64, 12 | pub argument_signatures: Vec, 13 | pub last_seen_messages: LastSeenMessagesUpdate, 14 | } 15 | 16 | #[derive(AzBuf, Clone, Debug, PartialEq)] 17 | pub struct ArgumentSignature { 18 | pub name: String, 19 | pub signature: MessageSignature, 20 | } 21 | -------------------------------------------------------------------------------- /azalea-inventory/src/default_components/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod generated; 2 | 3 | use azalea_registry::builtin::ItemKind; 4 | 5 | use crate::components::DataComponentTrait; 6 | 7 | /// A trait for data components that some [`ItemKind`]s may have a default value 8 | /// for. 9 | pub trait DefaultableComponent: DataComponentTrait { 10 | fn default_for_item(item: ItemKind) -> Option 11 | where 12 | Self: Sized; 13 | } 14 | impl DefaultableComponent for T { 15 | default fn default_for_item(_item: ItemKind) -> Option { 16 | None 17 | } 18 | } 19 | pub fn get_default_component(item: ItemKind) -> Option { 20 | T::default_for_item(item) 21 | } 22 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/game/s_player_action.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | use azalea_core::{direction::Direction, position::BlockPos}; 3 | use azalea_protocol_macros::ServerboundGamePacket; 4 | 5 | #[derive(AzBuf, Clone, Debug, PartialEq, ServerboundGamePacket)] 6 | pub struct ServerboundPlayerAction { 7 | pub action: Action, 8 | pub pos: BlockPos, 9 | pub direction: Direction, 10 | #[var] 11 | pub seq: u32, 12 | } 13 | 14 | #[derive(AzBuf, Clone, Copy, Debug, Eq, PartialEq)] 15 | pub enum Action { 16 | StartDestroyBlock = 0, 17 | AbortDestroyBlock = 1, 18 | StopDestroyBlock = 2, 19 | DropAllItems = 3, 20 | DropItem = 4, 21 | ReleaseUseItem = 5, 22 | SwapItemWithOffhand = 6, 23 | } 24 | -------------------------------------------------------------------------------- /azalea-brigadier/src/builder/literal_argument_builder.rs: -------------------------------------------------------------------------------- 1 | use super::argument_builder::{ArgumentBuilder, ArgumentBuilderType}; 2 | 3 | #[derive(Clone, Debug, Default)] 4 | pub struct Literal { 5 | pub value: String, 6 | } 7 | impl Literal { 8 | pub fn new(value: &str) -> Self { 9 | Self { 10 | value: value.to_owned(), 11 | } 12 | } 13 | } 14 | 15 | impl From for ArgumentBuilderType { 16 | fn from(literal: Literal) -> Self { 17 | Self::Literal(literal) 18 | } 19 | } 20 | 21 | /// Shortcut for creating a new literal builder node. 22 | pub fn literal(value: &str) -> ArgumentBuilder { 23 | ArgumentBuilder::new(ArgumentBuilderType::Literal(Literal::new(value))) 24 | } 25 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/game/c_animate.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | use azalea_protocol_macros::ClientboundGamePacket; 3 | use azalea_world::MinecraftEntityId; 4 | 5 | #[derive(AzBuf, ClientboundGamePacket, Clone, Debug, PartialEq)] 6 | pub struct ClientboundAnimate { 7 | #[var] 8 | pub id: MinecraftEntityId, 9 | pub action: AnimationAction, 10 | } 11 | 12 | // minecraft actually uses a u8 for this, but a varint still works and makes it 13 | // so i don't have to add a special handler 14 | #[derive(AzBuf, Clone, Copy, Debug, PartialEq)] 15 | pub enum AnimationAction { 16 | SwingMainHand = 0, 17 | Hurt = 1, 18 | WakeUp = 2, 19 | SwingOffHand = 3, 20 | CriticalHit = 4, 21 | MagicCriticalHit = 5, 22 | } 23 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/game/c_recipe_book_settings.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | use azalea_protocol_macros::ClientboundGamePacket; 3 | 4 | #[derive(AzBuf, ClientboundGamePacket, Clone, Debug, PartialEq)] 5 | pub struct ClientboundRecipeBookSettings { 6 | pub book_settings: RecipeBookSettings, 7 | } 8 | 9 | #[derive(AzBuf, Clone, Debug, PartialEq)] 10 | pub struct RecipeBookSettings { 11 | pub gui_open: bool, 12 | pub filtering_craftable: bool, 13 | 14 | pub furnace_gui_open: bool, 15 | pub furnace_filtering_craftable: bool, 16 | 17 | pub blast_furnace_gui_open: bool, 18 | pub blast_furnace_filtering_craftable: bool, 19 | 20 | pub smoker_gui_open: bool, 21 | pub smoker_filtering_craftable: bool, 22 | } 23 | -------------------------------------------------------------------------------- /azalea-inventory/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "azalea-inventory" 3 | description = "Representations of various inventory data structures in Minecraft." 4 | version.workspace = true 5 | edition.workspace = true 6 | license.workspace = true 7 | repository.workspace = true 8 | 9 | [dependencies] 10 | azalea-auth.workspace = true 11 | azalea-buf.workspace = true 12 | azalea-chat = { workspace = true, features = ["azalea-buf"] } 13 | azalea-core.workspace = true 14 | azalea-inventory-macros.workspace = true 15 | azalea-registry = { workspace = true, features = ["serde"] } 16 | indexmap.workspace = true 17 | serde.workspace = true 18 | simdnbt.workspace = true 19 | tracing.workspace = true 20 | uuid.workspace = true 21 | 22 | [lints] 23 | workspace = true 24 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/game/s_chat.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | use azalea_core::bitset::FixedBitSet; 3 | use azalea_crypto::signing::MessageSignature; 4 | use azalea_protocol_macros::ServerboundGamePacket; 5 | 6 | #[derive(AzBuf, Clone, Debug, PartialEq, ServerboundGamePacket)] 7 | pub struct ServerboundChat { 8 | #[limit(256)] 9 | pub message: String, 10 | pub timestamp: u64, 11 | pub salt: u64, 12 | pub signature: Option, 13 | pub last_seen_messages: LastSeenMessagesUpdate, 14 | } 15 | 16 | #[derive(AzBuf, Clone, Debug, Default, PartialEq)] 17 | pub struct LastSeenMessagesUpdate { 18 | #[var] 19 | pub offset: u32, 20 | pub acknowledged: FixedBitSet<20>, 21 | pub checksum: u8, 22 | } 23 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/game/c_light_update.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | use azalea_core::bitset::BitSet; 3 | use azalea_protocol_macros::ClientboundGamePacket; 4 | 5 | #[derive(AzBuf, ClientboundGamePacket, Clone, Debug, PartialEq)] 6 | pub struct ClientboundLightUpdate { 7 | #[var] 8 | pub x: i32, 9 | #[var] 10 | pub z: i32, 11 | pub light_data: ClientboundLightUpdatePacketData, 12 | } 13 | 14 | #[derive(AzBuf, Clone, Debug, Default, PartialEq)] 15 | pub struct ClientboundLightUpdatePacketData { 16 | pub sky_y_mask: BitSet, 17 | pub block_y_mask: BitSet, 18 | pub empty_sky_y_mask: BitSet, 19 | pub empty_block_y_mask: BitSet, 20 | pub sky_updates: Vec>, 21 | pub block_updates: Vec>, 22 | } 23 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/game/c_award_stats.rs: -------------------------------------------------------------------------------- 1 | use std::collections::HashMap; 2 | 3 | use azalea_buf::AzBuf; 4 | use azalea_protocol_macros::ClientboundGamePacket; 5 | use azalea_registry::builtin::{BlockKind, CustomStat, EntityKind, ItemKind}; 6 | 7 | #[derive(AzBuf, ClientboundGamePacket, Clone, Debug, PartialEq)] 8 | pub struct ClientboundAwardStats { 9 | #[var] 10 | pub stats: HashMap, 11 | } 12 | 13 | #[derive(AzBuf, Clone, Copy, Debug, Eq, Hash, PartialEq)] 14 | pub enum Stat { 15 | Mined(BlockKind), 16 | Crafted(ItemKind), 17 | Used(ItemKind), 18 | Broken(ItemKind), 19 | PickedUp(ItemKind), 20 | Dropped(ItemKind), 21 | Killed(EntityKind), 22 | KilledBy(EntityKind), 23 | Custom(CustomStat), 24 | } 25 | -------------------------------------------------------------------------------- /azalea-client/tests/simulation/receive_start_config_packet.rs: -------------------------------------------------------------------------------- 1 | use azalea_client::{InConfigState, test_utils::prelude::*}; 2 | use azalea_protocol::packets::{ConnectionProtocol, game::ClientboundStartConfiguration}; 3 | use azalea_world::InstanceName; 4 | 5 | #[test] 6 | fn test_receive_start_config_packet() { 7 | let _lock = init(); 8 | 9 | let mut simulation = Simulation::new(ConnectionProtocol::Game); 10 | 11 | simulation.receive_packet(default_login_packet()); 12 | simulation.tick(); 13 | assert!(simulation.has_component::()); 14 | simulation.tick(); 15 | 16 | simulation.receive_packet(ClientboundStartConfiguration); 17 | 18 | simulation.tick(); 19 | assert!(simulation.has_component::()); 20 | } 21 | -------------------------------------------------------------------------------- /codegen/newpacket.py: -------------------------------------------------------------------------------- 1 | import lib.code.version 2 | import lib.code.packet 3 | import lib.code.utils 4 | import lib.download 5 | import lib.extract 6 | import sys 7 | 8 | def generate(): 9 | version_id = lib.code.version.get_version_id() 10 | 11 | packets_report = lib.extract.get_packets_report(version_id) 12 | 13 | packet_id, direction, state = sys.argv[1], sys.argv[2], sys.argv[3] 14 | print( 15 | f'Generating code for packet id: {packet_id} with direction {direction} and state {state}') 16 | lib.code.packet.generate_packet(packets_report, packet_id, direction, state) 17 | lib.code.packet.set_packets(packets_report) 18 | 19 | lib.code.utils.fmt() 20 | 21 | print('Done!') 22 | 23 | if __name__ == '__main__': 24 | generate() 25 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/game/c_game_event.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | use azalea_protocol_macros::ClientboundGamePacket; 3 | 4 | #[derive(AzBuf, ClientboundGamePacket, Clone, Debug, PartialEq)] 5 | pub struct ClientboundGameEvent { 6 | pub event: EventType, 7 | pub param: f32, 8 | } 9 | 10 | #[derive(AzBuf, Clone, Copy, Debug, PartialEq)] 11 | pub enum EventType { 12 | NoRespawnBlockAvailable = 0, 13 | StartRaining = 1, 14 | StopRaining = 2, 15 | ChangeGameMode = 3, 16 | WinGame = 4, 17 | DemoEvent = 5, 18 | ArrowHitPlayer = 6, 19 | RainLevelChange = 7, 20 | ThunderLevelChange = 8, 21 | PufferFishSting = 9, 22 | GuardianElderEffect = 10, 23 | ImmediateRespawn = 11, 24 | LimitedCrafting = 12, 25 | WaitForLevelChunks = 13, 26 | } 27 | -------------------------------------------------------------------------------- /azalea-chat/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "azalea-chat" 3 | description = "Parse Minecraft chat messages." 4 | version.workspace = true 5 | edition.workspace = true 6 | license.workspace = true 7 | repository.workspace = true 8 | 9 | [features] 10 | default = [] 11 | simdnbt = ["dep:simdnbt"] 12 | azalea-buf = ["dep:azalea-buf", "simdnbt"] 13 | numbers = ["dep:azalea-registry", "dep:simdnbt"] 14 | 15 | [dependencies] 16 | azalea-buf = { workspace = true, optional = true, features = ["serde_json"] } 17 | azalea-language.workspace = true 18 | azalea-registry = { workspace = true, optional = true } 19 | serde = { workspace = true, features = ["derive"] } 20 | serde_json.workspace = true 21 | simdnbt = { workspace = true, optional = true } 22 | tracing.workspace = true 23 | 24 | [lints] 25 | workspace = true 26 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/game/c_set_display_objective.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | use azalea_protocol_macros::ClientboundGamePacket; 3 | 4 | #[derive(AzBuf, ClientboundGamePacket, Clone, Debug, PartialEq)] 5 | pub struct ClientboundSetDisplayObjective { 6 | pub slot: DisplaySlot, 7 | pub objective_name: String, 8 | } 9 | 10 | #[derive(AzBuf, Clone, Copy, Debug, PartialEq)] 11 | pub enum DisplaySlot { 12 | List = 0, 13 | Sidebar, 14 | BelowName, 15 | TeamBlack, 16 | TeamDarkBlue, 17 | TeamDarkGreen, 18 | TeamDarkAqua, 19 | TeamDarkRed, 20 | TeamDarkPurple, 21 | TeamGold, 22 | TeamGray, 23 | TeamDarkGray, 24 | TeamBlue, 25 | TeamGreen, 26 | TeamAqua, 27 | TeamRed, 28 | TeamLightPurple, 29 | TeamYellow, 30 | TeamWhite, 31 | } 32 | -------------------------------------------------------------------------------- /azalea-core/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "azalea-core" 3 | description = "Miscellaneous things in Azalea." 4 | version.workspace = true 5 | edition.workspace = true 6 | license.workspace = true 7 | repository.workspace = true 8 | 9 | [dependencies] 10 | azalea-buf.workspace = true 11 | azalea-registry.workspace = true 12 | bevy_ecs = { workspace = true, optional = true } 13 | nohash-hasher.workspace = true 14 | num-traits.workspace = true 15 | serde.workspace = true 16 | simdnbt.workspace = true 17 | tracing.workspace = true 18 | azalea-chat = { workspace = true, features = ["simdnbt"] } 19 | indexmap.workspace = true 20 | crc32c.workspace = true 21 | thiserror.workspace = true 22 | uuid.workspace = true 23 | 24 | [features] 25 | bevy_ecs = ["dep:bevy_ecs"] 26 | strict_registry = [] 27 | 28 | [lints] 29 | workspace = true 30 | -------------------------------------------------------------------------------- /azalea-crypto/benches/my_benchmark.rs: -------------------------------------------------------------------------------- 1 | use azalea_crypto::{create_cipher, decrypt_packet, encrypt_packet}; 2 | use criterion::{Criterion, criterion_group, criterion_main}; 3 | 4 | fn bench(c: &mut Criterion) { 5 | let (mut enc, dec) = create_cipher(b"0123456789abcdef"); 6 | 7 | let mut packet = [0u8; 65536]; 8 | for (i, item) in packet.iter_mut().enumerate() { 9 | *item = i as u8; 10 | } 11 | 12 | c.bench_function("Encrypt 64kb", |b| { 13 | b.iter(|| encrypt_packet(&mut enc.clone(), &mut packet.clone())) 14 | }); 15 | 16 | encrypt_packet(&mut enc, &mut packet); 17 | 18 | c.bench_function("Decrypt 64kb", |b| { 19 | b.iter(|| decrypt_packet(&mut dec.clone(), &mut packet.clone())) 20 | }); 21 | } 22 | 23 | criterion_group!(benches, bench); 24 | criterion_main!(benches); 25 | -------------------------------------------------------------------------------- /azalea-brigadier/src/parse_results.rs: -------------------------------------------------------------------------------- 1 | use std::{ 2 | collections::HashMap, 3 | fmt::{self, Debug}, 4 | rc::Rc, 5 | }; 6 | 7 | use crate::{ 8 | context::CommandContextBuilder, errors::CommandSyntaxError, string_reader::StringReader, 9 | tree::CommandNode, 10 | }; 11 | 12 | pub struct ParseResults<'a, S> { 13 | pub context: CommandContextBuilder<'a, S>, 14 | pub reader: StringReader, 15 | pub exceptions: HashMap>, CommandSyntaxError>, 16 | } 17 | 18 | impl Debug for ParseResults<'_, S> { 19 | fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { 20 | f.debug_struct("ParseResults") 21 | .field("context", &self.context) 22 | // .field("reader", &self.reader) 23 | .field("exceptions", &self.exceptions) 24 | .finish() 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /azalea-client/tests/simulation/mod.rs: -------------------------------------------------------------------------------- 1 | // This file is @generated by `azalea-client/build.rs`. 2 | 3 | mod change_dimension_to_nether_and_back; 4 | mod client_disconnect; 5 | mod close_open_container; 6 | mod correct_movement; 7 | mod correct_sneak_movement; 8 | mod correct_sprint_sneak_movement; 9 | mod despawn_entities_when_changing_dimension; 10 | mod enchantments; 11 | mod fast_login; 12 | mod login_to_dimension_with_same_name; 13 | mod mine_block_rollback; 14 | mod mine_block_timing_hand; 15 | mod mine_block_without_rollback; 16 | mod move_and_despawn_entity; 17 | mod move_despawned_entity; 18 | mod packet_order; 19 | mod packet_order_set_carried_item; 20 | mod receive_spawn_entity_and_start_config_packet; 21 | mod receive_start_config_packet; 22 | mod reply_to_ping_with_pong; 23 | mod set_health_before_login; 24 | mod teleport_movement; 25 | mod ticks_alive; 26 | -------------------------------------------------------------------------------- /azalea-entity/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "azalea-entity" 3 | description = "Things related to Minecraft entities used by Azalea" 4 | version.workspace = true 5 | edition.workspace = true 6 | license.workspace = true 7 | repository.workspace = true 8 | 9 | [dependencies] 10 | azalea-block.workspace = true 11 | azalea-buf.workspace = true 12 | azalea-chat = { workspace = true, features = ["azalea-buf"] } 13 | azalea-core.workspace = true 14 | azalea-inventory.workspace = true 15 | azalea-registry.workspace = true 16 | azalea-world.workspace = true 17 | bevy_app.workspace = true 18 | bevy_ecs.workspace = true 19 | derive_more.workspace = true 20 | enum-as-inner.workspace = true 21 | nohash-hasher.workspace = true 22 | parking_lot.workspace = true 23 | thiserror.workspace = true 24 | tracing.workspace = true 25 | uuid.workspace = true 26 | 27 | [lints] 28 | workspace = true 29 | -------------------------------------------------------------------------------- /azalea-core/src/objectives.rs: -------------------------------------------------------------------------------- 1 | use std::{ 2 | fmt::{self, Display}, 3 | str::FromStr, 4 | }; 5 | 6 | use azalea_buf::AzBuf; 7 | 8 | #[derive(AzBuf, Clone, Copy, Debug, PartialEq)] 9 | pub enum ObjectiveCriteria { 10 | Integer, 11 | Hearts, 12 | } 13 | 14 | impl Display for ObjectiveCriteria { 15 | fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { 16 | match self { 17 | ObjectiveCriteria::Integer => write!(f, "integer"), 18 | ObjectiveCriteria::Hearts => write!(f, "hearts"), 19 | } 20 | } 21 | } 22 | 23 | impl FromStr for ObjectiveCriteria { 24 | type Err = (); 25 | 26 | fn from_str(s: &str) -> Result { 27 | match s { 28 | "integer" => Ok(ObjectiveCriteria::Integer), 29 | "hearts" => Ok(ObjectiveCriteria::Hearts), 30 | _ => Err(()), 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /azalea/examples/echo.rs: -------------------------------------------------------------------------------- 1 | //! A simple bot that repeats chat messages sent by other players. 2 | 3 | use azalea::prelude::*; 4 | 5 | #[tokio::main] 6 | async fn main() -> AppExit { 7 | let account = Account::offline("bot"); 8 | // or let account = Account::microsoft("email").await.unwrap(); 9 | 10 | ClientBuilder::new() 11 | .set_handler(handle) 12 | .start(account, "localhost") 13 | .await 14 | } 15 | 16 | #[derive(Clone, Component, Default)] 17 | pub struct State {} 18 | 19 | async fn handle(bot: Client, event: Event, _state: State) -> anyhow::Result<()> { 20 | if let Event::Chat(m) = event 21 | && let (Some(sender), content) = m.split_sender_and_content() 22 | { 23 | if sender == bot.username() { 24 | // ignore our own messages 25 | return Ok(()); 26 | } 27 | bot.chat(content); 28 | } 29 | 30 | Ok(()) 31 | } 32 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/game/c_recipe_book_add.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | use azalea_protocol_macros::ClientboundGamePacket; 3 | use azalea_registry::builtin::RecipeBookCategory; 4 | 5 | use crate::common::recipe::{Ingredient, RecipeDisplayData}; 6 | 7 | #[derive(AzBuf, ClientboundGamePacket, Clone, Debug, PartialEq)] 8 | pub struct ClientboundRecipeBookAdd { 9 | pub entries: Vec, 10 | pub replace: bool, 11 | } 12 | 13 | #[derive(AzBuf, Clone, Debug, PartialEq)] 14 | pub struct Entry { 15 | pub contents: RecipeDisplayEntry, 16 | pub flags: u8, 17 | } 18 | 19 | #[derive(AzBuf, Clone, Debug, PartialEq)] 20 | pub struct RecipeDisplayEntry { 21 | #[var] 22 | pub id: u32, 23 | pub display: RecipeDisplayData, 24 | // optional varint 25 | #[var] 26 | pub group: u32, 27 | pub category: RecipeBookCategory, 28 | pub crafting_requirements: Option>, 29 | } 30 | -------------------------------------------------------------------------------- /azalea-inventory/src/item/mod.rs: -------------------------------------------------------------------------------- 1 | use azalea_registry::builtin::ItemKind; 2 | 3 | use crate::{components::MaxStackSize, default_components::get_default_component}; 4 | 5 | pub mod consume_effect; 6 | 7 | pub trait MaxStackSizeExt { 8 | /// Get the maximum stack size for this item. 9 | /// 10 | /// This is a signed integer to be consistent with the `count` field of 11 | /// [`ItemStackData`]. 12 | /// 13 | /// [`ItemStackData`]: crate::ItemStackData 14 | fn max_stack_size(&self) -> i32; 15 | 16 | /// Whether this item can be stacked with other items. 17 | /// 18 | /// This is equivalent to `self.max_stack_size() > 1`. 19 | fn stackable(&self) -> bool { 20 | self.max_stack_size() > 1 21 | } 22 | } 23 | 24 | impl MaxStackSizeExt for ItemKind { 25 | fn max_stack_size(&self) -> i32 { 26 | get_default_component::(*self).map_or(64, |s| s.count) 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/login/s_hello.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | use azalea_protocol_macros::ServerboundLoginPacket; 3 | use uuid::Uuid; 4 | 5 | #[derive(AzBuf, Clone, Debug, Eq, PartialEq, ServerboundLoginPacket)] 6 | pub struct ServerboundHello { 7 | #[limit(16)] 8 | pub name: String, 9 | pub profile_id: Uuid, 10 | } 11 | 12 | #[cfg(test)] 13 | mod tests { 14 | use std::io::Cursor; 15 | 16 | use azalea_buf::{AzaleaRead, AzaleaWrite}; 17 | 18 | use super::*; 19 | 20 | #[test] 21 | fn test_read_write() { 22 | let packet = ServerboundHello { 23 | name: "test".to_owned(), 24 | profile_id: Uuid::nil(), 25 | }; 26 | let mut buf: Vec = Vec::new(); 27 | packet.azalea_write(&mut buf).unwrap(); 28 | let packet2 = ServerboundHello::azalea_read(&mut Cursor::new(&buf)).unwrap(); 29 | assert_eq!(packet, packet2); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /azalea-client/src/lib.rs: -------------------------------------------------------------------------------- 1 | #![doc = include_str!("../README.md")] 2 | #![feature(error_generic_member_access)] 3 | #![feature(never_type)] 4 | 5 | mod account; 6 | mod client; 7 | mod entity_query; 8 | pub mod local_player; 9 | pub mod ping; 10 | pub mod player; 11 | mod plugins; 12 | 13 | #[cfg(feature = "log")] 14 | #[doc(hidden)] 15 | pub mod test_utils; 16 | 17 | pub use account::{Account, AccountOpts}; 18 | pub use azalea_physics::local_player::{PhysicsState, SprintDirection, WalkDirection}; 19 | pub use azalea_protocol::common::client_information::ClientInformation; 20 | // Re-export bevy-tasks so plugins can make sure that they're using the same 21 | // version. 22 | pub use bevy_tasks; 23 | pub use client::{ 24 | Client, InConfigState, InGameState, JoinedClientBundle, LocalPlayerBundle, StartClientOpts, 25 | start_ecs_runner, 26 | }; 27 | pub use events::Event; 28 | pub use movement::{StartSprintEvent, StartWalkEvent}; 29 | pub use plugins::*; 30 | -------------------------------------------------------------------------------- /azalea-crypto/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "azalea-crypto" 3 | description = "Cryptography features used in Minecraft." 4 | version.workspace = true 5 | edition.workspace = true 6 | license.workspace = true 7 | repository.workspace = true 8 | 9 | [dev-dependencies] 10 | criterion.workspace = true 11 | 12 | [dependencies] 13 | aes.workspace = true 14 | azalea-buf = { workspace = true, optional = true } 15 | cfb8.workspace = true 16 | num-bigint.workspace = true 17 | rand = { workspace = true, features = ["os_rng"] } 18 | # TODO: Remove when rand is fixed. 19 | rand_core.workspace = true 20 | rsa = { workspace = true, features = ["sha2"] } 21 | rsa_public_encrypt_pkcs1.workspace = true 22 | sha1.workspace = true 23 | sha2.workspace = true 24 | uuid.workspace = true 25 | md-5.workspace = true 26 | 27 | [features] 28 | signing = ["dep:azalea-buf"] 29 | 30 | [[bench]] 31 | harness = false 32 | name = "my_benchmark" 33 | 34 | [lints] 35 | workspace = true 36 | -------------------------------------------------------------------------------- /azalea-world/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "azalea-world" 3 | description = "The Minecraft world representation used in Azalea." 4 | version.workspace = true 5 | edition.workspace = true 6 | license.workspace = true 7 | repository.workspace = true 8 | 9 | [dev-dependencies] 10 | azalea-client.path = "../azalea-client" 11 | criterion.workspace = true 12 | 13 | [dependencies] 14 | azalea-block.workspace = true 15 | azalea-buf.workspace = true 16 | azalea-core = { workspace = true, features = ["bevy_ecs"] } 17 | azalea-registry.workspace = true 18 | bevy_ecs.workspace = true 19 | derive_more = { workspace = true, features = ["deref", "deref_mut"] } 20 | nohash-hasher.workspace = true 21 | parking_lot.workspace = true 22 | rustc-hash.workspace = true 23 | serde = { workspace = true, optional = true } 24 | tracing.workspace = true 25 | 26 | [features] 27 | serde = ["dep:serde"] 28 | 29 | [[bench]] 30 | name = "chunks" 31 | harness = false 32 | 33 | [lints] 34 | workspace = true 35 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/game/c_update_recipes.rs: -------------------------------------------------------------------------------- 1 | use std::collections::HashMap; 2 | 3 | use azalea_buf::AzBuf; 4 | use azalea_registry::identifier::Identifier; 5 | use azalea_protocol_macros::ClientboundGamePacket; 6 | use azalea_registry::builtin::ItemKind; 7 | 8 | use crate::common::recipe::{Ingredient, SlotDisplayData}; 9 | 10 | #[derive(AzBuf, ClientboundGamePacket, Clone, Debug, PartialEq)] 11 | pub struct ClientboundUpdateRecipes { 12 | pub item_sets: HashMap, 13 | pub stonecutter_recipes: Vec, 14 | } 15 | 16 | #[derive(AzBuf, Clone, Debug, PartialEq)] 17 | pub struct SingleInputEntry { 18 | pub input: Ingredient, 19 | pub recipe: SelectableRecipe, 20 | } 21 | #[derive(AzBuf, Clone, Debug, PartialEq)] 22 | pub struct SelectableRecipe { 23 | pub option_display: SlotDisplayData, 24 | } 25 | 26 | #[derive(AzBuf, Clone, Debug, PartialEq)] 27 | pub struct RecipePropertySet { 28 | pub items: Vec, 29 | } 30 | -------------------------------------------------------------------------------- /azalea/examples/testbot/commands/combat.rs: -------------------------------------------------------------------------------- 1 | use azalea::brigadier::prelude::*; 2 | use parking_lot::Mutex; 3 | 4 | use super::{CommandSource, Ctx}; 5 | 6 | pub fn register(commands: &mut CommandDispatcher>) { 7 | commands.register( 8 | literal("killaura").then(argument("enabled", bool()).executes(|ctx: &Ctx| { 9 | let enabled = get_bool(ctx, "enabled").unwrap(); 10 | let source = ctx.source.lock(); 11 | let bot = source.bot.clone(); 12 | { 13 | let mut ecs = bot.ecs.lock(); 14 | let mut entity = ecs.entity_mut(bot.entity); 15 | let mut state = entity.get_mut::().unwrap(); 16 | state.killaura = enabled 17 | } 18 | source.reply(if enabled { 19 | "Enabled killaura" 20 | } else { 21 | "Disabled killaura" 22 | }); 23 | 1 24 | })), 25 | ); 26 | } 27 | -------------------------------------------------------------------------------- /azalea-brigadier/src/lib.rs: -------------------------------------------------------------------------------- 1 | #![doc = include_str!("../README.md")] 2 | 3 | pub mod arguments; 4 | pub mod builder; 5 | pub mod command_dispatcher; 6 | pub mod context; 7 | pub mod errors; 8 | pub mod modifier; 9 | pub mod parse_results; 10 | pub mod result_consumer; 11 | pub mod string_reader; 12 | pub mod suggestion; 13 | pub mod tree; 14 | 15 | pub mod prelude { 16 | pub use crate::{ 17 | arguments::{ 18 | bool_argument_type::{bool, get_bool}, 19 | double_argument_type::{double, get_double}, 20 | float_argument_type::{float, get_float}, 21 | integer_argument_type::{get_integer, integer}, 22 | long_argument_type::{get_long, long}, 23 | string_argument_type::{get_string, greedy_string, string, word}, 24 | }, 25 | builder::{literal_argument_builder::literal, required_argument_builder::argument}, 26 | command_dispatcher::CommandDispatcher, 27 | context::CommandContext, 28 | }; 29 | } 30 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/game/c_explode.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::{AzBuf, AzaleaRead, AzaleaWrite}; 2 | use azalea_core::position::Vec3; 3 | use azalea_entity::particle::Particle; 4 | use azalea_protocol_macros::ClientboundGamePacket; 5 | use azalea_registry::builtin::SoundEvent; 6 | 7 | #[derive(AzBuf, ClientboundGamePacket, Clone, Debug, PartialEq)] 8 | pub struct ClientboundExplode { 9 | pub center: Vec3, 10 | pub radius: f32, 11 | pub block_count: i32, 12 | pub player_knockback: Option, 13 | pub explosion_particle: Particle, 14 | pub explosion_sound: SoundEvent, 15 | pub block_particles: Vec>, 16 | } 17 | 18 | #[derive(AzBuf, Clone, Debug, PartialEq)] 19 | pub struct Weighted { 20 | pub value: T, 21 | #[var] 22 | pub weight: i32, 23 | } 24 | 25 | #[derive(AzBuf, Clone, Debug, PartialEq)] 26 | pub struct ExplosionParticleInfo { 27 | pub particle: Particle, 28 | pub scaling: f32, 29 | pub speed: f32, 30 | } 31 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/game/c_login.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | use azalea_registry::identifier::Identifier; 3 | use azalea_protocol_macros::ClientboundGamePacket; 4 | use azalea_world::MinecraftEntityId; 5 | 6 | use crate::packets::common::CommonPlayerSpawnInfo; 7 | 8 | /// The first packet sent by the server to the client after login. 9 | /// 10 | /// This packet contains information about the state of the player, the 11 | /// world, and the registry. 12 | #[derive(AzBuf, ClientboundGamePacket, Clone, Debug, PartialEq)] 13 | pub struct ClientboundLogin { 14 | pub player_id: MinecraftEntityId, 15 | pub hardcore: bool, 16 | pub levels: Vec, 17 | #[var] 18 | pub max_players: i32, 19 | #[var] 20 | pub chunk_radius: u32, 21 | #[var] 22 | pub simulation_distance: u32, 23 | pub reduced_debug_info: bool, 24 | pub show_death_screen: bool, 25 | pub do_limited_crafting: bool, 26 | pub common: CommonPlayerSpawnInfo, 27 | pub enforces_secure_chat: bool, 28 | } 29 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/game/s_player_abilities.rs: -------------------------------------------------------------------------------- 1 | use std::io::{self, Cursor, Write}; 2 | 3 | use azalea_buf::{AzaleaRead, AzaleaWrite}; 4 | use azalea_core::bitset::FixedBitSet; 5 | use azalea_protocol_macros::ServerboundGamePacket; 6 | 7 | use crate::packets::BufReadError; 8 | 9 | #[derive(Clone, Debug, PartialEq, ServerboundGamePacket)] 10 | pub struct ServerboundPlayerAbilities { 11 | pub is_flying: bool, 12 | } 13 | 14 | impl AzaleaRead for ServerboundPlayerAbilities { 15 | fn azalea_read(buf: &mut Cursor<&[u8]>) -> Result { 16 | let set = FixedBitSet::<2>::azalea_read(buf)?; 17 | Ok(Self { 18 | is_flying: set.index(1), 19 | }) 20 | } 21 | } 22 | 23 | impl AzaleaWrite for ServerboundPlayerAbilities { 24 | fn azalea_write(&self, buf: &mut impl Write) -> io::Result<()> { 25 | let mut set = FixedBitSet::<2>::new(); 26 | if self.is_flying { 27 | set.set(1); 28 | } 29 | set.azalea_write(buf) 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /codegen/genblocks.py: -------------------------------------------------------------------------------- 1 | import lib.code.version 2 | import lib.code.shapes 3 | import lib.code.packet 4 | import lib.code.blocks 5 | import lib.code.utils 6 | import lib.download 7 | import lib.extract 8 | import lib.utils 9 | 10 | 11 | def generate(version_id): 12 | pumpkin_blocks_data = lib.extract.get_pumpkin_data(version_id, "blocks") 13 | burger_data = lib.extract.get_burger_data_for_version(version_id) 14 | 15 | block_states_report = lib.extract.get_block_states_report(version_id) 16 | registries = lib.extract.get_builtin_registries_report(version_id) 17 | ordered_blocks = lib.code.blocks.get_ordered_blocks(registries) 18 | 19 | lib.code.blocks.generate_blocks( 20 | block_states_report, pumpkin_blocks_data, ordered_blocks, burger_data 21 | ) 22 | lib.code.shapes.generate_block_shapes(pumpkin_blocks_data, block_states_report) 23 | 24 | lib.code.utils.fmt() 25 | 26 | print("Done!") 27 | 28 | 29 | if __name__ == "__main__": 30 | generate(lib.code.version.get_version_id()) 31 | -------------------------------------------------------------------------------- /azalea/src/auto_respawn.rs: -------------------------------------------------------------------------------- 1 | use azalea_client::{ 2 | packet::{death_event_on_0_health, game::DeathEvent}, 3 | respawn::{PerformRespawnEvent, perform_respawn}, 4 | }; 5 | use bevy_app::Update; 6 | use bevy_ecs::prelude::*; 7 | 8 | use crate::app::{App, Plugin}; 9 | 10 | /// A plugin that makes [`DeathEvent`]s send [`PerformRespawnEvent`]s. 11 | #[derive(Clone, Default)] 12 | pub struct AutoRespawnPlugin; 13 | impl Plugin for AutoRespawnPlugin { 14 | fn build(&self, app: &mut App) { 15 | app.add_systems( 16 | Update, 17 | auto_respawn 18 | .before(perform_respawn) 19 | .after(death_event_on_0_health), 20 | ); 21 | } 22 | } 23 | 24 | fn auto_respawn( 25 | mut events: MessageReader, 26 | mut perform_respawn_events: MessageWriter, 27 | ) { 28 | for event in events.read() { 29 | perform_respawn_events.write(PerformRespawnEvent { 30 | entity: event.entity, 31 | }); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /azalea-language/src/lib.rs: -------------------------------------------------------------------------------- 1 | #![doc = include_str!("../README.md")] 2 | 3 | use std::{collections::HashMap, sync::LazyLock}; 4 | 5 | use compact_str::CompactString; 6 | 7 | static STORAGE: LazyLock> = LazyLock::new(|| { 8 | let json = 9 | serde_json::from_str::>(include_str!("en_us.json")) 10 | .unwrap(); 11 | let mut json = json.into_iter().collect::>(); 12 | 13 | // sort by key to make binary search work 14 | json.sort_by(|a, b| a.0.cmp(&b.0)); 15 | 16 | json.into_boxed_slice() 17 | }); 18 | 19 | /// Get the string for the given translation ID. 20 | /// 21 | /// This just does a lookup in Minecraft's `en_us.json` file. 22 | pub fn get(key: &str) -> Option<&str> { 23 | let key = CompactString::from(key); 24 | let storage = &*STORAGE; 25 | // more memory efficient than a hashmap lookup 26 | let index = storage.binary_search_by(|(k, _)| k.cmp(&key)); 27 | index.ok().map(|i| storage[i].1.as_str()) 28 | } 29 | -------------------------------------------------------------------------------- /azalea-auth/README.md: -------------------------------------------------------------------------------- 1 | # `azalea-auth` 2 | 3 | A port of Mojang's Authlib and launcher authentication. 4 | 5 | The default location of Azalea's cache is at `~/.minecraft/azalea-auth.json`. 6 | You can delete or modify this file if you'd like to associate a cache key (usually an email) with a different account. 7 | 8 | # Examples 9 | 10 | ```no_run 11 | use std::path::PathBuf; 12 | 13 | #[tokio::main] 14 | async fn main() { 15 | let cache_file = PathBuf::from("example_cache.json"); 16 | 17 | let auth_result = azalea_auth::auth( 18 | "example@example.com", 19 | azalea_auth::AuthOpts { 20 | cache_file: Some(cache_file), 21 | ..Default::default() 22 | }, 23 | ) 24 | .await 25 | .unwrap(); 26 | println!("{auth_result:?}"); 27 | } 28 | ``` 29 | 30 | Thanks to [wiki contributors](https://minecraft.wiki/w/Microsoft_authentication), [Overhash](https://gist.github.com/OverHash/a71b32846612ba09d8f79c9d775bfadf), and [prismarine-auth contributors](https://github.com/PrismarineJS/prismarine-auth). 31 | -------------------------------------------------------------------------------- /azalea-core/src/attribute_modifier_operation.rs: -------------------------------------------------------------------------------- 1 | use std::str::FromStr; 2 | 3 | use azalea_buf::AzBuf; 4 | use serde::Serialize; 5 | use simdnbt::{FromNbtTag, borrow::NbtTag}; 6 | 7 | #[derive(AzBuf, Clone, Copy, Debug, PartialEq, Serialize)] 8 | #[serde(rename_all = "snake_case")] 9 | pub enum AttributeModifierOperation { 10 | AddValue, 11 | AddMultipliedBase, 12 | AddMultipliedTotal, 13 | } 14 | 15 | impl FromStr for AttributeModifierOperation { 16 | type Err = (); 17 | 18 | fn from_str(s: &str) -> Result { 19 | let value: AttributeModifierOperation = match s { 20 | "add_value" => Self::AddValue, 21 | "add_multiplied_base" => Self::AddMultipliedBase, 22 | "add_multiplied_total" => Self::AddMultipliedTotal, 23 | _ => return Err(()), 24 | }; 25 | Ok(value) 26 | } 27 | } 28 | impl FromNbtTag for AttributeModifierOperation { 29 | fn from_nbt_tag(tag: NbtTag) -> Option { 30 | let v = tag.string()?; 31 | Self::from_str(&v.to_str()).ok() 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /azalea-client/src/plugins/respawn.rs: -------------------------------------------------------------------------------- 1 | use azalea_protocol::packets::game::s_client_command::{self, ServerboundClientCommand}; 2 | use bevy_app::{App, Plugin, Update}; 3 | use bevy_ecs::prelude::*; 4 | 5 | use crate::packet::game::SendGamePacketEvent; 6 | 7 | /// Tell the server that we're respawning. 8 | #[derive(Clone, Debug, Message)] 9 | pub struct PerformRespawnEvent { 10 | pub entity: Entity, 11 | } 12 | 13 | /// A plugin that makes [`PerformRespawnEvent`] send the packet to respawn. 14 | pub struct RespawnPlugin; 15 | impl Plugin for RespawnPlugin { 16 | fn build(&self, app: &mut App) { 17 | app.add_message::() 18 | .add_systems(Update, perform_respawn); 19 | } 20 | } 21 | 22 | pub fn perform_respawn(mut events: MessageReader, mut commands: Commands) { 23 | for event in events.read() { 24 | commands.trigger(SendGamePacketEvent::new( 25 | event.entity, 26 | ServerboundClientCommand { 27 | action: s_client_command::Action::PerformRespawn, 28 | }, 29 | )); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/game/c_set_entity_data.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | use azalea_entity::EntityMetadataItems; 3 | use azalea_protocol_macros::ClientboundGamePacket; 4 | use azalea_world::MinecraftEntityId; 5 | 6 | #[derive(AzBuf, ClientboundGamePacket, Clone, Debug, PartialEq)] 7 | pub struct ClientboundSetEntityData { 8 | #[var] 9 | pub id: MinecraftEntityId, 10 | pub packed_items: EntityMetadataItems, 11 | } 12 | 13 | #[cfg(test)] 14 | mod tests { 15 | use std::io::Cursor; 16 | 17 | use azalea_buf::AzaleaRead; 18 | 19 | use super::*; 20 | 21 | #[test] 22 | fn test_read_6b6t_entity_data() { 23 | let contents = [ 24 | 254, 180, 160, 8, 11, 33, 190, 230, 102, 102, 0, 0, 0, 0, 191, 0, 0, 0, 12, 33, 63, 25 | 102, 102, 102, 63, 25, 153, 154, 63, 102, 102, 102, 23, 14, 234, 64, 255, 26 | ]; 27 | let mut buf = Cursor::new(contents.as_slice()); 28 | let packet = ClientboundSetEntityData::azalea_read(&mut buf).unwrap(); 29 | println!("{packet:?}"); 30 | 31 | assert_eq!(buf.position(), contents.len() as u64); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 mat 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /azalea-brigadier/src/context/string_range.rs: -------------------------------------------------------------------------------- 1 | use std::cmp; 2 | 3 | #[derive(Clone, Copy, Debug, Default, Eq, Hash, PartialEq)] 4 | pub struct StringRange { 5 | start: usize, 6 | end: usize, 7 | } 8 | 9 | impl StringRange { 10 | pub fn new(start: usize, end: usize) -> Self { 11 | Self { start, end } 12 | } 13 | 14 | pub fn at(pos: usize) -> Self { 15 | Self::new(pos, pos) 16 | } 17 | 18 | pub fn between(start: usize, end: usize) -> Self { 19 | Self::new(start, end) 20 | } 21 | 22 | pub fn encompassing(a: &Self, b: &Self) -> Self { 23 | Self::new(cmp::min(a.start, b.start), cmp::max(a.end, b.end)) 24 | } 25 | 26 | pub fn start(&self) -> usize { 27 | self.start 28 | } 29 | 30 | pub fn end(&self) -> usize { 31 | self.end 32 | } 33 | 34 | pub fn get<'a>(&self, reader: &'a str) -> &'a str { 35 | &reader[self.start..self.end] 36 | } 37 | 38 | pub fn is_empty(&self) -> bool { 39 | self.start == self.end 40 | } 41 | 42 | pub fn length(&self) -> usize { 43 | self.end - self.start 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /azalea-client/tests/simulation/ticks_alive.rs: -------------------------------------------------------------------------------- 1 | use azalea_client::{test_utils::prelude::*, tick_counter::TicksConnected}; 2 | use azalea_protocol::packets::ConnectionProtocol; 3 | 4 | #[test] 5 | fn counter_increments_and_resets_on_disconnect() { 6 | let _lock = init(); 7 | 8 | let mut simulation = Simulation::new(ConnectionProtocol::Game); 9 | simulation.tick(); 10 | 11 | assert!(!simulation.has_component::()); 12 | simulation.receive_packet(default_login_packet()); 13 | simulation.tick(); 14 | 15 | assert!(simulation.has_component::()); 16 | assert_eq!(simulation.component::().0, 1); 17 | 18 | // Tick three times; counter should read 2, 3, 4. 19 | for expected in 2..=4 { 20 | simulation.tick(); 21 | let counter = simulation.component::(); 22 | assert_eq!( 23 | counter.0, expected, 24 | "after {expected} tick(s) counter should be {expected}" 25 | ); 26 | } 27 | 28 | simulation.disconnect(); 29 | simulation.tick(); 30 | 31 | assert!(!simulation.has_component::()); 32 | } 33 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/config/mod.rs: -------------------------------------------------------------------------------- 1 | // NOTE: This file is @generated automatically by codegen/packet.py. 2 | // Don't edit it directly! 3 | 4 | use azalea_protocol_macros::declare_state_packets; 5 | 6 | declare_state_packets!(ConfigPacket, 7 | Clientbound => [ 8 | cookie_request, 9 | custom_payload, 10 | disconnect, 11 | finish_configuration, 12 | keep_alive, 13 | ping, 14 | reset_chat, 15 | registry_data, 16 | resource_pack_pop, 17 | resource_pack_push, 18 | store_cookie, 19 | transfer, 20 | update_enabled_features, 21 | update_tags, 22 | select_known_packs, 23 | custom_report_details, 24 | server_links, 25 | clear_dialog, 26 | show_dialog, 27 | code_of_conduct, 28 | ], 29 | Serverbound => [ 30 | client_information, 31 | cookie_response, 32 | custom_payload, 33 | finish_configuration, 34 | keep_alive, 35 | pong, 36 | resource_pack, 37 | select_known_packs, 38 | custom_click_action, 39 | accept_code_of_conduct, 40 | ] 41 | ); 42 | -------------------------------------------------------------------------------- /azalea-core/src/lib.rs: -------------------------------------------------------------------------------- 1 | #![allow(incomplete_features)] 2 | #![feature(generic_const_exprs)] 3 | #![doc = include_str!("../README.md")] 4 | 5 | pub mod aabb; 6 | pub mod attribute_modifier_operation; 7 | pub mod bitset; 8 | pub mod checksum; 9 | pub mod codec_utils; 10 | pub mod color; 11 | pub mod cursor3d; 12 | pub mod data_registry; 13 | pub mod delta; 14 | pub mod difficulty; 15 | pub mod direction; 16 | pub mod filterable; 17 | pub mod game_type; 18 | pub mod hit_result; 19 | pub mod math; 20 | pub mod objectives; 21 | pub mod position; 22 | pub mod registry_holder; 23 | #[doc(hidden)] 24 | pub mod resource_location { 25 | #![deprecated(note = "moved to `azalea_registry::identifier`.")] 26 | #[deprecated(note = "moved to `azalea_registry::identifier::Identifier`.")] 27 | pub type ResourceLocation = azalea_registry::identifier::Identifier; 28 | } 29 | #[doc(hidden)] 30 | pub mod identifier { 31 | #![deprecated(note = "moved to `azalea_registry::identifier`.")] 32 | #[deprecated(note = "moved to `azalea_registry::identifier::Identifier`.")] 33 | pub type Identifier = azalea_registry::identifier::Identifier; 34 | } 35 | pub mod sound; 36 | #[cfg(feature = "bevy_ecs")] 37 | pub mod tick; 38 | pub mod tier; 39 | -------------------------------------------------------------------------------- /azalea-world/benches/chunks.rs: -------------------------------------------------------------------------------- 1 | use std::hint::black_box; 2 | 3 | use azalea_core::position::ChunkBlockPos; 4 | use azalea_registry::builtin::BlockKind; 5 | use azalea_world::{BitStorage, Chunk}; 6 | use criterion::{Criterion, criterion_group, criterion_main}; 7 | 8 | fn bench_chunks(c: &mut Criterion) { 9 | c.bench_function("Chunk::set", |b| { 10 | b.iter(|| { 11 | let mut chunk = Chunk::default(); 12 | 13 | for x in 0..16 { 14 | for z in 0..16 { 15 | chunk.set_block_state( 16 | &ChunkBlockPos::new(x, 1, z), 17 | BlockKind::Bedrock.into(), 18 | 0, 19 | ); 20 | } 21 | } 22 | 23 | black_box(chunk); 24 | }); 25 | }); 26 | } 27 | 28 | fn bench_bitstorage(c: &mut Criterion) { 29 | c.bench_function("BitStorage::set", |b| { 30 | let mut storage = BitStorage::new(1, 4096, None).unwrap(); 31 | b.iter(|| { 32 | storage.set(136, 1); 33 | }); 34 | black_box(storage); 35 | }); 36 | } 37 | 38 | criterion_group!(benches, bench_chunks, bench_bitstorage); 39 | criterion_main!(benches); 40 | -------------------------------------------------------------------------------- /azalea-auth/examples/auth_manual.rs: -------------------------------------------------------------------------------- 1 | //! Authenticate with Microsoft and get a Minecraft profile, but don't cache and 2 | //! use our own code to display the link code. 3 | //! 4 | //! If you still want it to cache, look at the code in [`azalea_auth::auth`] and 5 | //! see how that does it. 6 | 7 | use std::error::Error; 8 | 9 | use azalea_auth::ProfileResponse; 10 | 11 | #[tokio::main] 12 | async fn main() -> Result<(), Box> { 13 | env_logger::init(); 14 | 15 | let profile = auth().await?; 16 | println!("Logged in as {}", profile.name); 17 | 18 | Ok(()) 19 | } 20 | 21 | // We will be using default `client_id` and `scope` 22 | async fn auth() -> Result> { 23 | let client = reqwest::Client::new(); 24 | 25 | let res = azalea_auth::get_ms_link_code(&client, None, None).await?; 26 | println!( 27 | "Go to {} and enter the code {}", 28 | res.verification_uri, res.user_code 29 | ); 30 | let msa = azalea_auth::get_ms_auth_token(&client, res, None).await?; 31 | let auth_result = azalea_auth::get_minecraft_token(&client, &msa.data.access_token).await?; 32 | Ok(azalea_auth::get_profile(&client, &auth_result.minecraft_access_token).await?) 33 | } 34 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/game/c_command_suggestions.rs: -------------------------------------------------------------------------------- 1 | use azalea_brigadier::suggestion::Suggestions; 2 | use azalea_buf::AzBuf; 3 | use azalea_protocol_macros::ClientboundGamePacket; 4 | 5 | #[derive(AzBuf, ClientboundGamePacket, Clone, Debug, PartialEq)] 6 | pub struct ClientboundCommandSuggestions { 7 | #[var] 8 | pub id: u32, 9 | pub suggestions: Suggestions, 10 | } 11 | 12 | #[cfg(test)] 13 | mod tests { 14 | use std::io::Cursor; 15 | 16 | use azalea_brigadier::{context::StringRange, suggestion::Suggestion}; 17 | use azalea_buf::{AzaleaRead, AzaleaWrite}; 18 | 19 | use super::*; 20 | 21 | #[test] 22 | fn test_suggestions() { 23 | let suggestions = Suggestions::new( 24 | StringRange::new(0, 5), 25 | vec![Suggestion::new_with_tooltip( 26 | StringRange::new(1, 4), 27 | "foo", 28 | "bar".to_owned(), 29 | )], 30 | ); 31 | let mut buf = Vec::new(); 32 | suggestions.azalea_write(&mut buf).unwrap(); 33 | let mut cursor = Cursor::new(&buf[..]); 34 | let suggestions = Suggestions::azalea_read(&mut cursor).unwrap(); 35 | assert_eq!(suggestions, suggestions); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /azalea/benches/checks.rs: -------------------------------------------------------------------------------- 1 | use std::hint::black_box; 2 | 3 | use azalea::pathfinder::mining::MiningCache; 4 | use azalea_registry::builtin::BlockKind; 5 | use criterion::{Criterion, criterion_group, criterion_main}; 6 | 7 | fn benchmark(c: &mut Criterion) { 8 | let mining_cache = MiningCache::new(None); 9 | 10 | let stone = BlockKind::Stone.into(); 11 | c.bench_function("is_liquid stone", |b| { 12 | b.iter(|| mining_cache.is_liquid(black_box(stone))); 13 | }); 14 | 15 | let water = BlockKind::Water.into(); 16 | c.bench_function("is_liquid water", |b| { 17 | b.iter(|| mining_cache.is_liquid(black_box(water))); 18 | }); 19 | 20 | let lava = BlockKind::Lava.into(); 21 | c.bench_function("is_liquid lava", |b| { 22 | b.iter(|| mining_cache.is_liquid(black_box(lava))); 23 | }); 24 | 25 | let waterlogged_slab = azalea_block::blocks::OakSlab { 26 | kind: azalea_block::properties::Type::Bottom, 27 | waterlogged: true, 28 | } 29 | .into(); 30 | c.bench_function("is_liquid waterlogged slab", |b| { 31 | b.iter(|| mining_cache.is_liquid(black_box(waterlogged_slab))); 32 | }); 33 | } 34 | 35 | criterion_group!(benches, benchmark); 36 | criterion_main!(benches); 37 | -------------------------------------------------------------------------------- /azalea-client/tests/simulation/receive_spawn_entity_and_start_config_packet.rs: -------------------------------------------------------------------------------- 1 | use azalea_client::{InConfigState, test_utils::prelude::*}; 2 | use azalea_core::position::Vec3; 3 | use azalea_protocol::packets::{ 4 | ConnectionProtocol, 5 | game::{ClientboundAddEntity, ClientboundStartConfiguration}, 6 | }; 7 | use azalea_registry::builtin::EntityKind; 8 | use azalea_world::InstanceName; 9 | use uuid::Uuid; 10 | 11 | #[test] 12 | fn test_receive_spawn_entity_and_start_config_packet() { 13 | let _lock = init(); 14 | 15 | let mut simulation = Simulation::new(ConnectionProtocol::Game); 16 | simulation.receive_packet(default_login_packet()); 17 | simulation.tick(); 18 | assert!(simulation.has_component::()); 19 | simulation.tick(); 20 | 21 | simulation.receive_packet(ClientboundAddEntity { 22 | id: 123.into(), 23 | uuid: Uuid::new_v4(), 24 | entity_type: EntityKind::ArmorStand, 25 | position: Vec3::ZERO, 26 | x_rot: 0, 27 | y_rot: 0, 28 | y_head_rot: 0, 29 | data: 0, 30 | movement: Default::default(), 31 | }); 32 | simulation.receive_packet(ClientboundStartConfiguration); 33 | 34 | simulation.tick(); 35 | assert!(simulation.has_component::()); 36 | } 37 | -------------------------------------------------------------------------------- /azalea-client/src/plugins/tick_end.rs: -------------------------------------------------------------------------------- 1 | //! Clients send a [`ServerboundClientTickEnd`] packet every tick. 2 | 3 | use azalea_core::tick::GameTick; 4 | use azalea_entity::LocalEntity; 5 | use azalea_physics::PhysicsSystems; 6 | use azalea_protocol::packets::game::ServerboundClientTickEnd; 7 | use azalea_world::InstanceName; 8 | use bevy_app::{App, Plugin}; 9 | use bevy_ecs::prelude::*; 10 | 11 | use crate::{mining::MiningSystems, packet::game::SendGamePacketEvent}; 12 | 13 | /// A plugin that makes clients send a [`ServerboundClientTickEnd`] packet every 14 | /// tick. 15 | pub struct TickEndPlugin; 16 | impl Plugin for TickEndPlugin { 17 | fn build(&self, app: &mut App) { 18 | app.add_systems( 19 | GameTick, 20 | // this has to happen after every other event that might send packets 21 | game_tick_packet 22 | .after(PhysicsSystems) 23 | .after(MiningSystems) 24 | .after(crate::movement::send_position), 25 | ); 26 | } 27 | } 28 | 29 | pub fn game_tick_packet( 30 | query: Query, With)>, 31 | mut commands: Commands, 32 | ) { 33 | for entity in query.iter() { 34 | commands.trigger(SendGamePacketEvent::new(entity, ServerboundClientTickEnd)); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /azalea-auth/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "azalea-auth" 3 | description = "A port of Mojang's Authlib and launcher authentication." 4 | version.workspace = true 5 | edition.workspace = true 6 | license.workspace = true 7 | repository.workspace = true 8 | 9 | [dependencies] 10 | azalea-buf.workspace = true 11 | azalea-crypto.workspace = true 12 | base64.workspace = true 13 | chrono = { workspace = true, features = ["serde"] } 14 | crypto-bigint.workspace = true # TODO: Remove when rsa is fixed. 15 | crypto-primes.workspace = true # TODO: Remove when rsa is fixed. 16 | indexmap.workspace = true 17 | reqwest = { workspace = true, optional = true, default-features = false, features = [ 18 | "json", 19 | "rustls-tls", 20 | ] } 21 | rsa.workspace = true 22 | signature.workspace = true # TODO: Remove when rsa is fixed. 23 | serde = { workspace = true, features = ["derive"] } 24 | serde_json.workspace = true 25 | thiserror.workspace = true 26 | tokio = { workspace = true, features = ["fs"] } 27 | tracing.workspace = true 28 | uuid = { workspace = true, features = ["serde", "v3"] } 29 | 30 | [dev-dependencies] 31 | env_logger.workspace = true 32 | tokio = { workspace = true, features = ["full"] } 33 | 34 | [features] 35 | default = ["online-mode"] 36 | online-mode = ["dep:reqwest"] 37 | 38 | [lints] 39 | workspace = true 40 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/game/s_test_instance_block_action.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | use azalea_chat::FormattedText; 3 | use azalea_core::position::{BlockPos, Vec3i}; 4 | use azalea_protocol_macros::ServerboundGamePacket; 5 | use azalea_registry::builtin::TestInstanceKind; 6 | 7 | use super::s_set_structure_block::Rotation; 8 | 9 | #[derive(AzBuf, Clone, Debug, PartialEq, ServerboundGamePacket)] 10 | pub struct ServerboundTestInstanceBlockAction { 11 | pub pos: BlockPos, 12 | pub action: Action, 13 | pub data: TestInstanceBlockEntityData, 14 | } 15 | 16 | #[derive(AzBuf, Clone, Copy, Debug, Default, PartialEq)] 17 | pub enum Action { 18 | #[default] 19 | Init, 20 | Query, 21 | Set, 22 | Reset, 23 | Save, 24 | Export, 25 | Run, 26 | } 27 | 28 | #[derive(AzBuf, Clone, Debug, Default, PartialEq)] 29 | pub struct TestInstanceBlockEntityData { 30 | pub test: Option, 31 | pub size: Vec3i, 32 | pub rotation: Rotation, 33 | pub ignore_entities: bool, 34 | pub status: TestInstanceBlockEntityStatus, 35 | pub error_message: Option, 36 | } 37 | 38 | #[derive(AzBuf, Clone, Copy, Debug, Default, PartialEq)] 39 | pub enum TestInstanceBlockEntityStatus { 40 | #[default] 41 | Cleared, 42 | Running, 43 | Finished, 44 | } 45 | -------------------------------------------------------------------------------- /azalea-core/src/color.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | 3 | #[derive(AzBuf, Clone, Copy, Debug, Default, Eq, PartialEq)] 4 | pub struct RgbColor { 5 | value: u32, 6 | } 7 | 8 | impl RgbColor { 9 | pub fn new(r: u8, g: u8, b: u8) -> Self { 10 | Self { 11 | value: ((r as u32) << 16) | ((g as u32) << 8) | (b as u32), 12 | } 13 | } 14 | 15 | pub fn red(&self) -> u8 { 16 | (self.value >> 16) as u8 17 | } 18 | 19 | pub fn green(&self) -> u8 { 20 | (self.value >> 8) as u8 21 | } 22 | 23 | pub fn blue(&self) -> u8 { 24 | self.value as u8 25 | } 26 | } 27 | 28 | #[derive(AzBuf, Clone, Copy, Debug, Default, Eq, PartialEq)] 29 | pub struct ArgbColor { 30 | value: u32, 31 | } 32 | 33 | impl ArgbColor { 34 | pub fn new(a: u8, r: u8, g: u8, b: u8) -> Self { 35 | Self { 36 | value: ((a as u32) << 24) | ((r as u32) << 16) | ((g as u32) << 8) | b as u32, 37 | } 38 | } 39 | 40 | pub fn alpha(&self) -> u8 { 41 | (self.value >> 24) as u8 42 | } 43 | 44 | pub fn red(&self) -> u8 { 45 | (self.value >> 16) as u8 46 | } 47 | 48 | pub fn green(&self) -> u8 { 49 | (self.value >> 8) as u8 50 | } 51 | 52 | pub fn blue(&self) -> u8 { 53 | self.value as u8 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/game/s_seen_advancements.rs: -------------------------------------------------------------------------------- 1 | use std::io::{self, Cursor, Write}; 2 | 3 | use azalea_buf::{AzBuf, AzaleaRead, AzaleaWrite}; 4 | use azalea_registry::identifier::Identifier; 5 | use azalea_protocol_macros::ServerboundGamePacket; 6 | 7 | use crate::packets::BufReadError; 8 | 9 | #[derive(Clone, Debug, PartialEq, ServerboundGamePacket)] 10 | pub struct ServerboundSeenAdvancements { 11 | pub action: Action, 12 | pub tab: Option, 13 | } 14 | 15 | #[derive(AzBuf, Clone, Copy, Debug, Eq, PartialEq)] 16 | pub enum Action { 17 | OpenedTab = 0, 18 | ClosedScreen = 1, 19 | } 20 | 21 | impl AzaleaRead for ServerboundSeenAdvancements { 22 | fn azalea_read(buf: &mut Cursor<&[u8]>) -> Result { 23 | let action = Action::azalea_read(buf)?; 24 | let tab = if action == Action::OpenedTab { 25 | Some(Identifier::azalea_read(buf)?) 26 | } else { 27 | None 28 | }; 29 | Ok(Self { action, tab }) 30 | } 31 | } 32 | 33 | impl AzaleaWrite for ServerboundSeenAdvancements { 34 | fn azalea_write(&self, buf: &mut impl Write) -> io::Result<()> { 35 | self.action.azalea_write(buf)?; 36 | if let Some(tab) = &self.tab { 37 | tab.azalea_write(buf)?; 38 | } 39 | Ok(()) 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /azalea-client/src/plugins/pong.rs: -------------------------------------------------------------------------------- 1 | use azalea_protocol::packets::{config, game}; 2 | use bevy_app::{App, Plugin}; 3 | use bevy_ecs::prelude::*; 4 | 5 | use super::packet::{ 6 | config::{ConfigPingEvent, SendConfigPacketEvent}, 7 | game::GamePingEvent, 8 | }; 9 | use crate::packet::game::SendGamePacketEvent; 10 | 11 | /// A plugin that replies to [`ClientboundPing`] packets with 12 | /// [`ServerboundPong`]. 13 | /// 14 | /// This works in both the `game` and `config` states. 15 | /// 16 | /// [`ClientboundPing`]: azalea_protocol::packets::game::ClientboundPing 17 | /// [`ServerboundPong`]: azalea_protocol::packets::game::ServerboundPong 18 | pub struct PongPlugin; 19 | impl Plugin for PongPlugin { 20 | fn build(&self, app: &mut App) { 21 | app.add_observer(reply_to_game_ping) 22 | .add_observer(reply_to_config_ping); 23 | } 24 | } 25 | 26 | pub fn reply_to_game_ping(ping: On, mut commands: Commands) { 27 | commands.trigger(SendGamePacketEvent::new( 28 | ping.entity, 29 | game::ServerboundPong { id: ping.packet.id }, 30 | )); 31 | } 32 | 33 | pub fn reply_to_config_ping(ping: On, mut commands: Commands) { 34 | commands.trigger(SendConfigPacketEvent::new( 35 | ping.entity, 36 | config::ServerboundPong { id: ping.packet.id }, 37 | )); 38 | } 39 | -------------------------------------------------------------------------------- /azalea-client/src/plugins/tick_counter.rs: -------------------------------------------------------------------------------- 1 | use azalea_core::tick::GameTick; 2 | use azalea_physics::PhysicsSystems; 3 | use azalea_world::InstanceName; 4 | use bevy_app::{App, Plugin}; 5 | use bevy_ecs::prelude::*; 6 | 7 | use crate::{mining::MiningSystems, movement::send_position, tick_broadcast::send_tick_broadcast}; 8 | 9 | /// Counts the number of game ticks elapsed on the **local client** since the 10 | /// `login` packet was received. 11 | #[derive(Clone, Component, Debug, Default, Eq, PartialEq)] 12 | pub struct TicksConnected(pub u64); 13 | 14 | /// Inserts the counter-increment system into the `GameTick` schedule **before** 15 | /// physics, mining and movement. 16 | pub struct TickCounterPlugin; 17 | 18 | impl Plugin for TickCounterPlugin { 19 | fn build(&self, app: &mut App) { 20 | app.add_systems( 21 | GameTick, 22 | increment_counter 23 | .before(PhysicsSystems) 24 | .before(MiningSystems) 25 | .before(send_position) 26 | .before(send_tick_broadcast), 27 | ); 28 | } 29 | } 30 | 31 | /// Increment the [`GameTickCounter`] on every entity that lives in an instance. 32 | fn increment_counter(mut query: Query<&mut TicksConnected, With>) { 33 | for mut counter in &mut query { 34 | counter.0 += 1; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/game/c_server_links.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | use azalea_protocol_macros::ClientboundGamePacket; 3 | 4 | use crate::common::server_links::ServerLinkEntry; 5 | 6 | #[derive(AzBuf, ClientboundGamePacket, Clone, Debug, PartialEq)] 7 | pub struct ClientboundServerLinks { 8 | pub links: Vec, 9 | } 10 | 11 | #[cfg(test)] 12 | mod tests { 13 | use std::io::Cursor; 14 | 15 | use azalea_buf::AzaleaRead; 16 | 17 | use super::*; 18 | 19 | #[test] 20 | fn test_read_server_links() { 21 | tracing_subscriber::fmt::try_init().ok(); 22 | let contents = [ 23 | 1, 0, 10, 8, 0, 5, 99, 111, 108, 111, 114, 0, 7, 35, 48, 48, 70, 66, 57, 65, 8, 0, 4, 24 | 116, 101, 120, 116, 0, 15, 65, 98, 111, 117, 116, 32, 86, 101, 108, 111, 99, 105, 116, 25 | 97, 98, 0, 40, 104, 116, 116, 112, 115, 58, 47, 47, 119, 105, 108, 108, 105, 97, 109, 26 | 50, 55, 56, 46, 110, 101, 116, 47, 112, 114, 111, 106, 101, 99, 116, 47, 118, 101, 108, 27 | 111, 99, 105, 116, 97, 98, 28 | ]; 29 | let mut buf = Cursor::new(contents.as_slice()); 30 | let packet = ClientboundServerLinks::azalea_read(&mut buf).unwrap(); 31 | println!("{packet:?}"); 32 | 33 | assert_eq!(buf.position(), contents.len() as u64); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/game/c_damage_event.rs: -------------------------------------------------------------------------------- 1 | use std::io::{self, Cursor, Write}; 2 | 3 | use azalea_buf::{AzBuf, AzaleaRead, AzaleaReadVar, AzaleaWrite, AzaleaWriteVar}; 4 | use azalea_core::position::Vec3; 5 | use azalea_protocol_macros::ClientboundGamePacket; 6 | use azalea_world::MinecraftEntityId; 7 | 8 | #[derive(AzBuf, ClientboundGamePacket, Clone, Debug, PartialEq)] 9 | pub struct ClientboundDamageEvent { 10 | #[var] 11 | pub entity_id: MinecraftEntityId, 12 | #[var] 13 | pub source_type_id: u32, 14 | pub source_cause_id: OptionalEntityId, 15 | pub source_direct_id: OptionalEntityId, 16 | pub source_position: Option, 17 | } 18 | 19 | #[derive(Clone, Debug, PartialEq)] 20 | pub struct OptionalEntityId(pub Option); 21 | impl AzaleaRead for OptionalEntityId { 22 | fn azalea_read(buf: &mut Cursor<&[u8]>) -> Result { 23 | match u32::azalea_read_var(buf)? { 24 | 0 => Ok(OptionalEntityId(None)), 25 | id => Ok(OptionalEntityId(Some(id - 1))), 26 | } 27 | } 28 | } 29 | impl AzaleaWrite for OptionalEntityId { 30 | fn azalea_write(&self, buf: &mut impl Write) -> io::Result<()> { 31 | match self.0 { 32 | Some(id) => (id + 1).azalea_write_var(buf), 33 | None => 0u32.azalea_write_var(buf), 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /azalea-brigadier/src/arguments/bool_argument_type.rs: -------------------------------------------------------------------------------- 1 | use std::{any::Any, sync::Arc}; 2 | 3 | use super::ArgumentType; 4 | use crate::{ 5 | context::CommandContext, 6 | errors::CommandSyntaxError, 7 | string_reader::StringReader, 8 | suggestion::{Suggestions, SuggestionsBuilder}, 9 | }; 10 | 11 | #[derive(Default)] 12 | struct Boolean; 13 | 14 | impl ArgumentType for Boolean { 15 | fn parse(&self, reader: &mut StringReader) -> Result, CommandSyntaxError> { 16 | Ok(Arc::new(reader.read_boolean()?)) 17 | } 18 | 19 | fn list_suggestions(&self, mut builder: SuggestionsBuilder) -> Suggestions { 20 | if "true".starts_with(builder.remaining_lowercase()) { 21 | builder = builder.suggest("true"); 22 | } 23 | if "false".starts_with(builder.remaining_lowercase()) { 24 | builder = builder.suggest("false"); 25 | } 26 | builder.build() 27 | } 28 | 29 | fn examples(&self) -> Vec { 30 | vec!["true".to_owned(), "false".to_owned()] 31 | } 32 | } 33 | 34 | pub fn bool() -> impl ArgumentType { 35 | Boolean 36 | } 37 | pub fn get_bool(context: &CommandContext, name: &str) -> Option { 38 | context 39 | .argument(name) 40 | .expect("argument with name not found") 41 | .downcast_ref::() 42 | .cloned() 43 | } 44 | -------------------------------------------------------------------------------- /azalea/src/swarm/events.rs: -------------------------------------------------------------------------------- 1 | use azalea_client::local_player::InstanceHolder; 2 | use azalea_world::MinecraftEntityId; 3 | use bevy_app::{App, Plugin, Update}; 4 | use bevy_ecs::prelude::*; 5 | use derive_more::{Deref, DerefMut}; 6 | 7 | pub struct SwarmPlugin; 8 | impl Plugin for SwarmPlugin { 9 | fn build(&self, app: &mut App) { 10 | app.add_message::() 11 | .add_systems(Update, check_ready) 12 | .init_resource::(); 13 | } 14 | } 15 | 16 | /// All the bots from the swarm are now in the world. 17 | #[derive(Message)] 18 | pub struct SwarmReadyEvent; 19 | 20 | #[derive(Default, Deref, DerefMut, Resource)] 21 | struct IsSwarmReady(bool); 22 | 23 | fn check_ready( 24 | query: Query, With>, 25 | mut is_swarm_ready: ResMut, 26 | mut ready_events: MessageWriter, 27 | ) { 28 | // if we already know the swarm is ready, do nothing 29 | if **is_swarm_ready { 30 | return; 31 | } 32 | // if all the players are in the world, we're ready 33 | for entity_id in query.iter() { 34 | if entity_id.is_none() { 35 | return; 36 | } 37 | } 38 | 39 | // all the players are in the world, so we're ready 40 | **is_swarm_ready = true; 41 | ready_events.write(SwarmReadyEvent); 42 | } 43 | -------------------------------------------------------------------------------- /.github/workflows/doc.yml: -------------------------------------------------------------------------------- 1 | name: Documentation 2 | 3 | on: 4 | push: 5 | branches: 6 | - main 7 | workflow_dispatch: 8 | 9 | permissions: 10 | contents: write 11 | pages: write 12 | id-token: write 13 | 14 | concurrency: 15 | group: "pages" 16 | cancel-in-progress: true 17 | 18 | jobs: 19 | deploy: 20 | environment: 21 | name: github-pages 22 | url: ${{ steps.deployment.outputs.page_url }} 23 | runs-on: ubuntu-latest 24 | steps: 25 | - uses: actions/checkout@v4 26 | 27 | - name: Install Nightly 28 | run: rustup update nightly && rustup default nightly 29 | 30 | - name: Cache dependencies 31 | uses: Swatinem/rust-cache@v2 32 | 33 | # Redirect to default page 34 | - run: cargo doc --workspace --no-deps 35 | - uses: "finnp/create-file-action@master" 36 | env: 37 | FILE_NAME: "./target/doc/index.html" 38 | FILE_DATA: '' 39 | 40 | - name: Setup Pages 41 | uses: actions/configure-pages@v5 42 | 43 | - name: Upload artifact 44 | uses: actions/upload-pages-artifact@v4 45 | with: 46 | path: "./target/doc/" 47 | 48 | - name: Deploy to GitHub Pages 49 | id: deployment 50 | uses: actions/deploy-pages@v4 51 | -------------------------------------------------------------------------------- /azalea/examples/testbot/commands.rs: -------------------------------------------------------------------------------- 1 | pub mod combat; 2 | pub mod debug; 3 | pub mod movement; 4 | 5 | use azalea::{ 6 | Client, brigadier::prelude::*, chat::ChatPacket, ecs::prelude::*, entity::metadata::Player, 7 | player::GameProfileComponent, 8 | }; 9 | use parking_lot::Mutex; 10 | 11 | use crate::State; 12 | 13 | pub type Ctx = CommandContext>; 14 | 15 | pub struct CommandSource { 16 | pub bot: Client, 17 | pub state: State, 18 | pub chat: ChatPacket, 19 | } 20 | 21 | impl CommandSource { 22 | pub fn reply(&self, message: impl Into) { 23 | let message = message.into(); 24 | if self.chat.is_whisper() { 25 | self.bot 26 | .chat(format!("/w {} {message}", self.chat.sender().unwrap())); 27 | } else { 28 | self.bot.chat(message); 29 | } 30 | } 31 | 32 | pub fn entity(&mut self) -> Option { 33 | let username = self.chat.sender()?; 34 | self.bot 35 | .any_entity_by::<&GameProfileComponent, With>( 36 | |profile: &GameProfileComponent| profile.name == username, 37 | ) 38 | } 39 | } 40 | 41 | pub fn register_commands(commands: &mut CommandDispatcher>) { 42 | combat::register(commands); 43 | debug::register(commands); 44 | movement::register(commands); 45 | } 46 | -------------------------------------------------------------------------------- /azalea-buf/azalea-buf-macros/src/lib.rs: -------------------------------------------------------------------------------- 1 | mod read; 2 | mod write; 3 | 4 | use proc_macro::TokenStream; 5 | use quote::quote; 6 | use syn::{DeriveInput, parse_macro_input}; 7 | 8 | #[proc_macro_derive(AzaleaRead, attributes(var))] 9 | pub fn derive_azalearead(input: TokenStream) -> TokenStream { 10 | let DeriveInput { 11 | ident, 12 | generics, 13 | data, 14 | .. 15 | } = parse_macro_input!(input); 16 | 17 | read::create_impl_azalearead(&ident, &generics, &data).into() 18 | } 19 | 20 | #[proc_macro_derive(AzaleaWrite, attributes(var))] 21 | pub fn derive_azaleawrite(input: TokenStream) -> TokenStream { 22 | let DeriveInput { 23 | ident, 24 | generics, 25 | data, 26 | .. 27 | } = parse_macro_input!(input); 28 | 29 | write::create_impl_azaleawrite(&ident, &generics, &data).into() 30 | } 31 | 32 | #[proc_macro_derive(AzBuf, attributes(var, limit))] 33 | pub fn derive_azbuf(input: TokenStream) -> TokenStream { 34 | let DeriveInput { 35 | ident, 36 | generics, 37 | data, 38 | .. 39 | } = parse_macro_input!(input); 40 | 41 | let writable = write::create_impl_azaleawrite(&ident, &generics, &data); 42 | let readable = read::create_impl_azalearead(&ident, &generics, &data); 43 | quote! { 44 | #writable 45 | #readable 46 | } 47 | .into() 48 | } 49 | -------------------------------------------------------------------------------- /azalea-client/src/plugins/brand.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzaleaWrite; 2 | use azalea_protocol::packets::config::s_custom_payload::ServerboundCustomPayload; 3 | use bevy_app::prelude::*; 4 | use bevy_ecs::prelude::*; 5 | 6 | use super::packet::config::SendConfigPacketEvent; 7 | use 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. 13 | pub struct BrandPlugin; 14 | impl Plugin for BrandPlugin { 15 | fn build(&self, app: &mut App) { 16 | app.add_systems(Update, send_brand.before(send_client_information)); 17 | } 18 | } 19 | 20 | pub fn send_brand(mut commands: Commands, mut removed: RemovedComponents) { 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 | } 34 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/game/c_container_set_content.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | use azalea_inventory::ItemStack; 3 | use azalea_protocol_macros::ClientboundGamePacket; 4 | 5 | #[derive(AzBuf, ClientboundGamePacket, Clone, Debug, PartialEq)] 6 | pub struct ClientboundContainerSetContent { 7 | #[var] 8 | pub container_id: i32, 9 | #[var] 10 | pub state_id: u32, 11 | pub items: Vec, 12 | pub carried_item: ItemStack, 13 | } 14 | 15 | #[cfg(test)] 16 | mod tests { 17 | use std::io::Cursor; 18 | 19 | use azalea_buf::AzaleaRead; 20 | 21 | use super::ClientboundContainerSetContent; 22 | 23 | #[test] 24 | fn test_read_write_container_set_content() { 25 | let contents = [ 26 | 1, 2, 63, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 27 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 28 | 0, 0, 0, 0, 0, 0, 0, 1, 196, 6, 0, 0, 0, 29 | ]; 30 | let mut buf = Cursor::new(contents.as_slice()); 31 | let packet = ClientboundContainerSetContent::azalea_read(&mut buf).unwrap(); 32 | println!("{packet:?}"); 33 | 34 | assert_eq!(buf.position(), contents.len() as u64); 35 | 36 | let mut buf = Vec::new(); 37 | packet.write(&mut buf).unwrap(); 38 | assert_eq!(buf, contents); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /azalea-inventory/azalea-inventory-macros/src/lib.rs: -------------------------------------------------------------------------------- 1 | mod location_enum; 2 | mod menu_enum; 3 | mod menu_impl; 4 | mod parse_macro; 5 | mod utils; 6 | 7 | use parse_macro::{DeclareMenus, Field}; 8 | use proc_macro::TokenStream; 9 | use proc_macro2::Span; 10 | use quote::quote; 11 | use syn::{Ident, parse_macro_input}; 12 | 13 | #[proc_macro] 14 | pub fn declare_menus(input: TokenStream) -> TokenStream { 15 | let mut input = parse_macro_input!(input as DeclareMenus); 16 | 17 | // implicitly add a `player` field at the end unless an `inventory` field 18 | // is present 19 | for menu in &mut input.menus { 20 | let mut inventory_field_missing = true; 21 | for field in &menu.fields { 22 | if matches!(field.name.to_string().as_str(), "inventory" | "player") { 23 | inventory_field_missing = false; 24 | } 25 | } 26 | if inventory_field_missing { 27 | menu.fields.push(Field { 28 | name: Ident::new("player", Span::call_site()), 29 | length: 36, 30 | }) 31 | } 32 | } 33 | 34 | let menu_enum = menu_enum::generate(&input); 35 | let menu_impl = menu_impl::generate(&input); 36 | let location_enum = location_enum::generate(&input); 37 | 38 | quote! { 39 | #menu_enum 40 | #menu_impl 41 | 42 | #location_enum 43 | } 44 | .into() 45 | } 46 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/common.rs: -------------------------------------------------------------------------------- 1 | use azalea_buf::AzBuf; 2 | use azalea_core::{ 3 | data_registry::ResolvableDataRegistry, 4 | game_type::{GameMode, OptionalGameType}, 5 | position::GlobalPos, 6 | registry_holder::{RegistryHolder, dimension_type::DimensionKindElement}, 7 | }; 8 | use azalea_registry::{data::DimensionKind, identifier::Identifier}; 9 | use tracing::error; 10 | 11 | #[derive(AzBuf, Clone, Debug, PartialEq)] 12 | pub struct CommonPlayerSpawnInfo { 13 | pub dimension_type: DimensionKind, 14 | pub dimension: Identifier, 15 | pub seed: i64, 16 | pub game_type: GameMode, 17 | pub previous_game_type: OptionalGameType, 18 | pub is_debug: bool, 19 | pub is_flat: bool, 20 | pub last_death_location: Option, 21 | #[var] 22 | pub portal_cooldown: u32, 23 | #[var] 24 | pub sea_level: i32, 25 | } 26 | impl CommonPlayerSpawnInfo { 27 | pub fn dimension_type<'a>( 28 | &self, 29 | registry_holder: &'a RegistryHolder, 30 | ) -> Option<(&'a Identifier, &'a DimensionKindElement)> { 31 | let dimension_res = self.dimension_type.resolve(registry_holder); 32 | let Some((dimension_type, dimension_data)) = dimension_res else { 33 | error!("Couldn't resolve dimension_type {:?}", self.dimension_type); 34 | return None; 35 | }; 36 | 37 | Some((dimension_type, dimension_data)) 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /azalea-protocol/src/packets/game/c_level_chunk_with_light.rs: -------------------------------------------------------------------------------- 1 | use std::sync::Arc; 2 | 3 | use azalea_buf::AzBuf; 4 | use azalea_protocol_macros::ClientboundGamePacket; 5 | use azalea_registry::builtin::BlockEntityKind; 6 | use azalea_world::heightmap::HeightmapKind; 7 | use simdnbt::owned::Nbt; 8 | 9 | use super::c_light_update::ClientboundLightUpdatePacketData; 10 | 11 | #[derive(AzBuf, ClientboundGamePacket, Clone, Debug, PartialEq)] 12 | pub struct ClientboundLevelChunkWithLight { 13 | // this can't be a ChunkPos since that reads z first and then x 14 | pub x: i32, 15 | pub z: i32, 16 | pub chunk_data: ClientboundLevelChunkPacketData, 17 | pub light_data: ClientboundLightUpdatePacketData, 18 | } 19 | 20 | #[derive(AzBuf, Clone, Debug, PartialEq)] 21 | pub struct ClientboundLevelChunkPacketData { 22 | pub heightmaps: Vec<(HeightmapKind, Box<[u64]>)>, 23 | /// The raw chunk sections. 24 | /// 25 | /// We can't parse the data in azalea-protocol because it depends on context 26 | /// from other packets 27 | /// 28 | /// This is an Arc because it's often very big and we want it to be cheap to 29 | /// clone. 30 | pub data: Arc>, 31 | pub block_entities: Vec, 32 | } 33 | 34 | #[derive(AzBuf, Clone, Debug, PartialEq)] 35 | pub struct BlockEntity { 36 | pub packed_xz: u8, 37 | pub y: u16, 38 | pub kind: BlockEntityKind, 39 | pub data: Nbt, 40 | } 41 | --------------------------------------------------------------------------------