From 6eee543a3367d38a6f0e9bffb457a2bd76a8f9cc Mon Sep 17 00:00:00 2001 From: mat <27899617+mat-1@users.noreply.github.com> Date: Sat, 12 Nov 2022 23:54:05 -0600 Subject: [PATCH] Pathfinder (#25) Pathfinding is very much not done, but it works enough and I want to get this merged. TODO: fast replanning, goals that aren't a single node, falling moves (it should be able to play the dropper), parkour moves --- .cargo/config.toml | 0 .github/workflows/check.yml | 0 .gitignore | 0 Cargo.lock | 570 ++++++----- Cargo.toml | 0 README.md | 0 azalea-auth/Cargo.toml | 0 azalea-auth/README.md | 0 azalea-auth/examples/auth.rs | 0 azalea-auth/src/auth.rs | 0 azalea-auth/src/cache.rs | 0 azalea-auth/src/sessionserver.rs | 0 azalea-block/Cargo.toml | 0 azalea-block/README.md | 0 azalea-block/azalea-block-macros/Cargo.toml | 0 azalea-block/azalea-block-macros/src/lib.rs | 0 azalea-block/azalea-block-macros/src/utils.rs | 0 azalea-block/src/behavior.rs | 0 azalea-block/src/blocks.rs | 0 azalea-block/src/lib.rs | 0 azalea-brigadier/Cargo.toml | 0 azalea-brigadier/src/suggestion/mod.rs | 0 .../src/suggestion/suggestions.rs | 0 azalea-buf/Cargo.toml | 0 azalea-buf/README.md | 0 azalea-buf/azalea-buf-macros/Cargo.toml | 0 azalea-buf/azalea-buf-macros/README.md | 0 azalea-buf/azalea-buf-macros/src/lib.rs | 0 azalea-buf/src/definitions.rs | 0 azalea-buf/src/lib.rs | 0 azalea-buf/src/read.rs | 0 azalea-buf/src/serializable_uuid.rs | 0 azalea-buf/src/write.rs | 0 azalea-chat/Cargo.toml | 0 azalea-chat/src/text_component.rs | 0 azalea-chat/src/translatable_component.rs | 0 azalea-client/Cargo.toml | 25 +- azalea-client/src/account.rs | 0 azalea-client/src/chat.rs | 2 +- azalea-client/src/client.rs | 97 +- azalea-client/src/get_mc_dir.rs | 0 azalea-client/src/lib.rs | 7 +- azalea-client/src/movement.rs | 198 +++- azalea-client/src/player.rs | 6 +- azalea-client/src/plugins.rs | 78 ++ azalea-core/Cargo.toml | 0 azalea-core/README.md | 0 azalea-core/src/aabb.rs | 42 +- azalea-core/src/bitset.rs | 0 azalea-core/src/block_hit_result.rs | 0 azalea-core/src/cursor3d.rs | 0 azalea-core/src/delta.rs | 23 - azalea-core/src/direction.rs | 58 ++ azalea-core/src/particle/mod.rs | 0 azalea-core/src/position.rs | 301 +++--- azalea-core/src/slot.rs | 0 azalea-crypto/Cargo.toml | 0 azalea-crypto/README.md | 0 azalea-crypto/benches/my_benchmark.rs | 0 azalea-crypto/src/lib.rs | 0 azalea-crypto/src/signing.rs | 0 azalea-language/Cargo.toml | 0 azalea-language/README.md | 0 azalea-language/src/en_us.json | 0 azalea-language/src/lib.rs | 0 azalea-nbt/Cargo.toml | 0 azalea-physics/Cargo.toml | 9 +- azalea-physics/README.md | 0 azalea-physics/src/collision/blocks.rs | 0 .../src/collision/dimension_collisions.rs | 7 +- .../src/collision/discrete_voxel_shape.rs | 0 azalea-physics/src/collision/mergers.rs | 0 azalea-physics/src/collision/mod.rs | 10 +- azalea-physics/src/collision/shape.rs | 0 azalea-physics/src/lib.rs | 49 +- azalea-protocol/Cargo.toml | 0 azalea-protocol/README.md | 0 .../azalea-protocol-macros/Cargo.toml | 0 .../azalea-protocol-macros/src/lib.rs | 0 azalea-protocol/src/connect.rs | 0 .../game/clientbound_add_entity_packet.rs | 0 .../clientbound_add_experience_orb_packet.rs | 0 .../game/clientbound_add_player_packet.rs | 0 .../game/clientbound_animate_packet.rs | 0 .../game/clientbound_award_stats_packet.rs | 0 .../clientbound_block_changed_ack_packet.rs | 0 .../clientbound_block_destruction_packet.rs | 0 .../clientbound_block_entity_data_packet.rs | 0 .../game/clientbound_block_event_packet.rs | 0 .../game/clientbound_block_update_packet.rs | 0 .../game/clientbound_boss_event_packet.rs | 0 .../game/clientbound_chat_preview_packet.rs | 0 .../clientbound_command_suggestions_packet.rs | 0 .../game/clientbound_commands_packet.rs | 0 ...lientbound_container_set_content_packet.rs | 0 .../clientbound_container_set_data_packet.rs | 0 .../clientbound_container_set_slot_packet.rs | 0 .../game/clientbound_cooldown_packet.rs | 0 ...entbound_custom_chat_completions_packet.rs | 0 .../game/clientbound_custom_sound_packet.rs | 0 .../game/clientbound_delete_chat_packet.rs | 0 .../game/clientbound_disconnect_packet.rs | 0 .../game/clientbound_entity_event_packet.rs | 0 .../game/clientbound_explode_packet.rs | 0 .../clientbound_forget_level_chunk_packet.rs | 0 .../game/clientbound_game_event_packet.rs | 0 .../clientbound_horse_screen_open_packet.rs | 0 .../clientbound_initialize_border_packet.rs | 0 .../game/clientbound_keep_alive_packet.rs | 0 ...ientbound_level_chunk_with_light_packet.rs | 0 .../game/clientbound_level_event_packet.rs | 0 .../clientbound_level_particles_packet.rs | 0 .../game/clientbound_light_update_packet.rs | 0 .../game/clientbound_map_item_data_packet.rs | 0 .../clientbound_merchant_offers_packet.rs | 0 .../clientbound_move_entity_pos_packet.rs | 0 .../clientbound_move_entity_pos_rot_packet.rs | 0 .../clientbound_move_entity_rot_packet.rs | 0 .../game/clientbound_move_vehicle_packet.rs | 0 .../game/clientbound_open_book_packet.rs | 0 .../game/clientbound_open_screen_packet.rs | 0 .../clientbound_open_sign_editor_packet.rs | 0 .../packets/game/clientbound_ping_packet.rs | 0 .../clientbound_place_ghost_recipe_packet.rs | 0 .../clientbound_player_chat_header_packet.rs | 0 .../game/clientbound_player_chat_packet.rs | 0 .../clientbound_player_combat_end_packet.rs | 0 .../clientbound_player_combat_enter_packet.rs | 0 .../clientbound_player_combat_kill_packet.rs | 0 .../game/clientbound_player_info_packet.rs | 0 .../game/clientbound_player_look_at_packet.rs | 0 .../clientbound_player_position_packet.rs | 0 .../packets/game/clientbound_recipe_packet.rs | 0 .../clientbound_remove_entities_packet.rs | 0 .../clientbound_remove_mob_effect_packet.rs | 0 .../game/clientbound_resource_pack_packet.rs | 0 .../game/clientbound_respawn_packet.rs | 0 .../game/clientbound_rotate_head_packet.rs | 0 ...lientbound_section_blocks_update_packet.rs | 0 ...entbound_select_advancements_tab_packet.rs | 0 .../game/clientbound_server_data_packet.rs | 0 .../clientbound_set_action_bar_text_packet.rs | 0 .../clientbound_set_border_center_packet.rs | 0 ...clientbound_set_border_lerp_size_packet.rs | 0 .../clientbound_set_border_size_packet.rs | 0 ...ntbound_set_border_warning_delay_packet.rs | 0 ...ound_set_border_warning_distance_packet.rs | 0 .../game/clientbound_set_camera_packet.rs | 0 ...ientbound_set_chunk_cache_center_packet.rs | 0 ...ientbound_set_chunk_cache_radius_packet.rs | 0 ...bound_set_default_spawn_position_packet.rs | 0 ...ntbound_set_display_chat_preview_packet.rs | 0 ...lientbound_set_display_objective_packet.rs | 0 .../clientbound_set_entity_data_packet.rs | 0 .../clientbound_set_entity_link_packet.rs | 0 .../clientbound_set_entity_motion_packet.rs | 0 .../game/clientbound_set_equipment_packet.rs | 0 .../game/clientbound_set_experience_packet.rs | 0 .../game/clientbound_set_health_packet.rs | 0 .../game/clientbound_set_objective_packet.rs | 0 .../game/clientbound_set_passengers_packet.rs | 0 .../clientbound_set_player_team_packet.rs | 0 .../game/clientbound_set_score_packet.rs | 0 ...entbound_set_simulation_distance_packet.rs | 0 .../clientbound_set_subtitle_text_packet.rs | 0 .../game/clientbound_set_time_packet.rs | 0 .../game/clientbound_set_title_text_packet.rs | 0 ...clientbound_set_titles_animation_packet.rs | 0 .../game/clientbound_sound_entity_packet.rs | 0 .../packets/game/clientbound_sound_packet.rs | 0 .../game/clientbound_stop_sound_packet.rs | 0 .../game/clientbound_system_chat_packet.rs | 0 .../game/clientbound_tab_list_packet.rs | 0 .../game/clientbound_tag_query_packet.rs | 0 .../clientbound_take_item_entity_packet.rs | 0 .../clientbound_teleport_entity_packet.rs | 0 .../clientbound_update_advancements_packet.rs | 0 .../clientbound_update_attributes_packet.rs | 40 +- .../clientbound_update_mob_effect_packet.rs | 0 .../game/clientbound_update_recipes_packet.rs | 0 azalea-protocol/src/packets/game/mod.rs | 0 ...serverbound_accept_teleportation_packet.rs | 0 .../serverbound_block_entity_tag_query.rs | 0 .../serverbound_change_difficulty_packet.rs | 0 .../game/serverbound_chat_ack_packet.rs | 0 .../game/serverbound_chat_command_packet.rs | 0 .../packets/game/serverbound_chat_packet.rs | 0 .../game/serverbound_chat_preview_packet.rs | 0 .../game/serverbound_client_command_packet.rs | 0 .../serverbound_client_information_packet.rs | 0 .../serverbound_command_suggestion_packet.rs | 0 ...rverbound_container_button_click_packet.rs | 0 .../serverbound_container_click_packet.rs | 0 .../serverbound_container_close_packet.rs | 0 .../game/serverbound_custom_payload_packet.rs | 0 .../game/serverbound_edit_book_packet.rs | 0 .../game/serverbound_entity_tag_query.rs | 0 .../game/serverbound_interact_packet.rs | 0 .../serverbound_jigsaw_generate_packet.rs | 0 .../game/serverbound_keep_alive_packet.rs | 0 .../serverbound_lock_difficulty_packet.rs | 0 .../serverbound_move_player_pos_packet.rs | 0 .../serverbound_move_player_pos_rot_packet.rs | 0 .../serverbound_move_player_rot_packet.rs | 0 ...verbound_move_player_status_only_packet.rs | 0 .../game/serverbound_move_vehicle_packet.rs | 0 .../game/serverbound_paddle_boat_packet.rs | 0 .../game/serverbound_pick_item_packet.rs | 0 .../game/serverbound_place_recipe_packet.rs | 0 .../serverbound_player_abilities_packet.rs | 0 .../game/serverbound_player_action_packet.rs | 0 .../game/serverbound_player_command_packet.rs | 0 .../game/serverbound_player_input_packet.rs | 0 .../packets/game/serverbound_pong_packet.rs | 0 ...ound_recipe_book_change_settings_packet.rs | 0 ...verbound_recipe_book_seen_recipe_packet.rs | 0 .../game/serverbound_rename_item_packet.rs | 0 .../game/serverbound_resource_pack_packet.rs | 0 .../serverbound_seen_advancements_packet.rs | 0 .../game/serverbound_select_trade_packet.rs | 0 .../game/serverbound_set_beacon_packet.rs | 0 .../serverbound_set_carried_item_packet.rs | 0 .../serverbound_set_command_block_packet.rs | 0 ...serverbound_set_command_minecart_packet.rs | 0 ...rverbound_set_creative_mode_slot_packet.rs | 0 .../serverbound_set_jigsaw_block_packet.rs | 0 .../serverbound_set_structure_block_packet.rs | 0 .../game/serverbound_sign_update_packet.rs | 0 .../packets/game/serverbound_swing_packet.rs | 0 .../serverbound_teleport_to_entity_packet.rs | 0 .../game/serverbound_use_item_on_packet.rs | 0 .../game/serverbound_use_item_packet.rs | 0 .../clientbound_login_disconnect_packet.rs | 0 .../login/serverbound_custom_query_packet.rs | 0 .../packets/login/serverbound_key_packet.rs | 0 azalea-protocol/src/packets/mod.rs | 0 .../clientbound_pong_response_packet.rs | 0 .../status/serverbound_ping_request_packet.rs | 0 azalea-protocol/src/read.rs | 0 azalea-registry/Cargo.toml | 0 azalea-registry/README.md | 0 .../azalea-registry-macros/Cargo.toml | 0 .../azalea-registry-macros/src/lib.rs | 0 azalea-registry/src/lib.rs | 0 azalea-world/Cargo.toml | 13 +- azalea-world/README.md | 0 azalea-world/src/bit_storage.rs | 0 azalea-world/src/chunk_storage.rs | 18 +- azalea-world/src/entity/attributes.rs | 116 +++ azalea-world/src/entity/data.rs | 0 azalea-world/src/entity/dimensions.rs | 0 azalea-world/src/entity/metadata.rs | 885 +++++++++++++++++- azalea-world/src/entity/mod.rs | 157 ++-- azalea-world/src/entity_storage.rs | 0 azalea-world/src/lib.rs | 20 +- azalea-world/src/palette.rs | 0 azalea/Cargo.toml | 8 +- azalea/README.md | 0 azalea/examples/craft_dig_straight_down.rs | 2 +- azalea/examples/echo.rs | 2 +- azalea/examples/mine_a_chunk.rs | 6 +- azalea/examples/potatobot/README.md | 0 azalea/examples/potatobot/autoeat.rs | 3 +- azalea/examples/potatobot/main.rs | 6 +- azalea/examples/pvp.rs | 4 +- azalea/src/bot.rs | 35 +- azalea/src/lib.rs | 84 +- azalea/src/pathfinder/mod.rs | 208 ++++ azalea/src/pathfinder/moves.rs | 191 ++++ azalea/src/pathfinder/mtdstarlite.rs | 453 +++++++++ azalea/src/prelude.rs | 2 + bot/Cargo.toml | 4 +- bot/src/main.rs | 50 +- codegen/.gitignore | 0 codegen/README.md | 0 codegen/genblocks.py | 0 codegen/genregistries.py | 0 codegen/lib/code/blocks.py | 0 codegen/lib/code/entity.py | 36 +- codegen/lib/code/packet.py | 0 codegen/lib/code/registry.py | 0 codegen/lib/code/shapes.py | 0 codegen/lib/code/utils.py | 0 codegen/lib/code/version.py | 0 codegen/lib/download.py | 0 codegen/lib/extract.py | 0 codegen/lib/mappings.py | 0 codegen/lib/utils.py | 0 codegen/migrate.py | 0 codegen/newpacket.py | 0 290 files changed, 3049 insertions(+), 776 deletions(-) mode change 100644 => 100755 .cargo/config.toml mode change 100644 => 100755 .github/workflows/check.yml mode change 100644 => 100755 .gitignore mode change 100755 => 100644 Cargo.lock mode change 100644 => 100755 Cargo.toml mode change 100644 => 100755 README.md mode change 100644 => 100755 azalea-auth/Cargo.toml mode change 100644 => 100755 azalea-auth/README.md mode change 100644 => 100755 azalea-auth/examples/auth.rs mode change 100644 => 100755 azalea-auth/src/auth.rs mode change 100644 => 100755 azalea-auth/src/cache.rs mode change 100644 => 100755 azalea-auth/src/sessionserver.rs mode change 100644 => 100755 azalea-block/Cargo.toml mode change 100644 => 100755 azalea-block/README.md mode change 100644 => 100755 azalea-block/azalea-block-macros/Cargo.toml mode change 100644 => 100755 azalea-block/azalea-block-macros/src/lib.rs mode change 100644 => 100755 azalea-block/azalea-block-macros/src/utils.rs mode change 100644 => 100755 azalea-block/src/behavior.rs mode change 100644 => 100755 azalea-block/src/blocks.rs mode change 100644 => 100755 azalea-block/src/lib.rs mode change 100644 => 100755 azalea-brigadier/Cargo.toml mode change 100644 => 100755 azalea-brigadier/src/suggestion/mod.rs mode change 100644 => 100755 azalea-brigadier/src/suggestion/suggestions.rs mode change 100644 => 100755 azalea-buf/Cargo.toml mode change 100644 => 100755 azalea-buf/README.md mode change 100644 => 100755 azalea-buf/azalea-buf-macros/Cargo.toml mode change 100644 => 100755 azalea-buf/azalea-buf-macros/README.md mode change 100644 => 100755 azalea-buf/azalea-buf-macros/src/lib.rs mode change 100644 => 100755 azalea-buf/src/definitions.rs mode change 100644 => 100755 azalea-buf/src/lib.rs mode change 100644 => 100755 azalea-buf/src/read.rs mode change 100644 => 100755 azalea-buf/src/serializable_uuid.rs mode change 100644 => 100755 azalea-buf/src/write.rs mode change 100644 => 100755 azalea-chat/Cargo.toml mode change 100644 => 100755 azalea-chat/src/text_component.rs mode change 100644 => 100755 azalea-chat/src/translatable_component.rs mode change 100644 => 100755 azalea-client/src/account.rs mode change 100644 => 100755 azalea-client/src/chat.rs mode change 100644 => 100755 azalea-client/src/get_mc_dir.rs mode change 100644 => 100755 azalea-client/src/movement.rs mode change 100644 => 100755 azalea-client/src/player.rs create mode 100644 azalea-client/src/plugins.rs mode change 100644 => 100755 azalea-core/Cargo.toml mode change 100644 => 100755 azalea-core/README.md mode change 100644 => 100755 azalea-core/src/aabb.rs mode change 100644 => 100755 azalea-core/src/bitset.rs mode change 100644 => 100755 azalea-core/src/block_hit_result.rs mode change 100644 => 100755 azalea-core/src/cursor3d.rs mode change 100644 => 100755 azalea-core/src/delta.rs mode change 100644 => 100755 azalea-core/src/direction.rs mode change 100644 => 100755 azalea-core/src/particle/mod.rs mode change 100644 => 100755 azalea-core/src/position.rs mode change 100644 => 100755 azalea-core/src/slot.rs mode change 100644 => 100755 azalea-crypto/Cargo.toml mode change 100644 => 100755 azalea-crypto/README.md mode change 100644 => 100755 azalea-crypto/benches/my_benchmark.rs mode change 100644 => 100755 azalea-crypto/src/lib.rs mode change 100644 => 100755 azalea-crypto/src/signing.rs mode change 100644 => 100755 azalea-language/Cargo.toml mode change 100644 => 100755 azalea-language/README.md mode change 100644 => 100755 azalea-language/src/en_us.json mode change 100644 => 100755 azalea-language/src/lib.rs mode change 100644 => 100755 azalea-nbt/Cargo.toml mode change 100644 => 100755 azalea-physics/Cargo.toml mode change 100644 => 100755 azalea-physics/README.md mode change 100644 => 100755 azalea-physics/src/collision/blocks.rs mode change 100644 => 100755 azalea-physics/src/collision/dimension_collisions.rs mode change 100644 => 100755 azalea-physics/src/collision/discrete_voxel_shape.rs mode change 100644 => 100755 azalea-physics/src/collision/mergers.rs mode change 100644 => 100755 azalea-physics/src/collision/mod.rs mode change 100644 => 100755 azalea-physics/src/collision/shape.rs mode change 100644 => 100755 azalea-physics/src/lib.rs mode change 100644 => 100755 azalea-protocol/Cargo.toml mode change 100644 => 100755 azalea-protocol/README.md mode change 100644 => 100755 azalea-protocol/azalea-protocol-macros/Cargo.toml mode change 100644 => 100755 azalea-protocol/azalea-protocol-macros/src/lib.rs mode change 100644 => 100755 azalea-protocol/src/connect.rs mode change 100644 => 100755 azalea-protocol/src/packets/game/clientbound_add_entity_packet.rs mode change 100644 => 100755 azalea-protocol/src/packets/game/clientbound_add_experience_orb_packet.rs mode change 100644 => 100755 azalea-protocol/src/packets/game/clientbound_add_player_packet.rs mode change 100644 => 100755 azalea-protocol/src/packets/game/clientbound_animate_packet.rs mode change 100644 => 100755 azalea-protocol/src/packets/game/clientbound_award_stats_packet.rs mode change 100644 => 100755 azalea-protocol/src/packets/game/clientbound_block_changed_ack_packet.rs mode change 100644 => 100755 azalea-protocol/src/packets/game/clientbound_block_destruction_packet.rs mode change 100644 => 100755 azalea-protocol/src/packets/game/clientbound_block_entity_data_packet.rs mode change 100644 => 100755 azalea-protocol/src/packets/game/clientbound_block_event_packet.rs mode change 100644 => 100755 azalea-protocol/src/packets/game/clientbound_block_update_packet.rs mode change 100644 => 100755 azalea-protocol/src/packets/game/clientbound_boss_event_packet.rs mode change 100644 => 100755 azalea-protocol/src/packets/game/clientbound_chat_preview_packet.rs mode change 100644 => 100755 azalea-protocol/src/packets/game/clientbound_command_suggestions_packet.rs mode change 100644 => 100755 azalea-protocol/src/packets/game/clientbound_commands_packet.rs mode change 100644 => 100755 azalea-protocol/src/packets/game/clientbound_container_set_content_packet.rs mode change 100644 => 100755 azalea-protocol/src/packets/game/clientbound_container_set_data_packet.rs mode change 100644 => 100755 azalea-protocol/src/packets/game/clientbound_container_set_slot_packet.rs mode change 100644 => 100755 azalea-protocol/src/packets/game/clientbound_cooldown_packet.rs mode change 100644 => 100755 azalea-protocol/src/packets/game/clientbound_custom_chat_completions_packet.rs mode change 100644 => 100755 azalea-protocol/src/packets/game/clientbound_custom_sound_packet.rs mode change 100644 => 100755 azalea-protocol/src/packets/game/clientbound_delete_chat_packet.rs mode change 100644 => 100755 azalea-protocol/src/packets/game/clientbound_disconnect_packet.rs mode change 100644 => 100755 azalea-protocol/src/packets/game/clientbound_entity_event_packet.rs mode change 100644 => 100755 azalea-protocol/src/packets/game/clientbound_explode_packet.rs mode change 100644 => 100755 azalea-protocol/src/packets/game/clientbound_forget_level_chunk_packet.rs mode change 100644 => 100755 azalea-protocol/src/packets/game/clientbound_game_event_packet.rs mode change 100644 => 100755 azalea-protocol/src/packets/game/clientbound_horse_screen_open_packet.rs mode change 100644 => 100755 azalea-protocol/src/packets/game/clientbound_initialize_border_packet.rs mode change 100644 => 100755 azalea-protocol/src/packets/game/clientbound_keep_alive_packet.rs mode change 100644 => 100755 azalea-protocol/src/packets/game/clientbound_level_chunk_with_light_packet.rs mode change 100644 => 100755 azalea-protocol/src/packets/game/clientbound_level_event_packet.rs mode change 100644 => 100755 azalea-protocol/src/packets/game/clientbound_level_particles_packet.rs mode change 100644 => 100755 azalea-protocol/src/packets/game/clientbound_light_update_packet.rs mode change 100644 => 100755 azalea-protocol/src/packets/game/clientbound_map_item_data_packet.rs mode change 100644 => 100755 azalea-protocol/src/packets/game/clientbound_merchant_offers_packet.rs mode change 100644 => 100755 azalea-protocol/src/packets/game/clientbound_move_entity_pos_packet.rs mode change 100644 => 100755 azalea-protocol/src/packets/game/clientbound_move_entity_pos_rot_packet.rs mode change 100644 => 100755 azalea-protocol/src/packets/game/clientbound_move_entity_rot_packet.rs mode change 100644 => 100755 azalea-protocol/src/packets/game/clientbound_move_vehicle_packet.rs mode change 100644 => 100755 azalea-protocol/src/packets/game/clientbound_open_book_packet.rs mode change 100644 => 100755 azalea-protocol/src/packets/game/clientbound_open_screen_packet.rs mode change 100644 => 100755 azalea-protocol/src/packets/game/clientbound_open_sign_editor_packet.rs mode change 100644 => 100755 azalea-protocol/src/packets/game/clientbound_ping_packet.rs mode change 100644 => 100755 azalea-protocol/src/packets/game/clientbound_place_ghost_recipe_packet.rs mode change 100644 => 100755 azalea-protocol/src/packets/game/clientbound_player_chat_header_packet.rs mode change 100644 => 100755 azalea-protocol/src/packets/game/clientbound_player_chat_packet.rs mode change 100644 => 100755 azalea-protocol/src/packets/game/clientbound_player_combat_end_packet.rs mode change 100644 => 100755 azalea-protocol/src/packets/game/clientbound_player_combat_enter_packet.rs mode change 100644 => 100755 azalea-protocol/src/packets/game/clientbound_player_combat_kill_packet.rs mode change 100644 => 100755 azalea-protocol/src/packets/game/clientbound_player_info_packet.rs mode change 100644 => 100755 azalea-protocol/src/packets/game/clientbound_player_look_at_packet.rs mode change 100644 => 100755 azalea-protocol/src/packets/game/clientbound_player_position_packet.rs mode change 100644 => 100755 azalea-protocol/src/packets/game/clientbound_recipe_packet.rs mode change 100644 => 100755 azalea-protocol/src/packets/game/clientbound_remove_entities_packet.rs mode change 100644 => 100755 azalea-protocol/src/packets/game/clientbound_remove_mob_effect_packet.rs mode change 100644 => 100755 azalea-protocol/src/packets/game/clientbound_resource_pack_packet.rs mode change 100644 => 100755 azalea-protocol/src/packets/game/clientbound_respawn_packet.rs mode change 100644 => 100755 azalea-protocol/src/packets/game/clientbound_rotate_head_packet.rs mode change 100644 => 100755 azalea-protocol/src/packets/game/clientbound_section_blocks_update_packet.rs mode change 100644 => 100755 azalea-protocol/src/packets/game/clientbound_select_advancements_tab_packet.rs mode change 100644 => 100755 azalea-protocol/src/packets/game/clientbound_server_data_packet.rs mode change 100644 => 100755 azalea-protocol/src/packets/game/clientbound_set_action_bar_text_packet.rs mode change 100644 => 100755 azalea-protocol/src/packets/game/clientbound_set_border_center_packet.rs mode change 100644 => 100755 azalea-protocol/src/packets/game/clientbound_set_border_lerp_size_packet.rs mode change 100644 => 100755 azalea-protocol/src/packets/game/clientbound_set_border_size_packet.rs mode change 100644 => 100755 azalea-protocol/src/packets/game/clientbound_set_border_warning_delay_packet.rs mode change 100644 => 100755 azalea-protocol/src/packets/game/clientbound_set_border_warning_distance_packet.rs mode change 100644 => 100755 azalea-protocol/src/packets/game/clientbound_set_camera_packet.rs mode change 100644 => 100755 azalea-protocol/src/packets/game/clientbound_set_chunk_cache_center_packet.rs mode change 100644 => 100755 azalea-protocol/src/packets/game/clientbound_set_chunk_cache_radius_packet.rs mode change 100644 => 100755 azalea-protocol/src/packets/game/clientbound_set_default_spawn_position_packet.rs mode change 100644 => 100755 azalea-protocol/src/packets/game/clientbound_set_display_chat_preview_packet.rs mode change 100644 => 100755 azalea-protocol/src/packets/game/clientbound_set_display_objective_packet.rs mode change 100644 => 100755 azalea-protocol/src/packets/game/clientbound_set_entity_data_packet.rs mode change 100644 => 100755 azalea-protocol/src/packets/game/clientbound_set_entity_link_packet.rs mode change 100644 => 100755 azalea-protocol/src/packets/game/clientbound_set_entity_motion_packet.rs mode change 100644 => 100755 azalea-protocol/src/packets/game/clientbound_set_equipment_packet.rs mode change 100644 => 100755 azalea-protocol/src/packets/game/clientbound_set_experience_packet.rs mode change 100644 => 100755 azalea-protocol/src/packets/game/clientbound_set_health_packet.rs mode change 100644 => 100755 azalea-protocol/src/packets/game/clientbound_set_objective_packet.rs mode change 100644 => 100755 azalea-protocol/src/packets/game/clientbound_set_passengers_packet.rs mode change 100644 => 100755 azalea-protocol/src/packets/game/clientbound_set_player_team_packet.rs mode change 100644 => 100755 azalea-protocol/src/packets/game/clientbound_set_score_packet.rs mode change 100644 => 100755 azalea-protocol/src/packets/game/clientbound_set_simulation_distance_packet.rs mode change 100644 => 100755 azalea-protocol/src/packets/game/clientbound_set_subtitle_text_packet.rs mode change 100644 => 100755 azalea-protocol/src/packets/game/clientbound_set_time_packet.rs mode change 100644 => 100755 azalea-protocol/src/packets/game/clientbound_set_title_text_packet.rs mode change 100644 => 100755 azalea-protocol/src/packets/game/clientbound_set_titles_animation_packet.rs mode change 100644 => 100755 azalea-protocol/src/packets/game/clientbound_sound_entity_packet.rs mode change 100644 => 100755 azalea-protocol/src/packets/game/clientbound_sound_packet.rs mode change 100644 => 100755 azalea-protocol/src/packets/game/clientbound_stop_sound_packet.rs mode change 100644 => 100755 azalea-protocol/src/packets/game/clientbound_system_chat_packet.rs mode change 100644 => 100755 azalea-protocol/src/packets/game/clientbound_tab_list_packet.rs mode change 100644 => 100755 azalea-protocol/src/packets/game/clientbound_tag_query_packet.rs mode change 100644 => 100755 azalea-protocol/src/packets/game/clientbound_take_item_entity_packet.rs mode change 100644 => 100755 azalea-protocol/src/packets/game/clientbound_teleport_entity_packet.rs mode change 100644 => 100755 azalea-protocol/src/packets/game/clientbound_update_advancements_packet.rs mode change 100644 => 100755 azalea-protocol/src/packets/game/clientbound_update_attributes_packet.rs mode change 100644 => 100755 azalea-protocol/src/packets/game/clientbound_update_mob_effect_packet.rs mode change 100644 => 100755 azalea-protocol/src/packets/game/clientbound_update_recipes_packet.rs mode change 100644 => 100755 azalea-protocol/src/packets/game/mod.rs mode change 100644 => 100755 azalea-protocol/src/packets/game/serverbound_accept_teleportation_packet.rs mode change 100644 => 100755 azalea-protocol/src/packets/game/serverbound_block_entity_tag_query.rs mode change 100644 => 100755 azalea-protocol/src/packets/game/serverbound_change_difficulty_packet.rs mode change 100644 => 100755 azalea-protocol/src/packets/game/serverbound_chat_ack_packet.rs mode change 100644 => 100755 azalea-protocol/src/packets/game/serverbound_chat_command_packet.rs mode change 100644 => 100755 azalea-protocol/src/packets/game/serverbound_chat_packet.rs mode change 100644 => 100755 azalea-protocol/src/packets/game/serverbound_chat_preview_packet.rs mode change 100644 => 100755 azalea-protocol/src/packets/game/serverbound_client_command_packet.rs mode change 100644 => 100755 azalea-protocol/src/packets/game/serverbound_client_information_packet.rs mode change 100644 => 100755 azalea-protocol/src/packets/game/serverbound_command_suggestion_packet.rs mode change 100644 => 100755 azalea-protocol/src/packets/game/serverbound_container_button_click_packet.rs mode change 100644 => 100755 azalea-protocol/src/packets/game/serverbound_container_click_packet.rs mode change 100644 => 100755 azalea-protocol/src/packets/game/serverbound_container_close_packet.rs mode change 100644 => 100755 azalea-protocol/src/packets/game/serverbound_custom_payload_packet.rs mode change 100644 => 100755 azalea-protocol/src/packets/game/serverbound_edit_book_packet.rs mode change 100644 => 100755 azalea-protocol/src/packets/game/serverbound_entity_tag_query.rs mode change 100644 => 100755 azalea-protocol/src/packets/game/serverbound_interact_packet.rs mode change 100644 => 100755 azalea-protocol/src/packets/game/serverbound_jigsaw_generate_packet.rs mode change 100644 => 100755 azalea-protocol/src/packets/game/serverbound_keep_alive_packet.rs mode change 100644 => 100755 azalea-protocol/src/packets/game/serverbound_lock_difficulty_packet.rs mode change 100644 => 100755 azalea-protocol/src/packets/game/serverbound_move_player_pos_packet.rs mode change 100644 => 100755 azalea-protocol/src/packets/game/serverbound_move_player_pos_rot_packet.rs mode change 100644 => 100755 azalea-protocol/src/packets/game/serverbound_move_player_rot_packet.rs mode change 100644 => 100755 azalea-protocol/src/packets/game/serverbound_move_player_status_only_packet.rs mode change 100644 => 100755 azalea-protocol/src/packets/game/serverbound_move_vehicle_packet.rs mode change 100644 => 100755 azalea-protocol/src/packets/game/serverbound_paddle_boat_packet.rs mode change 100644 => 100755 azalea-protocol/src/packets/game/serverbound_pick_item_packet.rs mode change 100644 => 100755 azalea-protocol/src/packets/game/serverbound_place_recipe_packet.rs mode change 100644 => 100755 azalea-protocol/src/packets/game/serverbound_player_abilities_packet.rs mode change 100644 => 100755 azalea-protocol/src/packets/game/serverbound_player_action_packet.rs mode change 100644 => 100755 azalea-protocol/src/packets/game/serverbound_player_command_packet.rs mode change 100644 => 100755 azalea-protocol/src/packets/game/serverbound_player_input_packet.rs mode change 100644 => 100755 azalea-protocol/src/packets/game/serverbound_pong_packet.rs mode change 100644 => 100755 azalea-protocol/src/packets/game/serverbound_recipe_book_change_settings_packet.rs mode change 100644 => 100755 azalea-protocol/src/packets/game/serverbound_recipe_book_seen_recipe_packet.rs mode change 100644 => 100755 azalea-protocol/src/packets/game/serverbound_rename_item_packet.rs mode change 100644 => 100755 azalea-protocol/src/packets/game/serverbound_resource_pack_packet.rs mode change 100644 => 100755 azalea-protocol/src/packets/game/serverbound_seen_advancements_packet.rs mode change 100644 => 100755 azalea-protocol/src/packets/game/serverbound_select_trade_packet.rs mode change 100644 => 100755 azalea-protocol/src/packets/game/serverbound_set_beacon_packet.rs mode change 100644 => 100755 azalea-protocol/src/packets/game/serverbound_set_carried_item_packet.rs mode change 100644 => 100755 azalea-protocol/src/packets/game/serverbound_set_command_block_packet.rs mode change 100644 => 100755 azalea-protocol/src/packets/game/serverbound_set_command_minecart_packet.rs mode change 100644 => 100755 azalea-protocol/src/packets/game/serverbound_set_creative_mode_slot_packet.rs mode change 100644 => 100755 azalea-protocol/src/packets/game/serverbound_set_jigsaw_block_packet.rs mode change 100644 => 100755 azalea-protocol/src/packets/game/serverbound_set_structure_block_packet.rs mode change 100644 => 100755 azalea-protocol/src/packets/game/serverbound_sign_update_packet.rs mode change 100644 => 100755 azalea-protocol/src/packets/game/serverbound_swing_packet.rs mode change 100644 => 100755 azalea-protocol/src/packets/game/serverbound_teleport_to_entity_packet.rs mode change 100644 => 100755 azalea-protocol/src/packets/game/serverbound_use_item_on_packet.rs mode change 100644 => 100755 azalea-protocol/src/packets/game/serverbound_use_item_packet.rs mode change 100644 => 100755 azalea-protocol/src/packets/login/clientbound_login_disconnect_packet.rs mode change 100644 => 100755 azalea-protocol/src/packets/login/serverbound_custom_query_packet.rs mode change 100644 => 100755 azalea-protocol/src/packets/login/serverbound_key_packet.rs mode change 100644 => 100755 azalea-protocol/src/packets/mod.rs mode change 100644 => 100755 azalea-protocol/src/packets/status/clientbound_pong_response_packet.rs mode change 100644 => 100755 azalea-protocol/src/packets/status/serverbound_ping_request_packet.rs mode change 100644 => 100755 azalea-protocol/src/read.rs mode change 100644 => 100755 azalea-registry/Cargo.toml mode change 100644 => 100755 azalea-registry/README.md mode change 100644 => 100755 azalea-registry/azalea-registry-macros/Cargo.toml mode change 100644 => 100755 azalea-registry/azalea-registry-macros/src/lib.rs mode change 100644 => 100755 azalea-registry/src/lib.rs mode change 100644 => 100755 azalea-world/Cargo.toml mode change 100644 => 100755 azalea-world/README.md mode change 100644 => 100755 azalea-world/src/bit_storage.rs mode change 100644 => 100755 azalea-world/src/chunk_storage.rs create mode 100644 azalea-world/src/entity/attributes.rs mode change 100644 => 100755 azalea-world/src/entity/data.rs mode change 100644 => 100755 azalea-world/src/entity/dimensions.rs mode change 100644 => 100755 azalea-world/src/entity_storage.rs mode change 100644 => 100755 azalea-world/src/lib.rs mode change 100644 => 100755 azalea-world/src/palette.rs mode change 100644 => 100755 azalea/Cargo.toml mode change 100644 => 100755 azalea/README.md mode change 100644 => 100755 azalea/examples/craft_dig_straight_down.rs mode change 100644 => 100755 azalea/examples/echo.rs mode change 100644 => 100755 azalea/examples/mine_a_chunk.rs mode change 100644 => 100755 azalea/examples/potatobot/README.md mode change 100644 => 100755 azalea/examples/potatobot/autoeat.rs mode change 100644 => 100755 azalea/examples/potatobot/main.rs mode change 100644 => 100755 azalea/examples/pvp.rs mode change 100644 => 100755 azalea/src/bot.rs mode change 100644 => 100755 azalea/src/lib.rs create mode 100644 azalea/src/pathfinder/mod.rs create mode 100644 azalea/src/pathfinder/moves.rs create mode 100644 azalea/src/pathfinder/mtdstarlite.rs mode change 100644 => 100755 azalea/src/prelude.rs mode change 100644 => 100755 bot/src/main.rs mode change 100644 => 100755 codegen/.gitignore mode change 100644 => 100755 codegen/README.md mode change 100644 => 100755 codegen/genblocks.py mode change 100644 => 100755 codegen/genregistries.py mode change 100644 => 100755 codegen/lib/code/blocks.py mode change 100644 => 100755 codegen/lib/code/packet.py mode change 100644 => 100755 codegen/lib/code/registry.py mode change 100644 => 100755 codegen/lib/code/shapes.py mode change 100644 => 100755 codegen/lib/code/utils.py mode change 100644 => 100755 codegen/lib/code/version.py mode change 100644 => 100755 codegen/lib/download.py mode change 100644 => 100755 codegen/lib/extract.py mode change 100644 => 100755 codegen/lib/mappings.py mode change 100644 => 100755 codegen/lib/utils.py mode change 100644 => 100755 codegen/migrate.py mode change 100644 => 100755 codegen/newpacket.py diff --git a/.cargo/config.toml b/.cargo/config.toml old mode 100644 new mode 100755 diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml old mode 100644 new mode 100755 diff --git a/.gitignore b/.gitignore old mode 100644 new mode 100755 diff --git a/Cargo.lock b/Cargo.lock old mode 100755 new mode 100644 index 2b541e2c..9c53524f --- a/Cargo.lock +++ b/Cargo.lock @@ -2,6 +2,15 @@ # It is not intended for manual editing. version = 3 +[[package]] +name = "addr2line" +version = "0.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9ecd88a8c8378ca913a680cd98f0f13ac67383d35993f86c90a70e3f137816b" +dependencies = [ + "gimli", +] + [[package]] name = "adler" version = "1.0.2" @@ -10,9 +19,9 @@ checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" [[package]] name = "aes" -version = "0.8.1" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfe0133578c0986e1fe3dfcd4af1cc5b2dd6c3dbf534d69916ce16a2701d40ba" +checksum = "433cfd6710c9986c576a25ca913c39d66a6474107b406f34f91d4a8923395241" dependencies = [ "cfg-if", "cipher", @@ -21,9 +30,9 @@ dependencies = [ [[package]] name = "ahash" -version = "0.8.0" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57e6e951cfbb2db8de1828d49073a113a29fd7117b1596caa781a258c7e38d72" +checksum = "bf6ccdb167abbf410dcb915cabd428929d7f6a04980b54a11f26a39f1c7f7107" dependencies = [ "cfg-if", "getrandom", @@ -42,15 +51,15 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.65" +version = "1.0.66" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "98161a4e3e2184da77bb14f02184cdd111e83bbbcc9979dfee3c44b9a85f5602" +checksum = "216261ddc8289130e551ddcd5ce8a064710c0d064a4d2895c67151c92b5443f6" [[package]] name = "async-compression" -version = "0.3.14" +version = "0.3.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "345fd392ab01f746c717b1357165b76f0b67a60192007b234058c9045fdcf695" +checksum = "942c7cd7ae39e91bde4820d74132e9862e62c2f386c3aa90ccf55949f5bad63a" dependencies = [ "flate2", "futures-core", @@ -72,9 +81,9 @@ dependencies = [ [[package]] name = "async-trait" -version = "0.1.57" +version = "0.1.58" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76464446b8bc32758d7e88ee1a804d9914cd9b1cb264c029899680b0be29826f" +checksum = "1e805d94e6b5001b651426cf4cd446b1ab5f319d27bab5c644f61de0a804360c" dependencies = [ "proc-macro2", "quote", @@ -104,10 +113,16 @@ version = "0.3.0" dependencies = [ "anyhow", "async-trait", + "azalea-block", "azalea-client", + "azalea-core", + "azalea-physics", "azalea-protocol", + "azalea-world", "env_logger", + "num-traits", "parking_lot", + "priority-queue", "thiserror", "tokio", ] @@ -188,6 +203,7 @@ name = "azalea-client" version = "0.3.0" dependencies = [ "anyhow", + "async-trait", "azalea-auth", "azalea-block", "azalea-chat", @@ -197,9 +213,11 @@ dependencies = [ "azalea-protocol", "azalea-world", "log", + "nohash-hasher", "parking_lot", "thiserror", "tokio", + "typemap_rev", "uuid", ] @@ -259,6 +277,7 @@ dependencies = [ "azalea-core", "azalea-world", "lazy_static", + "parking_lot", "uuid", ] @@ -333,15 +352,31 @@ dependencies = [ "enum-as-inner", "log", "nohash-hasher", + "parking_lot", "thiserror", "uuid", ] [[package]] -name = "base64" -version = "0.13.0" +name = "backtrace" +version = "0.3.66" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "904dfeac50f3cdaba28fc6f57fdcddb75f49ed61346676a78c4ffe55877802fd" +checksum = "cab84319d616cfb654d03394f38ab7e6f0919e181b1b57e1fd15e7fb4077d9a7" +dependencies = [ + "addr2line", + "cc", + "cfg-if", + "libc", + "miniz_oxide", + "object", + "rustc-demangle", +] + +[[package]] +name = "base64" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" [[package]] name = "bitflags" @@ -351,9 +386,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "block-buffer" -version = "0.10.2" +version = "0.10.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0bf7fe51849ea569fd452f37822f606a5cabb684dc918707a0193fd4664ff324" +checksum = "69cce20737498f97b993470a6e536b8523f0af7892a4f928cceb1ac5e52ebe7e" dependencies = [ "generic-array", ] @@ -384,9 +419,9 @@ dependencies = [ [[package]] name = "bumpalo" -version = "3.10.0" +version = "3.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "37ccbd214614c6783386c1af30caf03192f17891059cecc394b4fb119e363de3" +checksum = "572f695136211188308f16ad2ca5c851a712c464060ae6974944458eb83880ba" [[package]] name = "byteorder" @@ -396,24 +431,21 @@ checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" [[package]] name = "bytes" -version = "1.1.0" +version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4872d67bab6358e59559027aa3b9157c53d9358c51423c17554809a8858e0f8" +checksum = "ec8a7b6a70fde80372154c65702f00a0f56f3e1c36abbc6c440484be248856db" [[package]] name = "cast" -version = "0.2.7" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c24dab4283a142afa2fdca129b80ad2c6284e073930f964c3a1293c225ee39a" -dependencies = [ - "rustc_version", -] +checksum = "37b2a672a2cb129a2e41c10b1224bb368f9f37a2b16b612598138befd7b37eb5" [[package]] name = "cc" -version = "1.0.73" +version = "1.0.76" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2fff2a6927b3bb87f9595d67196a70493f627687a71d87a0d692242c33f58c11" +checksum = "76a284da2e6fe2092f2353e51713435363112dfd60030e22add80be333fb928f" [[package]] name = "cfb8" @@ -479,9 +511,9 @@ checksum = "5827cebf4670468b8772dd191856768aedcb1b0278a04f989f7766351917b9dc" [[package]] name = "cpufeatures" -version = "0.2.2" +version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59a6001667ab124aebae2a495118e11d30984c3a653e99d86d58971708cf5e4b" +checksum = "28d997bd5e24a5928dd43e46dc529867e207907fe0b239c3477d924f7f2ca320" dependencies = [ "libc", ] @@ -497,9 +529,9 @@ dependencies = [ [[package]] name = "criterion" -version = "0.3.5" +version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1604dafd25fba2fe2d5895a9da139f8dc9b319a5fe5354ca137cbbce4e178d10" +checksum = "b01d6de93b2b6c65e17c634a26653a29d107b3c98c607c765bf38d041531cd8f" dependencies = [ "atty", "cast", @@ -523,9 +555,9 @@ dependencies = [ [[package]] name = "criterion-plot" -version = "0.4.4" +version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d00996de9f2f7559f7f4dc286073197f83e92256a59ed395f9aac01fe717da57" +checksum = "2673cc8207403546f45f5fd319a974b1e6983ad1a3ee7e6041650013be041876" dependencies = [ "cast", "itertools", @@ -533,9 +565,9 @@ dependencies = [ [[package]] name = "crossbeam-channel" -version = "0.5.4" +version = "0.5.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5aaa7bd5fb665c6864b5f963dd9097905c54125909c7aa94c9e18507cdbe6c53" +checksum = "c2dd04ddaf88237dc3b8d8f9a3c1004b506b54b3313403944054d23c0870c521" dependencies = [ "cfg-if", "crossbeam-utils", @@ -543,9 +575,9 @@ dependencies = [ [[package]] name = "crossbeam-deque" -version = "0.8.1" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6455c0ca19f0d2fbf751b908d5c55c1f5cbc65e03c4225427254b46890bdde1e" +checksum = "715e8152b692bba2d374b53d4875445368fdf21a94751410af607a5ac677d1fc" dependencies = [ "cfg-if", "crossbeam-epoch", @@ -554,33 +586,31 @@ dependencies = [ [[package]] name = "crossbeam-epoch" -version = "0.9.8" +version = "0.9.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1145cf131a2c6ba0615079ab6a638f7e1973ac9c2634fcbeaaad6114246efe8c" +checksum = "f916dfc5d356b0ed9dae65f1db9fc9770aa2851d2662b988ccf4fe3516e86348" dependencies = [ "autocfg", "cfg-if", "crossbeam-utils", - "lazy_static", "memoffset", "scopeguard", ] [[package]] name = "crossbeam-utils" -version = "0.8.8" +version = "0.8.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0bf124c720b7686e3c2663cf54062ab0f68a88af2fb6a030e87e30bf721fcb38" +checksum = "edbafec5fa1f196ca66527c1b12c2ec4745ca14b50f1ad8f9f6f720b55d11fac" dependencies = [ "cfg-if", - "lazy_static", ] [[package]] name = "crypto-common" -version = "0.1.3" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57952ca27b5e3606ff4dd79b0020231aaf9d6aa76dc05fd30137538c50bd3ce8" +checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" dependencies = [ "generic-array", "typenum", @@ -616,9 +646,9 @@ checksum = "3ee2393c4a91429dffb4bedf19f4d6abf27d8a732c8ce4980305d782e5426d57" [[package]] name = "digest" -version = "0.10.3" +version = "0.10.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2fb860ca6fafa5552fb6d0e816a69c8e49f0908bf524e30a90d97c85892d506" +checksum = "adfbc57365a37acbd2ebf2b64d7e69bb766e2fea813521ed536f5d0520dcf86c" dependencies = [ "block-buffer", "crypto-common", @@ -626,9 +656,9 @@ dependencies = [ [[package]] name = "either" -version = "1.6.1" +version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e78d4f1cc4ae33bbfc157ed5d5a5ef3bc29227303d595861deb238fcec4e9457" +checksum = "90e5c1c8368803113bf0c9584fc495a58b86dc8a29edbf8fe877d21d9507e797" [[package]] name = "encoding_rs" @@ -653,9 +683,9 @@ dependencies = [ [[package]] name = "env_logger" -version = "0.9.1" +version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c90bf5f19754d10198ccb95b70664fc925bd1fc090a0fd9a6ebc54acc8cd6272" +checksum = "a12e6657c4c97ebab115a42dcee77225f7f482cdd841cf7088c657a42e9e00e7" dependencies = [ "atty", "humantime", @@ -673,6 +703,12 @@ dependencies = [ "instant", ] +[[package]] +name = "fixedbitset" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ce7134b9999ecaf8bcd65542e436736ef32ddca1b3e06094cb6ec5755203b80" + [[package]] name = "flate2" version = "1.0.24" @@ -706,19 +742,18 @@ checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" [[package]] name = "form_urlencoded" -version = "1.0.1" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5fc25a87fa4fd2094bffb06925852034d90a17f0d1e05197d4956d3555752191" +checksum = "a9c384f161156f5260c24a097c56119f9be8c798586aecc13afbcbe7b7e26bf8" dependencies = [ - "matches", "percent-encoding", ] [[package]] name = "futures" -version = "0.3.24" +version = "0.3.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f21eda599937fba36daeb58a22e8f5cee2d14c4a17b5b7739c7c8e5e3b8230c" +checksum = "38390104763dc37a5145a53c29c63c1290b5d316d6086ec32c293f6736051bb0" dependencies = [ "futures-channel", "futures-core", @@ -731,9 +766,9 @@ dependencies = [ [[package]] name = "futures-channel" -version = "0.3.24" +version = "0.3.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30bdd20c28fadd505d0fd6712cdfcb0d4b5648baf45faef7f852afb2399bb050" +checksum = "52ba265a92256105f45b719605a571ffe2d1f0fea3807304b522c1d778f79eed" dependencies = [ "futures-core", "futures-sink", @@ -741,15 +776,15 @@ dependencies = [ [[package]] name = "futures-core" -version = "0.3.24" +version = "0.3.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e5aa3de05362c3fb88de6531e6296e85cde7739cccad4b9dfeeb7f6ebce56bf" +checksum = "04909a7a7e4633ae6c4a9ab280aeb86da1236243a77b694a49eacd659a4bd3ac" [[package]] name = "futures-executor" -version = "0.3.24" +version = "0.3.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ff63c23854bee61b6e9cd331d523909f238fc7636290b96826e9cfa5faa00ab" +checksum = "7acc85df6714c176ab5edf386123fafe217be88c0840ec11f199441134a074e2" dependencies = [ "futures-core", "futures-task", @@ -758,15 +793,15 @@ dependencies = [ [[package]] name = "futures-io" -version = "0.3.24" +version = "0.3.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbf4d2a7a308fd4578637c0b17c7e1c7ba127b8f6ba00b29f717e9655d85eb68" +checksum = "00f5fb52a06bdcadeb54e8d3671f8888a39697dcb0b81b23b55174030427f4eb" [[package]] name = "futures-macro" -version = "0.3.24" +version = "0.3.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42cd15d1c7456c04dbdf7e88bcd69760d74f3a798d6444e16974b505b0e62f17" +checksum = "bdfb8ce053d86b91919aad980c220b1fb8401a9394410e1c289ed7e66b61835d" dependencies = [ "proc-macro2", "quote", @@ -775,21 +810,21 @@ dependencies = [ [[package]] name = "futures-sink" -version = "0.3.24" +version = "0.3.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "21b20ba5a92e727ba30e72834706623d94ac93a725410b6a6b6fbc1b07f7ba56" +checksum = "39c15cf1a4aa79df40f1bb462fb39676d0ad9e366c2a33b590d7c66f4f81fcf9" [[package]] name = "futures-task" -version = "0.3.24" +version = "0.3.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a6508c467c73851293f390476d4491cf4d227dbabcd4170f3bb6044959b294f1" +checksum = "2ffb393ac5d9a6eaa9d3fdf37ae2776656b706e200c8e16b1bdb227f5198e6ea" [[package]] name = "futures-util" -version = "0.3.24" +version = "0.3.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44fb6cb1be61cc1d2e43b262516aafcf63b241cffdb1d3fa115f91d9c7b09c90" +checksum = "197676987abd2f9cadff84926f410af1c183608d36641465df73ae8211dc65d6" dependencies = [ "futures-channel", "futures-core", @@ -805,9 +840,9 @@ dependencies = [ [[package]] name = "generic-array" -version = "0.14.5" +version = "0.14.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd48d33ec7f05fbfa152300fdad764757cbded343c1aa1cff2fbaf4134851803" +checksum = "bff49e947297f3312447abdca79f45f4738097cc82b06e72054d2223f601f1b9" dependencies = [ "typenum", "version_check", @@ -815,20 +850,26 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.6" +version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9be70c98951c83b8d2f8f60d7065fa6d5146873094452a1008da8c2f1e4205ad" +checksum = "c05aeb6a22b8f62540c194aac980f2115af067bfe15a0734d7277a768d396b31" dependencies = [ "cfg-if", "libc", - "wasi 0.10.0+wasi-snapshot-preview1", + "wasi", ] [[package]] -name = "h2" -version = "0.3.14" +name = "gimli" +version = "0.26.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ca32592cf21ac7ccab1825cd87f6c9b3d9022c44d086172ed0966bec8af30be" +checksum = "22030e2c5a68ec659fde1e949a745124b48e6fa8b045b7ed5bd1fe4ccc5c4e5d" + +[[package]] +name = "h2" +version = "0.3.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f9f29bc9dda355256b2916cf526ab02ce0aeaaaf2bad60d65ef3f12f11dd0f4" dependencies = [ "bytes", "fnv", @@ -878,7 +919,7 @@ checksum = "75f43d41e26995c17e71ee126451dd3941010b0514a81a9d11f3b341debc2399" dependencies = [ "bytes", "fnv", - "itoa 1.0.2", + "itoa 1.0.4", ] [[package]] @@ -912,9 +953,9 @@ checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" [[package]] name = "hyper" -version = "0.14.20" +version = "0.14.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02c929dc5c39e335a03c405292728118860721b10190d98c2a0f0efd5baafbac" +checksum = "034711faac9d2166cb1baf1a2fb0b60b1f277f8492fd72176c17f3515e1abd3c" dependencies = [ "bytes", "futures-channel", @@ -925,7 +966,7 @@ dependencies = [ "http-body", "httparse", "httpdate", - "itoa 1.0.2", + "itoa 1.0.4", "pin-project-lite", "socket2", "tokio", @@ -958,6 +999,16 @@ dependencies = [ "unicode-normalization", ] +[[package]] +name = "idna" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e14ddfc70884202db2244c223200c204c2bda1bc6e0998d11b5e024d657209e6" +dependencies = [ + "unicode-bidi", + "unicode-normalization", +] + [[package]] name = "indexmap" version = "1.9.1" @@ -988,15 +1039,15 @@ dependencies = [ [[package]] name = "ipnet" -version = "2.5.0" +version = "2.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "879d54834c8c76457ef4293a689b2a8c59b076067ad77b15efafbb05f92a592b" +checksum = "f88c5561171189e69df9d98bcf18fd5f9558300f7ea7b801eb8a0fd748bd8745" [[package]] name = "itertools" -version = "0.10.3" +version = "0.10.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a9a9d19fa1e79b6215ff29b9d6880b706147f16e9b1dbb1e4e5947b5b02bc5e3" +checksum = "b0fd2260e829bddf4cb6ea802289de2f86d6a7a690192fbe91b3f46e0f2c8473" dependencies = [ "either", ] @@ -1009,15 +1060,15 @@ checksum = "b71991ff56294aa922b450139ee08b3bfc70982c6b2c7562771375cf73542dd4" [[package]] name = "itoa" -version = "1.0.2" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "112c678d4050afce233f4f2852bb2eb519230b3cf12f33585275537d7e41578d" +checksum = "4217ad341ebadf8d8e724e264f13e593e0648f5b3e94b3896a5df283be015ecc" [[package]] name = "js-sys" -version = "0.3.57" +version = "0.3.60" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "671a26f820db17c2a2750743f1dd03bafd15b98c9f30c7c2628c024c05d73397" +checksum = "49409df3e3bf0856b916e2ceaca09ee28e6871cf7d9ce97a692cacfdb2a25a47" dependencies = [ "wasm-bindgen", ] @@ -1030,21 +1081,21 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] name = "libc" -version = "0.2.126" +version = "0.2.137" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "349d5a591cd28b49e1d1037471617a32ddcda5731b99419008085f72d5a53836" +checksum = "fc7fcc620a3bff7cdd7a365be3376c97191aeaccc2a603e600951e452615bf89" [[package]] name = "linked-hash-map" -version = "0.5.4" +version = "0.5.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7fb9b38af92608140b86b693604b9ffcc5824240a484d1ecd4795bacb2fe88f3" +checksum = "0717cef1bc8b636c6e1c1bbdefc09e6322da8a9321966e8928ef80d20f7f770f" [[package]] name = "lock_api" -version = "0.4.7" +version = "0.4.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "327fa5b6a6940e4699ec49a9beae1ea4845c6bab9314e4f84ac68742139d8c53" +checksum = "435011366fe56583b16cf956f9df0095b405b82d76425bc8981c0e22e60ec4df" dependencies = [ "autocfg", "scopeguard", @@ -1097,30 +1148,30 @@ checksum = "2a60c7ce501c71e03a9c9c0d35b861413ae925bd979cc7a4e30d060069aaac8d" [[package]] name = "miniz_oxide" -version = "0.5.3" +version = "0.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f5c75688da582b8ffc1f1799e9db273f32133c49e048f614d22ec3256773ccc" +checksum = "96590ba8f175222643a85693f33d26e9c8a015f599c216509b1a6894af675d34" dependencies = [ "adler", ] [[package]] name = "mio" -version = "0.8.4" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57ee1c23c7c63b0c9250c339ffdc69255f110b298b901b9f6c82547b7b87caaf" +checksum = "e5d732bc30207a6423068df043e3d02e0735b155ad7ce1a6f76fe2baa5b158de" dependencies = [ "libc", "log", - "wasi 0.11.0+wasi-snapshot-preview1", - "windows-sys", + "wasi", + "windows-sys 0.42.0", ] [[package]] name = "native-tls" -version = "0.2.10" +version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd7e2f3618557f980e0b17e8856252eee3c97fa12c54dff0ca290fb6266ca4a9" +checksum = "07226173c32f2926027b63cce4bcd8076c3552846cbe7925f3aaffeac0a3b92e" dependencies = [ "lazy_static", "libc", @@ -1167,9 +1218,9 @@ dependencies = [ [[package]] name = "num-complex" -version = "0.4.1" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97fbc387afefefd5e9e39493299f3069e14a140dd34dc19b4c1c1a8fddb6a790" +checksum = "7ae39348c8bc5fbd7f40c727a9925f03517afd2ab27d46702108b6a7e5414c19" dependencies = [ "num-traits", ] @@ -1208,9 +1259,9 @@ dependencies = [ [[package]] name = "num-rational" -version = "0.4.0" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d41702bd167c2df5520b384281bc111a4b5efcf7fbc4c9c222c815b07e0a6a6a" +checksum = "0638a1c9d0a3c0914158145bc76cff373a75a627e6ecbfb71cbe6f453a5a19b0" dependencies = [ "autocfg", "num-bigint", @@ -1229,19 +1280,28 @@ dependencies = [ [[package]] name = "num_cpus" -version = "1.13.1" +version = "1.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "19e64526ebdee182341572e50e9ad03965aa510cd94427a4549448f285e957a1" +checksum = "f6058e64324c71e02bc2b150e4f3bc8286db6c83092132ffa3f6b1eab0f9def5" dependencies = [ "hermit-abi", "libc", ] [[package]] -name = "once_cell" -version = "1.15.0" +name = "object" +version = "0.29.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e82dad04139b71a90c080c8463fe0dc7902db5192d939bd0950f074d014339e1" +checksum = "21158b2c33aa6d4561f1c0a6ea283ca92bc54802a93b263e910746d679a7eb53" +dependencies = [ + "memchr", +] + +[[package]] +name = "once_cell" +version = "1.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "86f0b0d4bf799edbc74508c1e8bf170ff5f41238e5f8225603ca7caaae2b7860" [[package]] name = "oorandom" @@ -1283,9 +1343,9 @@ checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" [[package]] name = "openssl-sys" -version = "0.9.76" +version = "0.9.77" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5230151e44c0f05157effb743e8d517472843121cf9243e8b81393edb5acd9ce" +checksum = "b03b84c3b2d099b81f0953422b4d4ad58761589d0229b5506356afca05a3670a" dependencies = [ "autocfg", "cc", @@ -1306,22 +1366,35 @@ dependencies = [ [[package]] name = "parking_lot_core" -version = "0.9.3" +version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09a279cbf25cb0757810394fbc1e359949b59e348145c643a939a525692e6929" +checksum = "4dc9e0dc2adc1c69d09143aff38d3d30c5c3f0df0dad82e6d25547af174ebec0" dependencies = [ + "backtrace", "cfg-if", "libc", + "petgraph", "redox_syscall", "smallvec", - "windows-sys", + "thread-id", + "windows-sys 0.42.0", ] [[package]] name = "percent-encoding" -version = "2.1.0" +version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d4fd5641d01c8f18a23da7b6fe29298ff4b55afcccdf78973b24cf3175fee32e" +checksum = "478c572c3d73181ff3c2539045f6eb99e5491218eae919370993b890cdbdd98e" + +[[package]] +name = "petgraph" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6d5014253a1331579ce62aa67443b4a658c5e7dd03d4bc6d302b94474888143" +dependencies = [ + "fixedbitset", + "indexmap", +] [[package]] name = "pin-project-lite" @@ -1337,15 +1410,15 @@ checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" [[package]] name = "pkg-config" -version = "0.3.25" +version = "0.3.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1df8c4ec4b0627e53bdf214615ad287367e482558cf84b109250b37464dc03ae" +checksum = "6ac9a59f73473f1b8d852421e59e64809f025994837ef743615c6d0c5b305160" [[package]] name = "plotters" -version = "0.3.1" +version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32a3fd9ec30b9749ce28cd91f255d569591cdf937fe280c312143e3c4bad6f2a" +checksum = "2538b639e642295546c50fcd545198c9d64ee2a38620a628724a3b266d5fbf97" dependencies = [ "num-traits", "plotters-backend", @@ -1356,24 +1429,34 @@ dependencies = [ [[package]] name = "plotters-backend" -version = "0.3.2" +version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d88417318da0eaf0fdcdb51a0ee6c3bed624333bff8f946733049380be67ac1c" +checksum = "193228616381fecdc1224c62e96946dfbc73ff4384fba576e052ff8c1bea8142" [[package]] name = "plotters-svg" -version = "0.3.1" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "521fa9638fa597e1dc53e9412a4f9cefb01187ee1f7413076f9e6749e2885ba9" +checksum = "f9a81d2759aae1dae668f783c308bc5c8ebd191ff4184aaa1b37f65a6ae5a56f" dependencies = [ "plotters-backend", ] [[package]] name = "ppv-lite86" -version = "0.2.16" +version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eb9f9e6e233e5c4a35559a617bf40a4ec447db2e84c20b55a6f83167b7e57872" +checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" + +[[package]] +name = "priority-queue" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d7685ca4cc0b3ad748c22ce6803e23b55b9206ef7715b965ebeaf41639238fdc" +dependencies = [ + "autocfg", + "indexmap", +] [[package]] name = "proc-macro2" @@ -1386,9 +1469,9 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.18" +version = "1.0.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1feb54ed693b93a84e14094943b84b7c4eae204c512b7ccb95ab0c66d278ad1" +checksum = "bbe448f377a7d6961e30f5955f9b8d106c3f5e449d493ee1b125c1d43c2b5179" dependencies = [ "proc-macro2", ] @@ -1416,9 +1499,9 @@ dependencies = [ [[package]] name = "rand_core" -version = "0.6.3" +version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d34f1408f55294453790c48b2f1ebbb1c5b4b7563eb1f418bcfcfdbb06ebb4e7" +checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" dependencies = [ "getrandom", ] @@ -1449,18 +1532,18 @@ dependencies = [ [[package]] name = "redox_syscall" -version = "0.2.13" +version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62f25bc4c7e55e0b0b7a1d43fb893f4fa1361d0abe38b9ce4f323c2adfe6ef42" +checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a" dependencies = [ "bitflags", ] [[package]] name = "regex" -version = "1.5.6" +version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d83f127d94bdbcda4c8cc2e50f6f84f4b611f69c902699ca385a39c3a75f9ff1" +checksum = "e076559ef8e241f2ae3479e36f97bd5741c0330689e217ad51ce2c76808b868a" dependencies = [ "aho-corasick", "memchr", @@ -1475,9 +1558,9 @@ checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132" [[package]] name = "regex-syntax" -version = "0.6.26" +version = "0.6.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49b3de9ec5dc0a3417da371aab17d729997c15010e7fd24ff707773a33bddb64" +checksum = "456c603be3e8d448b072f410900c09faf164fbce2d480456f50eea6e25f9c848" [[package]] name = "remove_dir_all" @@ -1537,19 +1620,16 @@ dependencies = [ ] [[package]] -name = "rustc_version" -version = "0.4.0" +name = "rustc-demangle" +version = "0.1.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" -dependencies = [ - "semver", -] +checksum = "7ef03e0a2b150c7a90d01faf6254c9c48a41e95fb2a8c2ac1c6f0d2b9aefc342" [[package]] name = "ryu" -version = "1.0.10" +version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3f6f92acf49d1b98f7a81226834412ada05458b7364277387724a237f062695" +checksum = "4501abdff3ae82a1c1b477a17252eb69cee9e66eb915c1abaa4f44d873df9f09" [[package]] name = "same-file" @@ -1567,7 +1647,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "88d6731146462ea25d9244b2ed5fd1d716d25c52e4d54aa4fb0f3c4e9854dbe2" dependencies = [ "lazy_static", - "windows-sys", + "windows-sys 0.36.1", ] [[package]] @@ -1599,17 +1679,11 @@ dependencies = [ "libc", ] -[[package]] -name = "semver" -version = "1.0.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a41d061efea015927ac527063765e73601444cdc344ba855bc7bd44578b25e1c" - [[package]] name = "serde" -version = "1.0.145" +version = "1.0.147" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "728eb6351430bccb993660dfffc5a72f91ccc1295abaa8ce19b27ebe4f75568b" +checksum = "d193d69bae983fc11a79df82342761dfbf28a99fc8d203dca4c3c1b590948965" dependencies = [ "serde_derive", ] @@ -1626,9 +1700,9 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.145" +version = "1.0.147" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81fa1584d3d1bcacd84c277a0dfe21f5b0f6accf4a23d04d4c6d61f1af522b4c" +checksum = "4f1d362ca8fc9c3e3a7484440752472d68a6caa98f1ab81d99b5dfe517cec852" dependencies = [ "proc-macro2", "quote", @@ -1637,11 +1711,11 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.86" +version = "1.0.87" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41feea4228a6f1cd09ec7a3593a682276702cd67b5273544757dae23c096f074" +checksum = "6ce777b7b150d76b9cf60d28b55f5847135a003f7d7350c6be7a773508ce7d45" dependencies = [ - "itoa 1.0.2", + "itoa 1.0.4", "ryu", "serde", ] @@ -1653,7 +1727,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d3491c14715ca2294c4d6a88f15e84739788c1d030eed8c110436aafdaa2f3fd" dependencies = [ "form_urlencoded", - "itoa 1.0.2", + "itoa 1.0.4", "ryu", "serde", ] @@ -1692,21 +1766,24 @@ dependencies = [ [[package]] name = "slab" -version = "0.4.6" +version = "0.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eb703cfe953bccee95685111adeedb76fabe4e97549a58d16f03ea7b9367bb32" +checksum = "4614a76b2a8be0058caa9dbbaf66d988527d86d003c11a94fbd335d7661edcef" +dependencies = [ + "autocfg", +] [[package]] name = "smallvec" -version = "1.8.0" +version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2dd574626839106c320a323308629dcb1acfc96e32a8cba364ddc61ac23ee83" +checksum = "a507befe795404456341dfab10cef66ead4c041f62b8b11bbb92bffe5d0953e0" [[package]] name = "socket2" -version = "0.4.4" +version = "0.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "66d72b759436ae32898a2af0a14218dbf55efde3feeb170eb623637db85ee1e0" +checksum = "02e2d2db9033d13a1567121ddd7a095ee144db4e1ca1b1bda3419bc0da294ebd" dependencies = [ "libc", "winapi", @@ -1775,6 +1852,17 @@ dependencies = [ "syn", ] +[[package]] +name = "thread-id" +version = "4.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5fdfe0627923f7411a43ec9ec9c39c3a9b4151be313e0922042581fb6c9b717f" +dependencies = [ + "libc", + "redox_syscall", + "winapi", +] + [[package]] name = "tinytemplate" version = "1.2.1" @@ -1863,9 +1951,9 @@ checksum = "b6bc1c9ce2b5135ac7f93c72918fc37feb872bdc6a5533a8b85eb4b86bfdae52" [[package]] name = "tracing" -version = "0.1.35" +version = "0.1.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a400e31aa60b9d44a52a8ee0343b5b18566b03a8321e0d321f695cf56e940160" +checksum = "8ce8c33a8d48bd45d624a6e523445fd21ec13d3653cd51f681abf67418f54eb8" dependencies = [ "cfg-if", "pin-project-lite", @@ -1886,9 +1974,9 @@ dependencies = [ [[package]] name = "tracing-core" -version = "0.1.28" +version = "0.1.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b7358be39f2f274f322d2aaed611acc57f382e8eb1e5b48cb9ae30933495ce7" +checksum = "24eb03ba0eab1fd845050058ce5e616558e8f8d8fca633e6b163fe25c797213a" dependencies = [ "once_cell", ] @@ -1906,7 +1994,7 @@ dependencies = [ "futures-channel", "futures-io", "futures-util", - "idna", + "idna 0.2.3", "ipnet", "lazy_static", "rand", @@ -1942,6 +2030,12 @@ version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "59547bce71d9c38b83d9c0e92b6066c4253371f15005def0c30d9657f50c7642" +[[package]] +name = "typemap_rev" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4fc45e9608894c9fefd9792d880560280086d73a4d8c8cb7436f27ca98550fb5" + [[package]] name = "typenum" version = "1.15.0" @@ -1956,42 +2050,41 @@ checksum = "099b7128301d285f79ddd55b9a83d5e6b9e97c92e0ea0daebee7263e932de992" [[package]] name = "unicode-ident" -version = "1.0.0" +version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d22af068fba1eb5edcb4aea19d382b2a3deb4c8f9d475c589b6ada9e0fd493ee" +checksum = "6ceab39d59e4c9499d4e5a8ee0e2735b891bb7308ac83dfb4e80cad195c9f6f3" [[package]] name = "unicode-normalization" -version = "0.1.19" +version = "0.1.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d54590932941a9e9266f0832deed84ebe1bf2e4c9e4a3554d393d18f5e854bf9" +checksum = "5c5713f0fc4b5db668a2ac63cdb7bb4469d8c9fed047b1d0292cc7b0ce2ba921" dependencies = [ "tinyvec", ] [[package]] name = "unicode-width" -version = "0.1.9" +version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3ed742d4ea2bd1176e236172c8429aaf54486e7ac098db29ffe6529e0ce50973" +checksum = "c0edd1e5b14653f783770bce4a4dabb4a5108a5370a5f5d8cfe8710c361f6c8b" [[package]] name = "url" -version = "2.2.2" +version = "2.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a507c383b2d33b5fc35d1861e77e6b383d158b2da5e14fe51b83dfedf6fd578c" +checksum = "0d68c799ae75762b8c3fe375feb6600ef5602c883c5d21eb51c09f22b83c4643" dependencies = [ "form_urlencoded", - "idna", - "matches", + "idna 0.3.0", "percent-encoding", ] [[package]] name = "uuid" -version = "1.1.2" +version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd6469f4314d5f1ffec476e05f17cc9a78bc7a27a6a857842170bdf8d6f98d2f" +checksum = "feb41e78f93363bb2df8b0e86a2ca30eed7806ea16ea0c790d757cf93f79be83" [[package]] name = "vcpkg" @@ -2026,12 +2119,6 @@ dependencies = [ "try-lock", ] -[[package]] -name = "wasi" -version = "0.10.0+wasi-snapshot-preview1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a143597ca7c7793eff794def352d41792a93c481eb1042423ff7ff72ba2c31f" - [[package]] name = "wasi" version = "0.11.0+wasi-snapshot-preview1" @@ -2040,9 +2127,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-bindgen" -version = "0.2.80" +version = "0.2.83" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "27370197c907c55e3f1a9fbe26f44e937fe6451368324e009cba39e139dc08ad" +checksum = "eaf9f5aceeec8be17c128b2e93e031fb8a4d469bb9c4ae2d7dc1888b26887268" dependencies = [ "cfg-if", "wasm-bindgen-macro", @@ -2050,13 +2137,13 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.80" +version = "0.2.83" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53e04185bfa3a779273da532f5025e33398409573f348985af9a1cbf3774d3f4" +checksum = "4c8ffb332579b0557b52d268b91feab8df3615f265d5270fec2a8c95b17c1142" dependencies = [ "bumpalo", - "lazy_static", "log", + "once_cell", "proc-macro2", "quote", "syn", @@ -2065,9 +2152,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-futures" -version = "0.4.30" +version = "0.4.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f741de44b75e14c35df886aff5f1eb73aa114fa5d4d00dcd37b5e01259bf3b2" +checksum = "23639446165ca5a5de86ae1d8896b737ae80319560fbaa4c2887b7da6e7ebd7d" dependencies = [ "cfg-if", "js-sys", @@ -2077,9 +2164,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.80" +version = "0.2.83" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17cae7ff784d7e83a2fe7611cfe766ecf034111b49deb850a3dc7699c08251f5" +checksum = "052be0f94026e6cbc75cdefc9bae13fd6052cdcaf532fa6c45e7ae33a1e6c810" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -2087,9 +2174,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.80" +version = "0.2.83" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "99ec0dc7a4756fffc231aab1b9f2f578d23cd391390ab27f952ae0c9b3ece20b" +checksum = "07bc0c051dc5f23e307b13285f9d75df86bfdf816c5721e573dec1f9b8aa193c" dependencies = [ "proc-macro2", "quote", @@ -2100,15 +2187,15 @@ dependencies = [ [[package]] name = "wasm-bindgen-shared" -version = "0.2.80" +version = "0.2.83" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d554b7f530dee5964d9a9468d95c1f8b8acae4f282807e7d27d4b03099a46744" +checksum = "1c38c045535d93ec4f0b4defec448e4291638ee608530863b1e2ba115d4fff7f" [[package]] name = "web-sys" -version = "0.3.57" +version = "0.3.60" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b17e741662c70c8bd24ac5c5b18de314a2c26c32bf8346ee1e6f53de919c283" +checksum = "bcda906d8be16e728fd5adc5b729afad4e444e106ab28cd1c7256e54fa61510f" dependencies = [ "js-sys", "wasm-bindgen", @@ -2151,43 +2238,100 @@ version = "0.36.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ea04155a16a59f9eab786fe12a4a450e75cdb175f9e0d80da1e17db09f55b8d2" dependencies = [ - "windows_aarch64_msvc", - "windows_i686_gnu", - "windows_i686_msvc", - "windows_x86_64_gnu", - "windows_x86_64_msvc", + "windows_aarch64_msvc 0.36.1", + "windows_i686_gnu 0.36.1", + "windows_i686_msvc 0.36.1", + "windows_x86_64_gnu 0.36.1", + "windows_x86_64_msvc 0.36.1", ] +[[package]] +name = "windows-sys" +version = "0.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a3e1820f08b8513f676f7ab6c1f99ff312fb97b553d30ff4dd86f9f15728aa7" +dependencies = [ + "windows_aarch64_gnullvm", + "windows_aarch64_msvc 0.42.0", + "windows_i686_gnu 0.42.0", + "windows_i686_msvc 0.42.0", + "windows_x86_64_gnu 0.42.0", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc 0.42.0", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41d2aa71f6f0cbe00ae5167d90ef3cfe66527d6f613ca78ac8024c3ccab9a19e" + [[package]] name = "windows_aarch64_msvc" version = "0.36.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9bb8c3fd39ade2d67e9874ac4f3db21f0d710bee00fe7cab16949ec184eeaa47" +[[package]] +name = "windows_aarch64_msvc" +version = "0.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd0f252f5a35cac83d6311b2e795981f5ee6e67eb1f9a7f64eb4500fbc4dcdb4" + [[package]] name = "windows_i686_gnu" version = "0.36.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "180e6ccf01daf4c426b846dfc66db1fc518f074baa793aa7d9b9aaeffad6a3b6" +[[package]] +name = "windows_i686_gnu" +version = "0.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fbeae19f6716841636c28d695375df17562ca208b2b7d0dc47635a50ae6c5de7" + [[package]] name = "windows_i686_msvc" version = "0.36.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e2e7917148b2812d1eeafaeb22a97e4813dfa60a3f8f78ebe204bcc88f12f024" +[[package]] +name = "windows_i686_msvc" +version = "0.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "84c12f65daa39dd2babe6e442988fc329d6243fdce47d7d2d155b8d874862246" + [[package]] name = "windows_x86_64_gnu" version = "0.36.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4dcd171b8776c41b97521e5da127a2d86ad280114807d0b2ab1e462bc764d9e1" +[[package]] +name = "windows_x86_64_gnu" +version = "0.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bf7b1b21b5362cbc318f686150e5bcea75ecedc74dd157d874d754a2ca44b0ed" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09d525d2ba30eeb3297665bd434a54297e4170c7f1a44cad4ef58095b4cd2028" + [[package]] name = "windows_x86_64_msvc" version = "0.36.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c811ca4a8c853ef420abd8592ba53ddbbac90410fab6903b3e79972a631f7680" +[[package]] +name = "windows_x86_64_msvc" +version = "0.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f40009d85759725a34da6d89a94e63d7bdc50a862acf0dbc7c8e488f1edcb6f5" + [[package]] name = "winreg" version = "0.10.1" diff --git a/Cargo.toml b/Cargo.toml old mode 100644 new mode 100755 diff --git a/README.md b/README.md old mode 100644 new mode 100755 diff --git a/azalea-auth/Cargo.toml b/azalea-auth/Cargo.toml old mode 100644 new mode 100755 diff --git a/azalea-auth/README.md b/azalea-auth/README.md old mode 100644 new mode 100755 diff --git a/azalea-auth/examples/auth.rs b/azalea-auth/examples/auth.rs old mode 100644 new mode 100755 diff --git a/azalea-auth/src/auth.rs b/azalea-auth/src/auth.rs old mode 100644 new mode 100755 diff --git a/azalea-auth/src/cache.rs b/azalea-auth/src/cache.rs old mode 100644 new mode 100755 diff --git a/azalea-auth/src/sessionserver.rs b/azalea-auth/src/sessionserver.rs old mode 100644 new mode 100755 diff --git a/azalea-block/Cargo.toml b/azalea-block/Cargo.toml old mode 100644 new mode 100755 diff --git a/azalea-block/README.md b/azalea-block/README.md old mode 100644 new mode 100755 diff --git a/azalea-block/azalea-block-macros/Cargo.toml b/azalea-block/azalea-block-macros/Cargo.toml old mode 100644 new mode 100755 diff --git a/azalea-block/azalea-block-macros/src/lib.rs b/azalea-block/azalea-block-macros/src/lib.rs old mode 100644 new mode 100755 diff --git a/azalea-block/azalea-block-macros/src/utils.rs b/azalea-block/azalea-block-macros/src/utils.rs old mode 100644 new mode 100755 diff --git a/azalea-block/src/behavior.rs b/azalea-block/src/behavior.rs old mode 100644 new mode 100755 diff --git a/azalea-block/src/blocks.rs b/azalea-block/src/blocks.rs old mode 100644 new mode 100755 diff --git a/azalea-block/src/lib.rs b/azalea-block/src/lib.rs old mode 100644 new mode 100755 diff --git a/azalea-brigadier/Cargo.toml b/azalea-brigadier/Cargo.toml old mode 100644 new mode 100755 diff --git a/azalea-brigadier/src/suggestion/mod.rs b/azalea-brigadier/src/suggestion/mod.rs old mode 100644 new mode 100755 diff --git a/azalea-brigadier/src/suggestion/suggestions.rs b/azalea-brigadier/src/suggestion/suggestions.rs old mode 100644 new mode 100755 diff --git a/azalea-buf/Cargo.toml b/azalea-buf/Cargo.toml old mode 100644 new mode 100755 diff --git a/azalea-buf/README.md b/azalea-buf/README.md old mode 100644 new mode 100755 diff --git a/azalea-buf/azalea-buf-macros/Cargo.toml b/azalea-buf/azalea-buf-macros/Cargo.toml old mode 100644 new mode 100755 diff --git a/azalea-buf/azalea-buf-macros/README.md b/azalea-buf/azalea-buf-macros/README.md old mode 100644 new mode 100755 diff --git a/azalea-buf/azalea-buf-macros/src/lib.rs b/azalea-buf/azalea-buf-macros/src/lib.rs old mode 100644 new mode 100755 diff --git a/azalea-buf/src/definitions.rs b/azalea-buf/src/definitions.rs old mode 100644 new mode 100755 diff --git a/azalea-buf/src/lib.rs b/azalea-buf/src/lib.rs old mode 100644 new mode 100755 diff --git a/azalea-buf/src/read.rs b/azalea-buf/src/read.rs old mode 100644 new mode 100755 diff --git a/azalea-buf/src/serializable_uuid.rs b/azalea-buf/src/serializable_uuid.rs old mode 100644 new mode 100755 diff --git a/azalea-buf/src/write.rs b/azalea-buf/src/write.rs old mode 100644 new mode 100755 diff --git a/azalea-chat/Cargo.toml b/azalea-chat/Cargo.toml old mode 100644 new mode 100755 diff --git a/azalea-chat/src/text_component.rs b/azalea-chat/src/text_component.rs old mode 100644 new mode 100755 diff --git a/azalea-chat/src/translatable_component.rs b/azalea-chat/src/translatable_component.rs old mode 100644 new mode 100755 diff --git a/azalea-client/Cargo.toml b/azalea-client/Cargo.toml index a430044e..edcee904 100644 --- a/azalea-client/Cargo.toml +++ b/azalea-client/Cargo.toml @@ -3,23 +3,26 @@ description = "A headless Minecraft client." edition = "2021" license = "MIT" name = "azalea-client" -version = "0.3.0" repository = "https://github.com/mat-1/azalea/tree/main/azalea-client" +version = "0.3.0" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] anyhow = "1.0.59" -azalea-auth = { path = "../azalea-auth", version = "0.3.0" } -azalea-block = { path = "../azalea-block", version = "0.3.0" } -azalea-chat = { path = "../azalea-chat", version = "0.3.0" } -azalea-core = { path = "../azalea-core", version = "0.3.0" } -azalea-crypto = { path = "../azalea-crypto", version = "0.3.0" } -azalea-physics = { path = "../azalea-physics", version = "0.3.0" } -azalea-protocol = { path = "../azalea-protocol", version = "0.3.0" } -azalea-world = { path = "../azalea-world", version = "0.3.0" } +async-trait = "0.1.58" +azalea-auth = {path = "../azalea-auth", version = "0.3.0"} +azalea-block = {path = "../azalea-block", version = "0.3.0"} +azalea-chat = {path = "../azalea-chat", version = "0.3.0"} +azalea-core = {path = "../azalea-core", version = "0.3.0"} +azalea-crypto = {path = "../azalea-crypto", version = "0.3.0"} +azalea-physics = {path = "../azalea-physics", version = "0.3.0"} +azalea-protocol = {path = "../azalea-protocol", version = "0.3.0"} +azalea-world = {path = "../azalea-world", version = "0.3.0"} log = "0.4.17" -parking_lot = "0.12.1" +nohash-hasher = "0.2.0" +parking_lot = {version = "^0.12.1", features = ["deadlock_detection"]} thiserror = "^1.0.34" -tokio = { version = "^1.21.2", features = ["sync"] } +tokio = {version = "^1.21.2", features = ["sync"]} +typemap_rev = "0.2.0" uuid = "^1.1.2" diff --git a/azalea-client/src/account.rs b/azalea-client/src/account.rs old mode 100644 new mode 100755 diff --git a/azalea-client/src/chat.rs b/azalea-client/src/chat.rs old mode 100644 new mode 100755 index b771a743..5eadc0c3 --- a/azalea-client/src/chat.rs +++ b/azalea-client/src/chat.rs @@ -70,7 +70,7 @@ impl Client { /// # account, /// # address: "localhost", /// # state: State::default(), - /// # plugins: vec![], + /// # plugins: plugins![], /// # handle, /// # }) /// # .await diff --git a/azalea-client/src/client.rs b/azalea-client/src/client.rs index 3d6c8e05..282de48f 100644 --- a/azalea-client/src/client.rs +++ b/azalea-client/src/client.rs @@ -1,4 +1,4 @@ -use crate::{movement::MoveDirection, Account, Player}; +use crate::{movement::WalkDirection, plugins::Plugins, Account, Player}; use azalea_auth::game_profile::GameProfile; use azalea_chat::Component; use azalea_core::{ChunkPos, ResourceLocation, Vec3}; @@ -28,11 +28,11 @@ use azalea_protocol::{ resolver, ServerAddress, }; use azalea_world::{ - entity::{metadata, EntityData, EntityMetadata, EntityMut, EntityRef}, + entity::{metadata, Entity, EntityData, EntityMetadata}, Dimension, }; use log::{debug, error, info, warn}; -use parking_lot::{Mutex, RwLock}; +use parking_lot::{Mutex, RwLock, RwLockReadGuard, RwLockWriteGuard}; use std::{ fmt::Debug, io::{self, Cursor}, @@ -86,10 +86,14 @@ pub struct Client { game_profile: GameProfile, pub read_conn: Arc>>, pub write_conn: Arc>>, - pub player: Arc>, - pub dimension: Arc>, + pub player: Arc>, + pub dimension: Arc>, pub physics_state: Arc>, pub client_information: Arc>, + /// Plugins are a way for other crates to add custom functionality to the + /// client and keep state. If you're not making a plugin and you're using + /// the `azalea` crate. you can ignore this field. + pub plugins: Arc, tasks: Arc>>>, } @@ -97,8 +101,12 @@ pub struct Client { pub struct PhysicsState { /// Minecraft only sends a movement packet either after 20 ticks or if the player moved enough. This is that tick counter. pub position_remainder: u32, + pub was_sprinting: bool, + // Whether we're going to try to start sprinting this tick. Equivalent to + // holding down ctrl for a tick. + pub trying_to_sprint: bool, - pub move_direction: MoveDirection, + pub move_direction: WalkDirection, pub forward_impulse: f32, pub left_impulse: f32, } @@ -253,11 +261,14 @@ impl Client { game_profile, read_conn, write_conn, - player: Arc::new(Mutex::new(Player::default())), - dimension: Arc::new(Mutex::new(Dimension::default())), + player: Arc::new(RwLock::new(Player::default())), + dimension: Arc::new(RwLock::new(Dimension::default())), physics_state: Arc::new(Mutex::new(PhysicsState::default())), - tasks: Arc::new(Mutex::new(Vec::new())), client_information: Arc::new(RwLock::new(ClientInformation::default())), + // The plugins can be modified by the user by replacing the plugins + // field right after this. No Mutex so the user doesn't need to .lock(). + plugins: Arc::new(Plugins::new()), + tasks: Arc::new(Mutex::new(Vec::new())), }; tx.send(Event::Initialize).unwrap(); @@ -403,7 +414,7 @@ impl Client { .as_int() .expect("min_y tag is not an int"); - let mut dimension_lock = client.dimension.lock(); + let mut dimension_lock = client.dimension.write(); // the 16 here is our render distance // i'll make this an actual setting later *dimension_lock = Dimension::new(16, height, min_y); @@ -415,7 +426,7 @@ impl Client { ); dimension_lock.add_entity(p.player_id, entity); - let mut player_lock = client.player.lock(); + let mut player_lock = client.player.write(); player_lock.set_entity_id(p.player_id); } @@ -482,11 +493,11 @@ impl Client { let (new_pos, y_rot, x_rot) = { let player_entity_id = { - let player_lock = client.player.lock(); + let player_lock = client.player.write(); player_lock.entity_id }; - let mut dimension_lock = client.dimension.lock(); + let mut dimension_lock = client.dimension.write(); let mut player_entity = dimension_lock .entity_mut(player_entity_id) @@ -574,7 +585,7 @@ impl Client { debug!("Got chunk cache center packet {:?}", p); client .dimension - .lock() + .write() .update_view_center(&ChunkPos::new(p.x, p.z)); } ClientboundGamePacket::LevelChunkWithLight(p) => { @@ -584,7 +595,7 @@ impl Client { // debug("chunk {:?}") if let Err(e) = client .dimension - .lock() + .write() .replace_with_packet_data(&pos, &mut Cursor::new(&p.chunk_data.data)) { error!("Couldn't set chunk data: {}", e); @@ -596,11 +607,11 @@ impl Client { ClientboundGamePacket::AddEntity(p) => { debug!("Got add entity packet {:?}", p); let entity = EntityData::from(p); - client.dimension.lock().add_entity(p.id, entity); + client.dimension.write().add_entity(p.id, entity); } ClientboundGamePacket::SetEntityData(p) => { debug!("Got set entity data packet {:?}", p); - let mut dimension = client.dimension.lock(); + let mut dimension = client.dimension.write(); if let Some(mut entity) = dimension.entity_mut(p.id) { entity.apply_metadata(&p.packed_items.0); } else { @@ -619,7 +630,7 @@ impl Client { ClientboundGamePacket::AddPlayer(p) => { debug!("Got add player packet {:?}", p); let entity = EntityData::from(p); - client.dimension.lock().add_entity(p.id, entity); + client.dimension.write().add_entity(p.id, entity); } ClientboundGamePacket::InitializeBorder(p) => { debug!("Got initialize border packet {:?}", p); @@ -640,7 +651,7 @@ impl Client { debug!("Got set experience packet {:?}", p); } ClientboundGamePacket::TeleportEntity(p) => { - let mut dimension_lock = client.dimension.lock(); + let mut dimension_lock = client.dimension.write(); dimension_lock .set_entity_pos( @@ -660,14 +671,14 @@ impl Client { // debug!("Got rotate head packet {:?}", p); } ClientboundGamePacket::MoveEntityPos(p) => { - let mut dimension_lock = client.dimension.lock(); + let mut dimension_lock = client.dimension.write(); dimension_lock .move_entity_with_delta(p.entity_id, &p.delta) .map_err(|e| HandleError::Other(e.into()))?; } ClientboundGamePacket::MoveEntityPosRot(p) => { - let mut dimension_lock = client.dimension.lock(); + let mut dimension_lock = client.dimension.write(); dimension_lock .move_entity_with_delta(p.entity_id, &p.delta) @@ -702,7 +713,7 @@ impl Client { } ClientboundGamePacket::BlockUpdate(p) => { debug!("Got block update packet {:?}", p); - let mut dimension = client.dimension.lock(); + let mut dimension = client.dimension.write(); dimension.set_block_state(&p.pos, p.block_state); } ClientboundGamePacket::Animate(p) => { @@ -710,7 +721,7 @@ impl Client { } ClientboundGamePacket::SectionBlocksUpdate(p) => { debug!("Got section blocks update packet {:?}", p); - let mut dimension = client.dimension.lock(); + let mut dimension = client.dimension.write(); for state in &p.states { dimension.set_block_state(&(p.section_pos + state.pos.clone()), state.state); } @@ -808,8 +819,8 @@ impl Client { async fn game_tick(client: &mut Client, tx: &UnboundedSender) { // return if there's no chunk at the player's position { - let dimension_lock = client.dimension.lock(); - let player_lock = client.player.lock(); + let dimension_lock = client.dimension.write(); + let player_lock = client.player.write(); let player_entity = player_lock.entity(&dimension_lock); let player_entity = if let Some(player_entity) = player_entity { player_entity @@ -835,30 +846,42 @@ impl Client { } /// Returns the entity associated to the player. - pub fn entity_mut<'d>(&self, dimension: &'d mut Dimension) -> EntityMut<'d> { + pub fn entity_mut(&self) -> Entity> { let entity_id = { - let player_lock = self.player.lock(); + let player_lock = self.player.write(); player_lock.entity_id }; - dimension - .entity_mut(entity_id) - .expect("Player entity should be in the given dimension") + + let mut dimension = self.dimension.write(); + + let entity_data = dimension + .entity_storage + .get_mut_by_id(entity_id) + .expect("Player entity should exist"); + let entity_ptr = unsafe { entity_data.as_ptr() }; + Entity::new(dimension, entity_id, entity_ptr) } /// Returns the entity associated to the player. - pub fn entity<'d>(&self, dimension: &'d Dimension) -> EntityRef<'d> { + pub fn entity(&self) -> Entity> { let entity_id = { - let player_lock = self.player.lock(); + let player_lock = self.player.read(); player_lock.entity_id }; - dimension - .entity(entity_id) - .expect("Player entity should be in the given dimension") + + let dimension = self.dimension.read(); + + let entity_data = dimension + .entity_storage + .get_by_id(entity_id) + .expect("Player entity should be in the given dimension"); + let entity_ptr = unsafe { entity_data.as_const_ptr() }; + Entity::new(dimension, entity_id, entity_ptr) } /// Returns whether we have a received the login packet yet. pub fn logged_in(&self) -> bool { - let dimension = self.dimension.lock(); - let player = self.player.lock(); + let dimension = self.dimension.read(); + let player = self.player.write(); player.entity(&dimension).is_some() } diff --git a/azalea-client/src/get_mc_dir.rs b/azalea-client/src/get_mc_dir.rs old mode 100644 new mode 100755 diff --git a/azalea-client/src/lib.rs b/azalea-client/src/lib.rs index 7a76e103..544ea0f4 100755 --- a/azalea-client/src/lib.rs +++ b/azalea-client/src/lib.rs @@ -5,6 +5,9 @@ //! [`azalea_protocol`]: https://crates.io/crates/azalea-protocol //! [`azalea`]: https://crates.io/crates/azalea +#![allow(incomplete_features)] +#![feature(trait_upcasting)] + mod account; mod chat; mod client; @@ -12,11 +15,13 @@ mod get_mc_dir; mod movement; pub mod ping; mod player; +mod plugins; pub use account::Account; pub use client::{ChatPacket, Client, ClientInformation, Event, JoinError}; -pub use movement::MoveDirection; +pub use movement::{SprintDirection, WalkDirection}; pub use player::Player; +pub use plugins::{Plugin, Plugins}; #[cfg(test)] mod tests { diff --git a/azalea-client/src/movement.rs b/azalea-client/src/movement.rs old mode 100644 new mode 100755 index 93acf36f..145513c0 --- a/azalea-client/src/movement.rs +++ b/azalea-client/src/movement.rs @@ -2,6 +2,7 @@ use crate::Client; use azalea_core::Vec3; use azalea_physics::collision::{MovableEntity, MoverType}; use azalea_physics::HasPhysics; +use azalea_protocol::packets::game::serverbound_player_command_packet::ServerboundPlayerCommandPacket; use azalea_protocol::packets::game::{ serverbound_move_player_pos_packet::ServerboundMovePlayerPosPacket, serverbound_move_player_pos_rot_packet::ServerboundMovePlayerPosRotPacket, @@ -28,24 +29,19 @@ impl From for MovePlayerError { } impl Client { - /// This gets called every tick. - pub async fn send_position(&mut self) -> Result<(), MovePlayerError> { + /// This gets called automatically every tick. + pub(crate) async fn send_position(&mut self) -> Result<(), MovePlayerError> { let packet = { - let player_lock = self.player.lock(); - let mut physics_state = self.physics_state.lock(); - let mut dimension_lock = self.dimension.lock(); - - let mut player_entity = player_lock - .entity_mut(&mut dimension_lock) - .expect("Player must exist"); - let player_pos = player_entity.pos(); - let player_old_pos = player_entity.last_pos; - - // TODO: send sprinting and sneaking packets here if they changed - + self.send_sprinting_if_needed().await?; // TODO: the camera being able to be controlled by other entities isn't implemented yet // if !self.is_controlled_camera() { return }; + let mut physics_state = self.physics_state.lock(); + + let player_entity = self.entity(); + let player_pos = player_entity.pos(); + let player_old_pos = player_entity.last_pos; + let x_delta = player_pos.x - player_old_pos.x; let y_delta = player_pos.y - player_old_pos.y; let z_delta = player_pos.z - player_old_pos.z; @@ -105,6 +101,9 @@ impl Client { None }; + drop(player_entity); + let mut player_entity = self.entity_mut(); + if sending_position { player_entity.last_pos = *player_entity.pos(); physics_state.position_remainder = 0; @@ -127,10 +126,35 @@ impl Client { Ok(()) } + async fn send_sprinting_if_needed(&mut self) -> Result<(), MovePlayerError> { + let is_sprinting = self.entity().metadata.sprinting; + let was_sprinting = self.physics_state.lock().was_sprinting; + if is_sprinting != was_sprinting { + let sprinting_action = if is_sprinting { + azalea_protocol::packets::game::serverbound_player_command_packet::Action::StartSprinting + } else { + azalea_protocol::packets::game::serverbound_player_command_packet::Action::StopSprinting + }; + let player_entity_id = self.entity().id; + self.write_packet( + ServerboundPlayerCommandPacket { + id: player_entity_id, + action: sprinting_action, + data: 0, + } + .get(), + ) + .await?; + self.physics_state.lock().was_sprinting = is_sprinting; + } + + Ok(()) + } + // Set our current position to the provided Vec3, potentially clipping through blocks. pub async fn set_pos(&mut self, new_pos: Vec3) -> Result<(), MovePlayerError> { - let player_lock = self.player.lock(); - let mut dimension_lock = self.dimension.lock(); + let player_lock = self.player.write(); + let mut dimension_lock = self.dimension.write(); dimension_lock.set_entity_pos(player_lock.entity_id, new_pos)?; @@ -138,8 +162,8 @@ impl Client { } pub async fn move_entity(&mut self, movement: &Vec3) -> Result<(), MovePlayerError> { - let mut dimension_lock = self.dimension.lock(); - let player = self.player.lock(); + let mut dimension_lock = self.dimension.write(); + let player = self.player.write(); let mut entity = player .entity_mut(&mut dimension_lock) @@ -160,19 +184,38 @@ impl Client { pub fn ai_step(&mut self) { self.tick_controls(None); - let player_lock = self.player.lock(); - let mut dimension_lock = self.dimension.lock(); - let mut player_entity = player_lock - .entity_mut(&mut dimension_lock) - .expect("Player must exist"); - // server ai step { + let mut player_entity = self.entity_mut(); + let physics_state = self.physics_state.lock(); player_entity.xxa = physics_state.left_impulse; player_entity.zza = physics_state.forward_impulse; } + // TODO: food data and abilities + // let has_enough_food_to_sprint = self.food_data().food_level || self.abilities().may_fly; + let has_enough_food_to_sprint = true; + + // TODO: double tapping w to sprint i think + + let trying_to_sprint = self.physics_state.lock().trying_to_sprint; + + if !self.sprinting() + && ( + // !self.is_in_water() + // || self.is_underwater() && + self.has_enough_impulse_to_start_sprinting() + && has_enough_food_to_sprint + // && !self.using_item() + // && !self.has_effect(MobEffects.BLINDNESS) + && trying_to_sprint + ) + { + self.set_sprinting(true); + } + + let mut player_entity = self.entity_mut(); player_entity.ai_step(); } @@ -184,21 +227,21 @@ impl Client { let mut left_impulse: f32 = 0.; let move_direction = physics_state.move_direction; match move_direction { - MoveDirection::Forward | MoveDirection::ForwardRight | MoveDirection::ForwardLeft => { + WalkDirection::Forward | WalkDirection::ForwardRight | WalkDirection::ForwardLeft => { forward_impulse += 1.; } - MoveDirection::Backward - | MoveDirection::BackwardRight - | MoveDirection::BackwardLeft => { + WalkDirection::Backward + | WalkDirection::BackwardRight + | WalkDirection::BackwardLeft => { forward_impulse -= 1.; } _ => {} }; match move_direction { - MoveDirection::Right | MoveDirection::ForwardRight | MoveDirection::BackwardRight => { + WalkDirection::Right | WalkDirection::ForwardRight | WalkDirection::BackwardRight => { left_impulse += 1.; } - MoveDirection::Left | MoveDirection::ForwardLeft | MoveDirection::BackwardLeft => { + WalkDirection::Left | WalkDirection::ForwardLeft | WalkDirection::BackwardLeft => { left_impulse -= 1.; } _ => {} @@ -212,35 +255,90 @@ impl Client { } } - /// Start walking in the given direction. - pub fn walk(&mut self, direction: MoveDirection) { - let mut physics_state = self.physics_state.lock(); - physics_state.move_direction = direction; + /// Start walking in the given direction. To sprint, use + /// [`Client::sprint`]. To stop walking, call walk with + /// `WalkDirection::None`. + pub fn walk(&mut self, direction: WalkDirection) { + { + let mut physics_state = self.physics_state.lock(); + physics_state.move_direction = direction; + } + + self.set_sprinting(false); } - /// Toggle whether we're jumping. This acts as if you held space in + /// Start sprinting in the given direction. To stop moving, call + /// [`Client::walk(WalkDirection::None)`] + pub fn sprint(&mut self, direction: SprintDirection) { + let mut physics_state = self.physics_state.lock(); + physics_state.move_direction = WalkDirection::from(direction); + physics_state.trying_to_sprint = true; + } + + // Whether we're currently sprinting. + pub fn sprinting(&self) -> bool { + self.entity().metadata.sprinting + } + + /// Change whether we're sprinting by adding an attribute modifier to the + /// player. You should use the [`walk`] and [`sprint`] methods instead. + /// Returns if the operation was successful. + fn set_sprinting(&mut self, sprinting: bool) -> bool { + let mut player_entity = self.entity_mut(); + player_entity.metadata.sprinting = sprinting; + if sprinting { + player_entity + .attributes + .speed + .insert(azalea_world::entity::attributes::sprinting_modifier()) + .is_ok() + } else { + player_entity + .attributes + .speed + .remove(&azalea_world::entity::attributes::sprinting_modifier().uuid) + .is_none() + } + } + + /// Set whether we're jumping. This acts as if you held space in /// vanilla. If you want to jump once, use the `jump` function. /// /// If you're making a realistic client, calling this function every tick is /// recommended. pub fn set_jumping(&mut self, jumping: bool) { - let mut dimension = self.dimension.lock(); - let mut player_entity = self.entity_mut(&mut dimension); - + let mut player_entity = self.entity_mut(); player_entity.jumping = jumping; } /// Returns whether the player will try to jump next tick. pub fn jumping(&self) -> bool { - let dimension = self.dimension.lock(); - let player_entity = self.entity(&dimension); + let player_entity = self.entity(); player_entity.jumping } + + /// Sets your rotation. `y_rot` is yaw (looking to the side), `x_rot` is + /// pitch (looking up and down). You can get these numbers from the vanilla + /// f3 screen. + pub fn set_rotation(&mut self, y_rot: f32, x_rot: f32) { + let mut player_entity = self.entity_mut(); + player_entity.set_rotation(y_rot, x_rot); + } + + // Whether the player is moving fast enough to be able to start sprinting. + fn has_enough_impulse_to_start_sprinting(&self) -> bool { + // if self.underwater() { + // self.has_forward_impulse() + // } else { + let physics_state = self.physics_state.lock(); + physics_state.forward_impulse > 0.8 + // } + } } #[derive(Clone, Copy, Debug, Default)] -pub enum MoveDirection { +pub enum WalkDirection { #[default] None, Forward, @@ -252,3 +350,21 @@ pub enum MoveDirection { BackwardRight, BackwardLeft, } + +/// The directions that we can sprint in. It's a subset of [`WalkDirection`]. +#[derive(Clone, Copy, Debug)] +pub enum SprintDirection { + Forward, + ForwardRight, + ForwardLeft, +} + +impl From for WalkDirection { + fn from(d: SprintDirection) -> Self { + match d { + SprintDirection::Forward => WalkDirection::Forward, + SprintDirection::ForwardRight => WalkDirection::ForwardRight, + SprintDirection::ForwardLeft => WalkDirection::ForwardLeft, + } + } +} diff --git a/azalea-client/src/player.rs b/azalea-client/src/player.rs old mode 100644 new mode 100755 index 11651b9c..ea6125ad --- a/azalea-client/src/player.rs +++ b/azalea-client/src/player.rs @@ -1,4 +1,4 @@ -use azalea_world::entity::{EntityMut, EntityRef}; +use azalea_world::entity::Entity; use azalea_world::Dimension; use uuid::Uuid; @@ -18,12 +18,12 @@ pub struct Player { impl Player { /// Get a reference to the entity of the player in the world. - pub fn entity<'d>(&'d self, dimension: &'d Dimension) -> Option { + pub fn entity<'d>(&'d self, dimension: &'d Dimension) -> Option> { dimension.entity(self.entity_id) } /// Get a mutable reference to the entity of the player in the world. - pub fn entity_mut<'d>(&'d self, dimension: &'d mut Dimension) -> Option { + pub fn entity_mut<'d>(&'d self, dimension: &'d mut Dimension) -> Option { dimension.entity_mut(self.entity_id) } diff --git a/azalea-client/src/plugins.rs b/azalea-client/src/plugins.rs new file mode 100644 index 00000000..1a3aa049 --- /dev/null +++ b/azalea-client/src/plugins.rs @@ -0,0 +1,78 @@ +use crate::{Client, Event}; +use async_trait::async_trait; +use nohash_hasher::NoHashHasher; +use std::{ + any::{Any, TypeId}, + collections::HashMap, + hash::BuildHasherDefault, +}; + +// kind of based on https://docs.rs/http/latest/src/http/extensions.rs.html +/// A map of plugin ids to Plugin trait objects. The client stores this so we +/// can keep the state for our plugins. +/// +/// If you're using azalea, you should generate this from the `plugins!` macro. +#[derive(Clone)] +pub struct Plugins { + map: Option, BuildHasherDefault>>>, +} + +impl Plugins { + pub fn new() -> Self { + Self { map: None } + } + + pub fn add(&mut self, plugin: T) { + if self.map.is_none() { + self.map = Some(HashMap::with_hasher(BuildHasherDefault::default())); + } + self.map + .as_mut() + .unwrap() + .insert(TypeId::of::(), Box::new(plugin)); + } + + pub fn get(&self) -> Option<&T> { + self.map + .as_ref() + .and_then(|map| map.get(&TypeId::of::())) + .and_then(|boxed| (boxed.as_ref() as &dyn Any).downcast_ref::()) + } +} + +impl IntoIterator for Plugins { + type Item = Box; + type IntoIter = std::vec::IntoIter; + + fn into_iter(self) -> Self::IntoIter { + self.map + .map(|map| map.into_iter().map(|(_, v)| v).collect::>()) + .unwrap_or_default() + .into_iter() + } +} + +/// Plugins can keep their own personal state, listen to events, and add new functions to Client. +#[async_trait] +pub trait Plugin: Send + Sync + PluginClone + Any + 'static { + async fn handle(self: Box, event: Event, bot: Client); +} + +/// An internal trait that allows Plugin to be cloned. +#[doc(hidden)] +pub trait PluginClone { + fn clone_box(&self) -> Box; +} +impl PluginClone for T +where + T: 'static + Plugin + Clone, +{ + fn clone_box(&self) -> Box { + Box::new(self.clone()) + } +} +impl Clone for Box { + fn clone(&self) -> Self { + self.clone_box() + } +} diff --git a/azalea-core/Cargo.toml b/azalea-core/Cargo.toml old mode 100644 new mode 100755 diff --git a/azalea-core/README.md b/azalea-core/README.md old mode 100644 new mode 100755 diff --git a/azalea-core/src/aabb.rs b/azalea-core/src/aabb.rs old mode 100644 new mode 100755 index 9ebdbcb9..58f079e7 --- a/azalea-core/src/aabb.rs +++ b/azalea-core/src/aabb.rs @@ -1,4 +1,4 @@ -use crate::{Axis, BlockHitResult, BlockPos, Direction, PositionXYZ, Vec3}; +use crate::{Axis, BlockHitResult, BlockPos, Direction, Vec3}; pub const EPSILON: f64 = 1.0E-7; @@ -15,7 +15,7 @@ pub struct AABB { } pub struct ClipPointOpts<'a> { - pub t: &'a mut [f64], + pub t: &'a mut f64, pub approach_dir: Option, pub delta: &'a Vec3, pub begin: f64, @@ -225,13 +225,10 @@ impl AABB { } pub fn clip(&self, min: &Vec3, max: &Vec3) -> Option { - let mut t = [1.0]; - let x = max.x - min.x; - let y = max.y - min.y; - let z = max.z - min.z; - let _dir = self.get_direction(self, min, &mut t, None, &Vec3 { x, y, z })?; - let t = t[0]; - Some(min.add(t * x, t * y, t * z)) + let mut t = 1.0; + let delta = max - min; + let _dir = self.get_direction(self, min, &mut t, None, &delta)?; + Some(min + &(delta * t)) } pub fn clip_iterable( @@ -241,19 +238,16 @@ impl AABB { to: &Vec3, pos: &BlockPos, ) -> Option { - let mut t = [1.0]; + let mut t = 1.0; let mut dir = None; - let x = to.x - from.x; - let y = to.y - from.y; - let z = to.z - from.z; + let delta = to - from; for aabb in boxes { - dir = self.get_direction(aabb, from, &mut t, dir, &Vec3 { x, y, z }); + dir = self.get_direction(aabb, from, &mut t, dir, &delta); } let dir = dir?; - let t = t[0]; Some(BlockHitResult { - location: from.add(t * x, t * y, t * z), + location: from + &(delta * t), direction: dir, block_pos: *pos, inside: false, @@ -265,7 +259,7 @@ impl AABB { &self, aabb: &AABB, from: &Vec3, - t: &mut [f64], + t: &mut f64, dir: Option, delta: &Vec3, ) -> Option { @@ -393,13 +387,13 @@ impl AABB { let t_y = (opts.start.y + t_x) / opts.delta.y; let t_z = (opts.start.z + t_x) / opts.delta.z; if 0.0 < t_x - && t_x < opts.t[0] + && t_x < *opts.t && opts.min_x - EPSILON < t_y && t_y < opts.max_x + EPSILON && opts.min_z - EPSILON < t_z && t_z < opts.max_z + EPSILON { - opts.t[0] = t_x; + *opts.t = t_x; Some(opts.result_dir) } else { opts.approach_dir @@ -416,11 +410,11 @@ impl AABB { } pub fn get_center(&self) -> Vec3 { - Vec3 { - x: (self.min_x + self.max_x) / 2.0, - y: (self.min_y + self.max_y) / 2.0, - z: (self.min_z + self.max_z) / 2.0, - } + Vec3::new( + (self.min_x + self.max_x) / 2.0, + (self.min_y + self.max_y) / 2.0, + (self.min_z + self.max_z) / 2.0, + ) } pub fn of_size(center: Vec3, dx: f64, dy: f64, dz: f64) -> AABB { diff --git a/azalea-core/src/bitset.rs b/azalea-core/src/bitset.rs old mode 100644 new mode 100755 diff --git a/azalea-core/src/block_hit_result.rs b/azalea-core/src/block_hit_result.rs old mode 100644 new mode 100755 diff --git a/azalea-core/src/cursor3d.rs b/azalea-core/src/cursor3d.rs old mode 100644 new mode 100755 diff --git a/azalea-core/src/delta.rs b/azalea-core/src/delta.rs old mode 100644 new mode 100755 index d1f72c17..4f730d14 --- a/azalea-core/src/delta.rs +++ b/azalea-core/src/delta.rs @@ -1,5 +1,3 @@ -use std::ops::{Add, AddAssign}; - use crate::Vec3; pub use azalea_buf::McBuf; @@ -76,24 +74,3 @@ impl Vec3 { self.multiply(amount, amount, amount) } } - -// impl + and += -impl Add for Vec3 { - type Output = Vec3; - - fn add(self, other: Vec3) -> Vec3 { - Vec3 { - x: self.x + other.x, - y: self.y + other.y, - z: self.z + other.z, - } - } -} - -impl AddAssign for Vec3 { - fn add_assign(&mut self, other: Vec3) { - self.x += other.x; - self.y += other.y; - self.z += other.z; - } -} diff --git a/azalea-core/src/direction.rs b/azalea-core/src/direction.rs old mode 100644 new mode 100755 index 22a19ee0..5a7f601a --- a/azalea-core/src/direction.rs +++ b/azalea-core/src/direction.rs @@ -13,6 +13,15 @@ pub enum Direction { East, } +// TODO: make azalea_block use this instead of FacingCardinal +#[derive(Clone, Copy, Debug, McBuf)] +pub enum CardinalDirection { + North, + South, + West, + East, +} + #[derive(Clone, Copy, Debug)] pub enum Axis { X = 0, @@ -27,6 +36,55 @@ pub enum AxisCycle { Backward = 2, } +impl CardinalDirection { + #[inline] + pub fn x(self) -> i32 { + match self { + CardinalDirection::East => 1, + CardinalDirection::West => -1, + _ => 0, + } + } + #[inline] + pub fn z(self) -> i32 { + match self { + CardinalDirection::South => 1, + CardinalDirection::North => -1, + _ => 0, + } + } + + pub fn iter() -> impl Iterator { + [ + CardinalDirection::North, + CardinalDirection::South, + CardinalDirection::West, + CardinalDirection::East, + ] + .iter() + .copied() + } + + #[inline] + pub fn right(self) -> CardinalDirection { + match self { + CardinalDirection::North => CardinalDirection::East, + CardinalDirection::South => CardinalDirection::West, + CardinalDirection::West => CardinalDirection::North, + CardinalDirection::East => CardinalDirection::South, + } + } + #[inline] + pub fn left(self) -> CardinalDirection { + match self { + CardinalDirection::North => CardinalDirection::West, + CardinalDirection::South => CardinalDirection::East, + CardinalDirection::West => CardinalDirection::South, + CardinalDirection::East => CardinalDirection::North, + } + } +} + impl Axis { /// Pick x, y, or z from the arguments depending on the axis. #[inline] diff --git a/azalea-core/src/particle/mod.rs b/azalea-core/src/particle/mod.rs old mode 100644 new mode 100755 diff --git a/azalea-core/src/position.rs b/azalea-core/src/position.rs old mode 100644 new mode 100755 index 85ffc774..61368b28 --- a/azalea-core/src/position.rs +++ b/azalea-core/src/position.rs @@ -2,114 +2,136 @@ use crate::ResourceLocation; use azalea_buf::{BufReadError, McBufReadable, McBufWritable}; use std::{ io::{Cursor, Write}, - ops::{Add, Mul, Rem}, + ops::{Add, AddAssign, Mul, Rem, Sub}, }; -pub trait PositionXYZ -where - T: Add + Mul, -{ - fn x(&self) -> T; - fn y(&self) -> T; - fn z(&self) -> T; +macro_rules! vec3_impl { + ($name:ident, $type:ty) => { + impl $name { + pub fn new(x: $type, y: $type, z: $type) -> Self { + Self { x, y, z } + } - fn set_x(&self, n: T) -> Self; - fn set_y(&self, n: T) -> Self; - fn set_z(&self, n: T) -> Self; + pub fn length_sqr(&self) -> $type { + self.x * self.x + self.y * self.y + self.z * self.z + } - // hopefully these get optimized - fn add_x(&self, n: T) -> Self - where - Self: Sized, - { - self.set_x(self.x() + n) - } - fn add_y(&self, n: T) -> Self - where - Self: Sized, - { - self.set_y(self.y() + n) - } - fn add_z(&self, n: T) -> Self - where - Self: Sized, - { - self.set_z(self.z() + n) - } + /// Return a new instance of this position with the y coordinate + /// decreased by the given number. + pub fn down(&self, y: $type) -> Self { + Self { + x: self.x, + y: self.y - y, + z: self.z, + } + } + /// Return a new instance of this position with the y coordinate + /// increased by the given number. + pub fn up(&self, y: $type) -> Self { + Self { + x: self.x, + y: self.y + y, + z: self.z, + } + } + } - fn add(&self, x: T, y: T, z: T) -> Self - where - Self: Sized, - { - self.add_x(x).add_y(y).add_z(z) - } + impl Add for &$name { + type Output = $name; - fn length_sqr(&self) -> T - where - Self: Sized, - { - self.x() * self.x() + self.y() * self.y() + self.z() * self.z() - } + fn add(self, rhs: Self) -> Self::Output { + $name { + x: self.x + rhs.x, + y: self.y + rhs.y, + z: self.z + rhs.z, + } + } + } + + impl Add for $name { + type Output = $name; + + fn add(self, rhs: Self) -> Self::Output { + (&self).add(&rhs) + } + } + + impl AddAssign for $name { + fn add_assign(&mut self, rhs: Self) { + self.x += rhs.x; + self.y += rhs.y; + self.z += rhs.z; + } + } + impl Rem<$type> for $name { + type Output = Self; + + fn rem(self, rhs: $type) -> Self::Output { + Self { + x: self.x % rhs, + y: self.y % rhs, + z: self.z % rhs, + } + } + } + + impl Sub for &$name { + type Output = $name; + + /// Find the difference between two positions. + fn sub(self, other: Self) -> Self::Output { + Self::Output { + x: self.x - other.x, + y: self.y - other.y, + z: self.z - other.z, + } + } + } + impl Sub for $name { + type Output = Self; + + fn sub(self, other: Self) -> Self::Output { + (&self).sub(&other) + } + } + + impl Mul<$type> for $name { + type Output = Self; + + fn mul(self, multiplier: $type) -> Self::Output { + Self { + x: self.x * multiplier, + y: self.y * multiplier, + z: self.z * multiplier, + } + } + } + }; } -#[derive(Clone, Copy, Debug, Default, Eq, PartialEq)] +#[derive(Clone, Copy, Debug, Default, PartialEq)] +pub struct Vec3 { + pub x: f64, + pub y: f64, + pub z: f64, +} +vec3_impl!(Vec3, f64); + +#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)] pub struct BlockPos { pub x: i32, pub y: i32, pub z: i32, } +vec3_impl!(BlockPos, i32); impl BlockPos { - pub fn new(x: i32, y: i32, z: i32) -> Self { - BlockPos { x, y, z } - } - - pub fn below(&self) -> Self { - self.add(0, -1, 0) - } -} - -impl Rem for BlockPos { - type Output = Self; - - fn rem(self, rhs: i32) -> Self { - BlockPos { - x: self.x % rhs, - y: self.y % rhs, - z: self.z % rhs, - } - } -} - -impl PositionXYZ for BlockPos { - fn x(&self) -> i32 { - self.x - } - fn y(&self) -> i32 { - self.y - } - fn z(&self) -> i32 { - self.z - } - fn set_x(&self, n: i32) -> Self { - BlockPos { - x: n, - y: self.y, - z: self.z, - } - } - fn set_y(&self, n: i32) -> Self { - BlockPos { - x: self.x, - y: n, - z: self.z, - } - } - fn set_z(&self, n: i32) -> Self { - BlockPos { - x: self.x, - y: self.y, - z: n, + /// Get the absolute center of a block position by adding 0.5 to each coordinate. + pub fn center(&self) -> Vec3 { + Vec3 { + x: self.x as f64 + 0.5, + y: self.y as f64 + 0.5, + z: self.z as f64 + 0.5, } } } @@ -127,17 +149,15 @@ impl ChunkPos { } /// The coordinates of a chunk section in the world. -#[derive(Clone, Copy, Debug, Default)] +#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)] pub struct ChunkSectionPos { pub x: i32, pub y: i32, pub z: i32, } +vec3_impl!(ChunkSectionPos, i32); impl ChunkSectionPos { - pub fn new(x: i32, y: i32, z: i32) -> Self { - ChunkSectionPos { x, y, z } - } pub fn block_to_section_coord(block: i32) -> i32 { block >> 4 } @@ -155,32 +175,25 @@ impl ChunkBlockPos { ChunkBlockPos { x, y, z } } } -/// The coordinates of a block inside a chunk section. -#[derive(Clone, Debug, Default)] + +/// The coordinates of a block inside a chunk section. Each coordinate must be in the range [0, 15]. +#[derive(Clone, Debug, Default, PartialEq, Eq)] pub struct ChunkSectionBlockPos { - /// A number between 0 and 16. pub x: u8, - /// A number between 0 and 16. pub y: u8, - /// A number between 0 and 16. pub z: u8, } - -impl ChunkSectionBlockPos { - pub fn new(x: u8, y: u8, z: u8) -> Self { - ChunkSectionBlockPos { x, y, z } - } -} +vec3_impl!(ChunkSectionBlockPos, u8); impl Add for ChunkSectionPos { type Output = BlockPos; fn add(self, rhs: ChunkSectionBlockPos) -> Self::Output { - BlockPos { - x: self.x * 16 + rhs.x as i32, - y: self.y * 16 + rhs.y as i32, - z: self.z * 16 + rhs.z as i32, - } + BlockPos::new( + self.x * 16 + rhs.x as i32, + self.y * 16 + rhs.y as i32, + self.z * 16 + rhs.z as i32, + ) } } @@ -192,47 +205,6 @@ pub struct GlobalPos { pub dimension: ResourceLocation, } -/// An exact point in the world. -#[derive(Debug, Clone, Copy, Default, PartialEq)] -pub struct Vec3 { - pub x: f64, - pub y: f64, - pub z: f64, -} - -impl PositionXYZ for Vec3 { - fn x(&self) -> f64 { - self.x - } - fn y(&self) -> f64 { - self.y - } - fn z(&self) -> f64 { - self.z - } - fn set_x(&self, n: f64) -> Self { - Vec3 { - x: n, - y: self.y, - z: self.z, - } - } - fn set_y(&self, n: f64) -> Self { - Vec3 { - x: self.x, - y: n, - z: self.z, - } - } - fn set_z(&self, n: f64) -> Self { - Vec3 { - x: self.x, - y: self.y, - z: n, - } - } -} - impl From<&BlockPos> for ChunkPos { fn from(pos: &BlockPos) -> Self { ChunkPos { @@ -261,9 +233,9 @@ impl From for ChunkPos { impl From<&BlockPos> for ChunkBlockPos { fn from(pos: &BlockPos) -> Self { ChunkBlockPos { - x: pos.x.rem_euclid(16).unsigned_abs() as u8, + x: pos.x.rem_euclid(16) as u8, y: pos.y, - z: pos.z.rem_euclid(16).unsigned_abs() as u8, + z: pos.z.rem_euclid(16) as u8, } } } @@ -271,9 +243,9 @@ impl From<&BlockPos> for ChunkBlockPos { impl From<&BlockPos> for ChunkSectionBlockPos { fn from(pos: &BlockPos) -> Self { ChunkSectionBlockPos { - x: pos.x.rem(16).unsigned_abs() as u8, - y: pos.y.rem(16).unsigned_abs() as u8, - z: pos.z.rem(16).unsigned_abs() as u8, + x: pos.x.rem_euclid(16) as u8, + y: pos.y.rem_euclid(16) as u8, + z: pos.z.rem_euclid(16) as u8, } } } @@ -282,7 +254,7 @@ impl From<&ChunkBlockPos> for ChunkSectionBlockPos { fn from(pos: &ChunkBlockPos) -> Self { ChunkSectionBlockPos { x: pos.x, - y: pos.y.rem(16).unsigned_abs() as u8, + y: pos.y.rem_euclid(16) as u8, z: pos.z, } } @@ -419,4 +391,13 @@ mod tests { let block_pos = BlockPos::read_from(&mut buf).unwrap(); assert_eq!(block_pos, BlockPos::new(49, -43, -3)); } + + #[test] + fn test_into_chunk_section_block_pos() { + let block_pos = BlockPos::new(0, -60, 0); + assert_eq!( + ChunkSectionBlockPos::from(&block_pos), + ChunkSectionBlockPos::new(0, 4, 0) + ); + } } diff --git a/azalea-core/src/slot.rs b/azalea-core/src/slot.rs old mode 100644 new mode 100755 diff --git a/azalea-crypto/Cargo.toml b/azalea-crypto/Cargo.toml old mode 100644 new mode 100755 diff --git a/azalea-crypto/README.md b/azalea-crypto/README.md old mode 100644 new mode 100755 diff --git a/azalea-crypto/benches/my_benchmark.rs b/azalea-crypto/benches/my_benchmark.rs old mode 100644 new mode 100755 diff --git a/azalea-crypto/src/lib.rs b/azalea-crypto/src/lib.rs old mode 100644 new mode 100755 diff --git a/azalea-crypto/src/signing.rs b/azalea-crypto/src/signing.rs old mode 100644 new mode 100755 diff --git a/azalea-language/Cargo.toml b/azalea-language/Cargo.toml old mode 100644 new mode 100755 diff --git a/azalea-language/README.md b/azalea-language/README.md old mode 100644 new mode 100755 diff --git a/azalea-language/src/en_us.json b/azalea-language/src/en_us.json old mode 100644 new mode 100755 diff --git a/azalea-language/src/lib.rs b/azalea-language/src/lib.rs old mode 100644 new mode 100755 diff --git a/azalea-nbt/Cargo.toml b/azalea-nbt/Cargo.toml old mode 100644 new mode 100755 diff --git a/azalea-physics/Cargo.toml b/azalea-physics/Cargo.toml old mode 100644 new mode 100755 index 8012a674..a1e1968f --- a/azalea-physics/Cargo.toml +++ b/azalea-physics/Cargo.toml @@ -3,16 +3,17 @@ description = "Physics for Minecraft entities." edition = "2021" license = "MIT" name = "azalea-physics" -version = "0.3.0" repository = "https://github.com/mat-1/azalea/tree/main/azalea-physics" +version = "0.3.0" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -azalea-block = { path = "../azalea-block", version = "^0.3.0" } -azalea-core = { path = "../azalea-core", version = "^0.3.0" } -azalea-world = { path = "../azalea-world", version = "^0.3.0" } +azalea-block = {path = "../azalea-block", version = "^0.3.0"} +azalea-core = {path = "../azalea-core", version = "^0.3.0"} +azalea-world = {path = "../azalea-world", version = "^0.3.0"} lazy_static = "1.4.0" +parking_lot = "^0.12.1" [dev-dependencies] uuid = "^1.1.2" diff --git a/azalea-physics/README.md b/azalea-physics/README.md old mode 100644 new mode 100755 diff --git a/azalea-physics/src/collision/blocks.rs b/azalea-physics/src/collision/blocks.rs old mode 100644 new mode 100755 diff --git a/azalea-physics/src/collision/dimension_collisions.rs b/azalea-physics/src/collision/dimension_collisions.rs old mode 100644 new mode 100755 index 35eb9f5b..fd4e5141 --- a/azalea-physics/src/collision/dimension_collisions.rs +++ b/azalea-physics/src/collision/dimension_collisions.rs @@ -3,7 +3,8 @@ use azalea_block::BlockState; use azalea_core::{ChunkPos, ChunkSectionPos, Cursor3d, CursorIterationType, EPSILON}; use azalea_world::entity::EntityData; use azalea_world::{Chunk, Dimension}; -use std::sync::{Arc, Mutex}; +use parking_lot::Mutex; +use std::sync::Arc; use super::Shapes; @@ -92,10 +93,10 @@ impl<'a> Iterator for BlockCollisions<'a> { Some(chunk) => chunk, None => continue, }; - let chunk_lock = chunk.lock().unwrap(); let pos = item.pos; - let block_state: BlockState = chunk_lock + let block_state: BlockState = chunk + .lock() .get(&(&pos).into(), self.dimension.min_y()) .unwrap_or(BlockState::Air); diff --git a/azalea-physics/src/collision/discrete_voxel_shape.rs b/azalea-physics/src/collision/discrete_voxel_shape.rs old mode 100644 new mode 100755 diff --git a/azalea-physics/src/collision/mergers.rs b/azalea-physics/src/collision/mergers.rs old mode 100644 new mode 100755 diff --git a/azalea-physics/src/collision/mod.rs b/azalea-physics/src/collision/mod.rs old mode 100644 new mode 100755 index f08e48e3..d5502f3d --- a/azalea-physics/src/collision/mod.rs +++ b/azalea-physics/src/collision/mod.rs @@ -4,8 +4,10 @@ mod discrete_voxel_shape; mod mergers; mod shape; -use azalea_core::{Axis, PositionXYZ, Vec3, AABB, EPSILON}; -use azalea_world::entity::{EntityData, EntityMut}; +use std::ops::DerefMut; + +use azalea_core::{Axis, Vec3, AABB, EPSILON}; +use azalea_world::entity::{Entity, EntityData}; use azalea_world::{Dimension, MoveEntityError}; pub use blocks::BlockWithShape; use dimension_collisions::CollisionGetter; @@ -81,7 +83,7 @@ impl HasCollision for Dimension { } } -impl MovableEntity for EntityMut<'_> { +impl> MovableEntity for Entity<'_, D> { /// Move an entity by a given delta, checking for collisions. fn move_colliding( &mut self, @@ -158,6 +160,8 @@ impl MovableEntity for EntityMut<'_> { if vertical_collision { // blockBelow.updateEntityAfterFallOn(this.level, this); + // the default implementation of updateEntityAfterFallOn sets the y movement to 0 + self.delta.y = 0.; } if on_ground { diff --git a/azalea-physics/src/collision/shape.rs b/azalea-physics/src/collision/shape.rs old mode 100644 new mode 100755 diff --git a/azalea-physics/src/lib.rs b/azalea-physics/src/lib.rs old mode 100644 new mode 100755 index ac0b92a8..635a36bc --- a/azalea-physics/src/lib.rs +++ b/azalea-physics/src/lib.rs @@ -2,9 +2,14 @@ pub mod collision; +use std::ops::DerefMut; + use azalea_block::{Block, BlockState}; use azalea_core::{BlockPos, Vec3}; -use azalea_world::entity::{EntityData, EntityMut}; +use azalea_world::{ + entity::{Entity, EntityData}, + Dimension, +}; use collision::{MovableEntity, MoverType}; pub trait HasPhysics { @@ -14,7 +19,7 @@ pub trait HasPhysics { fn jump_from_ground(&mut self); } -impl HasPhysics for EntityMut<'_> { +impl> HasPhysics for Entity<'_, D> { /// Move the entity with the given acceleration while handling friction, /// gravity, collisions, and some other stuff. fn travel(&mut self, acceleration: &Vec3) { @@ -115,17 +120,17 @@ impl HasPhysics for EntityMut<'_> { y: jump_power, z: old_delta_movement.z, }; - // if self.sprinting { - // let y_rot = self.y_rot * 0.017453292; - // self.delta = self.delta - // + Vec3 { - // x: (-f32::sin(y_rot) * 0.2) as f64, - // y: 0., - // z: (f32::cos(y_rot) * 0.2) as f64, - // }; - // } + if self.metadata.sprinting { + let y_rot = self.y_rot * 0.017453292; + self.delta = self.delta + + Vec3 { + x: (-f32::sin(y_rot) * 0.2) as f64, + y: 0., + z: (f32::cos(y_rot) * 0.2) as f64, + }; + } - // self.has_impulse = true; + self.has_impulse = true; } } @@ -138,17 +143,21 @@ fn get_block_pos_below_that_affects_movement(entity: &EntityData) -> BlockPos { ) } -fn handle_relative_friction_and_calculate_movement( - entity: &mut EntityMut, +fn handle_relative_friction_and_calculate_movement>( + entity: &mut Entity, acceleration: &Vec3, block_friction: f32, ) -> Vec3 { - entity.move_relative(get_speed(&*entity, block_friction), acceleration); + entity.move_relative( + get_friction_influenced_speed(&*entity, block_friction), + acceleration, + ); // entity.delta = entity.handle_on_climbable(entity.delta); entity .move_colliding(&MoverType::Own, &entity.delta.clone()) .expect("Entity should exist."); // let delta_movement = entity.delta; + // ladders // if ((entity.horizontalCollision || entity.jumping) && (entity.onClimbable() || entity.getFeetBlockState().is(Blocks.POWDER_SNOW) && PowderSnowBlock.canEntityWalkOnPowderSnow(entity))) { // var3 = new Vec3(var3.x, 0.2D, var3.z); // } @@ -160,10 +169,10 @@ fn handle_relative_friction_and_calculate_movement( // private float getFrictionInfluencedSpeed(float friction) { // return this.onGround ? this.getSpeed() * (0.21600002F / (friction * friction * friction)) : this.flyingSpeed; // } -fn get_speed(entity: &EntityData, friction: f32) -> f32 { +fn get_friction_influenced_speed(entity: &EntityData, friction: f32) -> f32 { // TODO: have speed & flying_speed fields in entity if entity.on_ground { - let speed: f32 = 0.7; + let speed: f32 = entity.attributes.speed.calculate() as f32; speed * (0.216f32 / (friction * friction * friction)) } else { // entity.flying_speed @@ -173,7 +182,7 @@ fn get_speed(entity: &EntityData, friction: f32) -> f32 { /// Returns the what the entity's jump should be multiplied by based on the /// block they're standing on. -fn block_jump_factor(entity: &EntityMut) -> f32 { +fn block_jump_factor>(entity: &Entity) -> f32 { let block_at_pos = entity.dimension.get_block_state(&entity.pos().into()); let block_below = entity .dimension @@ -201,11 +210,11 @@ fn block_jump_factor(entity: &EntityMut) -> f32 { // public double getJumpBoostPower() { // return this.hasEffect(MobEffects.JUMP) ? (double)(0.1F * (float)(this.getEffect(MobEffects.JUMP).getAmplifier() + 1)) : 0.0D; // } -fn jump_power(entity: &EntityMut) -> f32 { +fn jump_power>(entity: &Entity) -> f32 { 0.42 * block_jump_factor(entity) } -fn jump_boost_power(_entity: &EntityMut) -> f64 { +fn jump_boost_power>(_entity: &Entity) -> f64 { // TODO: potion effects // if let Some(effects) = entity.effects() { // if let Some(jump_effect) = effects.get(&Effect::Jump) { diff --git a/azalea-protocol/Cargo.toml b/azalea-protocol/Cargo.toml old mode 100644 new mode 100755 diff --git a/azalea-protocol/README.md b/azalea-protocol/README.md old mode 100644 new mode 100755 diff --git a/azalea-protocol/azalea-protocol-macros/Cargo.toml b/azalea-protocol/azalea-protocol-macros/Cargo.toml old mode 100644 new mode 100755 diff --git a/azalea-protocol/azalea-protocol-macros/src/lib.rs b/azalea-protocol/azalea-protocol-macros/src/lib.rs old mode 100644 new mode 100755 diff --git a/azalea-protocol/src/connect.rs b/azalea-protocol/src/connect.rs old mode 100644 new mode 100755 diff --git a/azalea-protocol/src/packets/game/clientbound_add_entity_packet.rs b/azalea-protocol/src/packets/game/clientbound_add_entity_packet.rs old mode 100644 new mode 100755 diff --git a/azalea-protocol/src/packets/game/clientbound_add_experience_orb_packet.rs b/azalea-protocol/src/packets/game/clientbound_add_experience_orb_packet.rs old mode 100644 new mode 100755 diff --git a/azalea-protocol/src/packets/game/clientbound_add_player_packet.rs b/azalea-protocol/src/packets/game/clientbound_add_player_packet.rs old mode 100644 new mode 100755 diff --git a/azalea-protocol/src/packets/game/clientbound_animate_packet.rs b/azalea-protocol/src/packets/game/clientbound_animate_packet.rs old mode 100644 new mode 100755 diff --git a/azalea-protocol/src/packets/game/clientbound_award_stats_packet.rs b/azalea-protocol/src/packets/game/clientbound_award_stats_packet.rs old mode 100644 new mode 100755 diff --git a/azalea-protocol/src/packets/game/clientbound_block_changed_ack_packet.rs b/azalea-protocol/src/packets/game/clientbound_block_changed_ack_packet.rs old mode 100644 new mode 100755 diff --git a/azalea-protocol/src/packets/game/clientbound_block_destruction_packet.rs b/azalea-protocol/src/packets/game/clientbound_block_destruction_packet.rs old mode 100644 new mode 100755 diff --git a/azalea-protocol/src/packets/game/clientbound_block_entity_data_packet.rs b/azalea-protocol/src/packets/game/clientbound_block_entity_data_packet.rs old mode 100644 new mode 100755 diff --git a/azalea-protocol/src/packets/game/clientbound_block_event_packet.rs b/azalea-protocol/src/packets/game/clientbound_block_event_packet.rs old mode 100644 new mode 100755 diff --git a/azalea-protocol/src/packets/game/clientbound_block_update_packet.rs b/azalea-protocol/src/packets/game/clientbound_block_update_packet.rs old mode 100644 new mode 100755 diff --git a/azalea-protocol/src/packets/game/clientbound_boss_event_packet.rs b/azalea-protocol/src/packets/game/clientbound_boss_event_packet.rs old mode 100644 new mode 100755 diff --git a/azalea-protocol/src/packets/game/clientbound_chat_preview_packet.rs b/azalea-protocol/src/packets/game/clientbound_chat_preview_packet.rs old mode 100644 new mode 100755 diff --git a/azalea-protocol/src/packets/game/clientbound_command_suggestions_packet.rs b/azalea-protocol/src/packets/game/clientbound_command_suggestions_packet.rs old mode 100644 new mode 100755 diff --git a/azalea-protocol/src/packets/game/clientbound_commands_packet.rs b/azalea-protocol/src/packets/game/clientbound_commands_packet.rs old mode 100644 new mode 100755 diff --git a/azalea-protocol/src/packets/game/clientbound_container_set_content_packet.rs b/azalea-protocol/src/packets/game/clientbound_container_set_content_packet.rs old mode 100644 new mode 100755 diff --git a/azalea-protocol/src/packets/game/clientbound_container_set_data_packet.rs b/azalea-protocol/src/packets/game/clientbound_container_set_data_packet.rs old mode 100644 new mode 100755 diff --git a/azalea-protocol/src/packets/game/clientbound_container_set_slot_packet.rs b/azalea-protocol/src/packets/game/clientbound_container_set_slot_packet.rs old mode 100644 new mode 100755 diff --git a/azalea-protocol/src/packets/game/clientbound_cooldown_packet.rs b/azalea-protocol/src/packets/game/clientbound_cooldown_packet.rs old mode 100644 new mode 100755 diff --git a/azalea-protocol/src/packets/game/clientbound_custom_chat_completions_packet.rs b/azalea-protocol/src/packets/game/clientbound_custom_chat_completions_packet.rs old mode 100644 new mode 100755 diff --git a/azalea-protocol/src/packets/game/clientbound_custom_sound_packet.rs b/azalea-protocol/src/packets/game/clientbound_custom_sound_packet.rs old mode 100644 new mode 100755 diff --git a/azalea-protocol/src/packets/game/clientbound_delete_chat_packet.rs b/azalea-protocol/src/packets/game/clientbound_delete_chat_packet.rs old mode 100644 new mode 100755 diff --git a/azalea-protocol/src/packets/game/clientbound_disconnect_packet.rs b/azalea-protocol/src/packets/game/clientbound_disconnect_packet.rs old mode 100644 new mode 100755 diff --git a/azalea-protocol/src/packets/game/clientbound_entity_event_packet.rs b/azalea-protocol/src/packets/game/clientbound_entity_event_packet.rs old mode 100644 new mode 100755 diff --git a/azalea-protocol/src/packets/game/clientbound_explode_packet.rs b/azalea-protocol/src/packets/game/clientbound_explode_packet.rs old mode 100644 new mode 100755 diff --git a/azalea-protocol/src/packets/game/clientbound_forget_level_chunk_packet.rs b/azalea-protocol/src/packets/game/clientbound_forget_level_chunk_packet.rs old mode 100644 new mode 100755 diff --git a/azalea-protocol/src/packets/game/clientbound_game_event_packet.rs b/azalea-protocol/src/packets/game/clientbound_game_event_packet.rs old mode 100644 new mode 100755 diff --git a/azalea-protocol/src/packets/game/clientbound_horse_screen_open_packet.rs b/azalea-protocol/src/packets/game/clientbound_horse_screen_open_packet.rs old mode 100644 new mode 100755 diff --git a/azalea-protocol/src/packets/game/clientbound_initialize_border_packet.rs b/azalea-protocol/src/packets/game/clientbound_initialize_border_packet.rs old mode 100644 new mode 100755 diff --git a/azalea-protocol/src/packets/game/clientbound_keep_alive_packet.rs b/azalea-protocol/src/packets/game/clientbound_keep_alive_packet.rs old mode 100644 new mode 100755 diff --git a/azalea-protocol/src/packets/game/clientbound_level_chunk_with_light_packet.rs b/azalea-protocol/src/packets/game/clientbound_level_chunk_with_light_packet.rs old mode 100644 new mode 100755 diff --git a/azalea-protocol/src/packets/game/clientbound_level_event_packet.rs b/azalea-protocol/src/packets/game/clientbound_level_event_packet.rs old mode 100644 new mode 100755 diff --git a/azalea-protocol/src/packets/game/clientbound_level_particles_packet.rs b/azalea-protocol/src/packets/game/clientbound_level_particles_packet.rs old mode 100644 new mode 100755 diff --git a/azalea-protocol/src/packets/game/clientbound_light_update_packet.rs b/azalea-protocol/src/packets/game/clientbound_light_update_packet.rs old mode 100644 new mode 100755 diff --git a/azalea-protocol/src/packets/game/clientbound_map_item_data_packet.rs b/azalea-protocol/src/packets/game/clientbound_map_item_data_packet.rs old mode 100644 new mode 100755 diff --git a/azalea-protocol/src/packets/game/clientbound_merchant_offers_packet.rs b/azalea-protocol/src/packets/game/clientbound_merchant_offers_packet.rs old mode 100644 new mode 100755 diff --git a/azalea-protocol/src/packets/game/clientbound_move_entity_pos_packet.rs b/azalea-protocol/src/packets/game/clientbound_move_entity_pos_packet.rs old mode 100644 new mode 100755 diff --git a/azalea-protocol/src/packets/game/clientbound_move_entity_pos_rot_packet.rs b/azalea-protocol/src/packets/game/clientbound_move_entity_pos_rot_packet.rs old mode 100644 new mode 100755 diff --git a/azalea-protocol/src/packets/game/clientbound_move_entity_rot_packet.rs b/azalea-protocol/src/packets/game/clientbound_move_entity_rot_packet.rs old mode 100644 new mode 100755 diff --git a/azalea-protocol/src/packets/game/clientbound_move_vehicle_packet.rs b/azalea-protocol/src/packets/game/clientbound_move_vehicle_packet.rs old mode 100644 new mode 100755 diff --git a/azalea-protocol/src/packets/game/clientbound_open_book_packet.rs b/azalea-protocol/src/packets/game/clientbound_open_book_packet.rs old mode 100644 new mode 100755 diff --git a/azalea-protocol/src/packets/game/clientbound_open_screen_packet.rs b/azalea-protocol/src/packets/game/clientbound_open_screen_packet.rs old mode 100644 new mode 100755 diff --git a/azalea-protocol/src/packets/game/clientbound_open_sign_editor_packet.rs b/azalea-protocol/src/packets/game/clientbound_open_sign_editor_packet.rs old mode 100644 new mode 100755 diff --git a/azalea-protocol/src/packets/game/clientbound_ping_packet.rs b/azalea-protocol/src/packets/game/clientbound_ping_packet.rs old mode 100644 new mode 100755 diff --git a/azalea-protocol/src/packets/game/clientbound_place_ghost_recipe_packet.rs b/azalea-protocol/src/packets/game/clientbound_place_ghost_recipe_packet.rs old mode 100644 new mode 100755 diff --git a/azalea-protocol/src/packets/game/clientbound_player_chat_header_packet.rs b/azalea-protocol/src/packets/game/clientbound_player_chat_header_packet.rs old mode 100644 new mode 100755 diff --git a/azalea-protocol/src/packets/game/clientbound_player_chat_packet.rs b/azalea-protocol/src/packets/game/clientbound_player_chat_packet.rs old mode 100644 new mode 100755 diff --git a/azalea-protocol/src/packets/game/clientbound_player_combat_end_packet.rs b/azalea-protocol/src/packets/game/clientbound_player_combat_end_packet.rs old mode 100644 new mode 100755 diff --git a/azalea-protocol/src/packets/game/clientbound_player_combat_enter_packet.rs b/azalea-protocol/src/packets/game/clientbound_player_combat_enter_packet.rs old mode 100644 new mode 100755 diff --git a/azalea-protocol/src/packets/game/clientbound_player_combat_kill_packet.rs b/azalea-protocol/src/packets/game/clientbound_player_combat_kill_packet.rs old mode 100644 new mode 100755 diff --git a/azalea-protocol/src/packets/game/clientbound_player_info_packet.rs b/azalea-protocol/src/packets/game/clientbound_player_info_packet.rs old mode 100644 new mode 100755 diff --git a/azalea-protocol/src/packets/game/clientbound_player_look_at_packet.rs b/azalea-protocol/src/packets/game/clientbound_player_look_at_packet.rs old mode 100644 new mode 100755 diff --git a/azalea-protocol/src/packets/game/clientbound_player_position_packet.rs b/azalea-protocol/src/packets/game/clientbound_player_position_packet.rs old mode 100644 new mode 100755 diff --git a/azalea-protocol/src/packets/game/clientbound_recipe_packet.rs b/azalea-protocol/src/packets/game/clientbound_recipe_packet.rs old mode 100644 new mode 100755 diff --git a/azalea-protocol/src/packets/game/clientbound_remove_entities_packet.rs b/azalea-protocol/src/packets/game/clientbound_remove_entities_packet.rs old mode 100644 new mode 100755 diff --git a/azalea-protocol/src/packets/game/clientbound_remove_mob_effect_packet.rs b/azalea-protocol/src/packets/game/clientbound_remove_mob_effect_packet.rs old mode 100644 new mode 100755 diff --git a/azalea-protocol/src/packets/game/clientbound_resource_pack_packet.rs b/azalea-protocol/src/packets/game/clientbound_resource_pack_packet.rs old mode 100644 new mode 100755 diff --git a/azalea-protocol/src/packets/game/clientbound_respawn_packet.rs b/azalea-protocol/src/packets/game/clientbound_respawn_packet.rs old mode 100644 new mode 100755 diff --git a/azalea-protocol/src/packets/game/clientbound_rotate_head_packet.rs b/azalea-protocol/src/packets/game/clientbound_rotate_head_packet.rs old mode 100644 new mode 100755 diff --git a/azalea-protocol/src/packets/game/clientbound_section_blocks_update_packet.rs b/azalea-protocol/src/packets/game/clientbound_section_blocks_update_packet.rs old mode 100644 new mode 100755 diff --git a/azalea-protocol/src/packets/game/clientbound_select_advancements_tab_packet.rs b/azalea-protocol/src/packets/game/clientbound_select_advancements_tab_packet.rs old mode 100644 new mode 100755 diff --git a/azalea-protocol/src/packets/game/clientbound_server_data_packet.rs b/azalea-protocol/src/packets/game/clientbound_server_data_packet.rs old mode 100644 new mode 100755 diff --git a/azalea-protocol/src/packets/game/clientbound_set_action_bar_text_packet.rs b/azalea-protocol/src/packets/game/clientbound_set_action_bar_text_packet.rs old mode 100644 new mode 100755 diff --git a/azalea-protocol/src/packets/game/clientbound_set_border_center_packet.rs b/azalea-protocol/src/packets/game/clientbound_set_border_center_packet.rs old mode 100644 new mode 100755 diff --git a/azalea-protocol/src/packets/game/clientbound_set_border_lerp_size_packet.rs b/azalea-protocol/src/packets/game/clientbound_set_border_lerp_size_packet.rs old mode 100644 new mode 100755 diff --git a/azalea-protocol/src/packets/game/clientbound_set_border_size_packet.rs b/azalea-protocol/src/packets/game/clientbound_set_border_size_packet.rs old mode 100644 new mode 100755 diff --git a/azalea-protocol/src/packets/game/clientbound_set_border_warning_delay_packet.rs b/azalea-protocol/src/packets/game/clientbound_set_border_warning_delay_packet.rs old mode 100644 new mode 100755 diff --git a/azalea-protocol/src/packets/game/clientbound_set_border_warning_distance_packet.rs b/azalea-protocol/src/packets/game/clientbound_set_border_warning_distance_packet.rs old mode 100644 new mode 100755 diff --git a/azalea-protocol/src/packets/game/clientbound_set_camera_packet.rs b/azalea-protocol/src/packets/game/clientbound_set_camera_packet.rs old mode 100644 new mode 100755 diff --git a/azalea-protocol/src/packets/game/clientbound_set_chunk_cache_center_packet.rs b/azalea-protocol/src/packets/game/clientbound_set_chunk_cache_center_packet.rs old mode 100644 new mode 100755 diff --git a/azalea-protocol/src/packets/game/clientbound_set_chunk_cache_radius_packet.rs b/azalea-protocol/src/packets/game/clientbound_set_chunk_cache_radius_packet.rs old mode 100644 new mode 100755 diff --git a/azalea-protocol/src/packets/game/clientbound_set_default_spawn_position_packet.rs b/azalea-protocol/src/packets/game/clientbound_set_default_spawn_position_packet.rs old mode 100644 new mode 100755 diff --git a/azalea-protocol/src/packets/game/clientbound_set_display_chat_preview_packet.rs b/azalea-protocol/src/packets/game/clientbound_set_display_chat_preview_packet.rs old mode 100644 new mode 100755 diff --git a/azalea-protocol/src/packets/game/clientbound_set_display_objective_packet.rs b/azalea-protocol/src/packets/game/clientbound_set_display_objective_packet.rs old mode 100644 new mode 100755 diff --git a/azalea-protocol/src/packets/game/clientbound_set_entity_data_packet.rs b/azalea-protocol/src/packets/game/clientbound_set_entity_data_packet.rs old mode 100644 new mode 100755 diff --git a/azalea-protocol/src/packets/game/clientbound_set_entity_link_packet.rs b/azalea-protocol/src/packets/game/clientbound_set_entity_link_packet.rs old mode 100644 new mode 100755 diff --git a/azalea-protocol/src/packets/game/clientbound_set_entity_motion_packet.rs b/azalea-protocol/src/packets/game/clientbound_set_entity_motion_packet.rs old mode 100644 new mode 100755 diff --git a/azalea-protocol/src/packets/game/clientbound_set_equipment_packet.rs b/azalea-protocol/src/packets/game/clientbound_set_equipment_packet.rs old mode 100644 new mode 100755 diff --git a/azalea-protocol/src/packets/game/clientbound_set_experience_packet.rs b/azalea-protocol/src/packets/game/clientbound_set_experience_packet.rs old mode 100644 new mode 100755 diff --git a/azalea-protocol/src/packets/game/clientbound_set_health_packet.rs b/azalea-protocol/src/packets/game/clientbound_set_health_packet.rs old mode 100644 new mode 100755 diff --git a/azalea-protocol/src/packets/game/clientbound_set_objective_packet.rs b/azalea-protocol/src/packets/game/clientbound_set_objective_packet.rs old mode 100644 new mode 100755 diff --git a/azalea-protocol/src/packets/game/clientbound_set_passengers_packet.rs b/azalea-protocol/src/packets/game/clientbound_set_passengers_packet.rs old mode 100644 new mode 100755 diff --git a/azalea-protocol/src/packets/game/clientbound_set_player_team_packet.rs b/azalea-protocol/src/packets/game/clientbound_set_player_team_packet.rs old mode 100644 new mode 100755 diff --git a/azalea-protocol/src/packets/game/clientbound_set_score_packet.rs b/azalea-protocol/src/packets/game/clientbound_set_score_packet.rs old mode 100644 new mode 100755 diff --git a/azalea-protocol/src/packets/game/clientbound_set_simulation_distance_packet.rs b/azalea-protocol/src/packets/game/clientbound_set_simulation_distance_packet.rs old mode 100644 new mode 100755 diff --git a/azalea-protocol/src/packets/game/clientbound_set_subtitle_text_packet.rs b/azalea-protocol/src/packets/game/clientbound_set_subtitle_text_packet.rs old mode 100644 new mode 100755 diff --git a/azalea-protocol/src/packets/game/clientbound_set_time_packet.rs b/azalea-protocol/src/packets/game/clientbound_set_time_packet.rs old mode 100644 new mode 100755 diff --git a/azalea-protocol/src/packets/game/clientbound_set_title_text_packet.rs b/azalea-protocol/src/packets/game/clientbound_set_title_text_packet.rs old mode 100644 new mode 100755 diff --git a/azalea-protocol/src/packets/game/clientbound_set_titles_animation_packet.rs b/azalea-protocol/src/packets/game/clientbound_set_titles_animation_packet.rs old mode 100644 new mode 100755 diff --git a/azalea-protocol/src/packets/game/clientbound_sound_entity_packet.rs b/azalea-protocol/src/packets/game/clientbound_sound_entity_packet.rs old mode 100644 new mode 100755 diff --git a/azalea-protocol/src/packets/game/clientbound_sound_packet.rs b/azalea-protocol/src/packets/game/clientbound_sound_packet.rs old mode 100644 new mode 100755 diff --git a/azalea-protocol/src/packets/game/clientbound_stop_sound_packet.rs b/azalea-protocol/src/packets/game/clientbound_stop_sound_packet.rs old mode 100644 new mode 100755 diff --git a/azalea-protocol/src/packets/game/clientbound_system_chat_packet.rs b/azalea-protocol/src/packets/game/clientbound_system_chat_packet.rs old mode 100644 new mode 100755 diff --git a/azalea-protocol/src/packets/game/clientbound_tab_list_packet.rs b/azalea-protocol/src/packets/game/clientbound_tab_list_packet.rs old mode 100644 new mode 100755 diff --git a/azalea-protocol/src/packets/game/clientbound_tag_query_packet.rs b/azalea-protocol/src/packets/game/clientbound_tag_query_packet.rs old mode 100644 new mode 100755 diff --git a/azalea-protocol/src/packets/game/clientbound_take_item_entity_packet.rs b/azalea-protocol/src/packets/game/clientbound_take_item_entity_packet.rs old mode 100644 new mode 100755 diff --git a/azalea-protocol/src/packets/game/clientbound_teleport_entity_packet.rs b/azalea-protocol/src/packets/game/clientbound_teleport_entity_packet.rs old mode 100644 new mode 100755 diff --git a/azalea-protocol/src/packets/game/clientbound_update_advancements_packet.rs b/azalea-protocol/src/packets/game/clientbound_update_advancements_packet.rs old mode 100644 new mode 100755 diff --git a/azalea-protocol/src/packets/game/clientbound_update_attributes_packet.rs b/azalea-protocol/src/packets/game/clientbound_update_attributes_packet.rs old mode 100644 new mode 100755 index bcccdc3f..4c24ba64 --- a/azalea-protocol/src/packets/game/clientbound_update_attributes_packet.rs +++ b/azalea-protocol/src/packets/game/clientbound_update_attributes_packet.rs @@ -1,9 +1,7 @@ -use azalea_buf::{BufReadError, McBuf}; -use azalea_buf::{McBufReadable, McBufWritable}; +use azalea_buf::McBuf; use azalea_core::ResourceLocation; use azalea_protocol_macros::ClientboundGamePacket; -use std::io::{Cursor, Write}; -use uuid::Uuid; +use azalea_world::entity::attributes::AttributeModifier; #[derive(Clone, Debug, McBuf, ClientboundGamePacket)] pub struct ClientboundUpdateAttributesPacket { @@ -16,37 +14,5 @@ pub struct ClientboundUpdateAttributesPacket { pub struct AttributeSnapshot { pub attribute: ResourceLocation, pub base: f64, - pub modifiers: Vec, -} - -#[derive(Clone, Debug, McBuf)] -pub struct Modifier { - pub uuid: Uuid, - pub amount: f64, - pub operation: u8, -} - -#[derive(Clone, Debug, Copy)] -enum Operation { - Addition = 0, - MultiplyBase = 1, - MultiplyTotal = 2, -} - -impl McBufReadable for Operation { - fn read_from(buf: &mut Cursor<&[u8]>) -> Result { - match u8::read_from(buf)? { - 0 => Ok(Operation::Addition), - 1 => Ok(Operation::MultiplyBase), - 2 => Ok(Operation::MultiplyTotal), - id => Err(BufReadError::UnexpectedEnumVariant { id: id.into() }), - } - } -} - -impl McBufWritable for Operation { - fn write_into(&self, buf: &mut impl Write) -> Result<(), std::io::Error> { - (*self as u8).write_into(buf)?; - Ok(()) - } + pub modifiers: Vec, } diff --git a/azalea-protocol/src/packets/game/clientbound_update_mob_effect_packet.rs b/azalea-protocol/src/packets/game/clientbound_update_mob_effect_packet.rs old mode 100644 new mode 100755 diff --git a/azalea-protocol/src/packets/game/clientbound_update_recipes_packet.rs b/azalea-protocol/src/packets/game/clientbound_update_recipes_packet.rs old mode 100644 new mode 100755 diff --git a/azalea-protocol/src/packets/game/mod.rs b/azalea-protocol/src/packets/game/mod.rs old mode 100644 new mode 100755 diff --git a/azalea-protocol/src/packets/game/serverbound_accept_teleportation_packet.rs b/azalea-protocol/src/packets/game/serverbound_accept_teleportation_packet.rs old mode 100644 new mode 100755 diff --git a/azalea-protocol/src/packets/game/serverbound_block_entity_tag_query.rs b/azalea-protocol/src/packets/game/serverbound_block_entity_tag_query.rs old mode 100644 new mode 100755 diff --git a/azalea-protocol/src/packets/game/serverbound_change_difficulty_packet.rs b/azalea-protocol/src/packets/game/serverbound_change_difficulty_packet.rs old mode 100644 new mode 100755 diff --git a/azalea-protocol/src/packets/game/serverbound_chat_ack_packet.rs b/azalea-protocol/src/packets/game/serverbound_chat_ack_packet.rs old mode 100644 new mode 100755 diff --git a/azalea-protocol/src/packets/game/serverbound_chat_command_packet.rs b/azalea-protocol/src/packets/game/serverbound_chat_command_packet.rs old mode 100644 new mode 100755 diff --git a/azalea-protocol/src/packets/game/serverbound_chat_packet.rs b/azalea-protocol/src/packets/game/serverbound_chat_packet.rs old mode 100644 new mode 100755 diff --git a/azalea-protocol/src/packets/game/serverbound_chat_preview_packet.rs b/azalea-protocol/src/packets/game/serverbound_chat_preview_packet.rs old mode 100644 new mode 100755 diff --git a/azalea-protocol/src/packets/game/serverbound_client_command_packet.rs b/azalea-protocol/src/packets/game/serverbound_client_command_packet.rs old mode 100644 new mode 100755 diff --git a/azalea-protocol/src/packets/game/serverbound_client_information_packet.rs b/azalea-protocol/src/packets/game/serverbound_client_information_packet.rs old mode 100644 new mode 100755 diff --git a/azalea-protocol/src/packets/game/serverbound_command_suggestion_packet.rs b/azalea-protocol/src/packets/game/serverbound_command_suggestion_packet.rs old mode 100644 new mode 100755 diff --git a/azalea-protocol/src/packets/game/serverbound_container_button_click_packet.rs b/azalea-protocol/src/packets/game/serverbound_container_button_click_packet.rs old mode 100644 new mode 100755 diff --git a/azalea-protocol/src/packets/game/serverbound_container_click_packet.rs b/azalea-protocol/src/packets/game/serverbound_container_click_packet.rs old mode 100644 new mode 100755 diff --git a/azalea-protocol/src/packets/game/serverbound_container_close_packet.rs b/azalea-protocol/src/packets/game/serverbound_container_close_packet.rs old mode 100644 new mode 100755 diff --git a/azalea-protocol/src/packets/game/serverbound_custom_payload_packet.rs b/azalea-protocol/src/packets/game/serverbound_custom_payload_packet.rs old mode 100644 new mode 100755 diff --git a/azalea-protocol/src/packets/game/serverbound_edit_book_packet.rs b/azalea-protocol/src/packets/game/serverbound_edit_book_packet.rs old mode 100644 new mode 100755 diff --git a/azalea-protocol/src/packets/game/serverbound_entity_tag_query.rs b/azalea-protocol/src/packets/game/serverbound_entity_tag_query.rs old mode 100644 new mode 100755 diff --git a/azalea-protocol/src/packets/game/serverbound_interact_packet.rs b/azalea-protocol/src/packets/game/serverbound_interact_packet.rs old mode 100644 new mode 100755 diff --git a/azalea-protocol/src/packets/game/serverbound_jigsaw_generate_packet.rs b/azalea-protocol/src/packets/game/serverbound_jigsaw_generate_packet.rs old mode 100644 new mode 100755 diff --git a/azalea-protocol/src/packets/game/serverbound_keep_alive_packet.rs b/azalea-protocol/src/packets/game/serverbound_keep_alive_packet.rs old mode 100644 new mode 100755 diff --git a/azalea-protocol/src/packets/game/serverbound_lock_difficulty_packet.rs b/azalea-protocol/src/packets/game/serverbound_lock_difficulty_packet.rs old mode 100644 new mode 100755 diff --git a/azalea-protocol/src/packets/game/serverbound_move_player_pos_packet.rs b/azalea-protocol/src/packets/game/serverbound_move_player_pos_packet.rs old mode 100644 new mode 100755 diff --git a/azalea-protocol/src/packets/game/serverbound_move_player_pos_rot_packet.rs b/azalea-protocol/src/packets/game/serverbound_move_player_pos_rot_packet.rs old mode 100644 new mode 100755 diff --git a/azalea-protocol/src/packets/game/serverbound_move_player_rot_packet.rs b/azalea-protocol/src/packets/game/serverbound_move_player_rot_packet.rs old mode 100644 new mode 100755 diff --git a/azalea-protocol/src/packets/game/serverbound_move_player_status_only_packet.rs b/azalea-protocol/src/packets/game/serverbound_move_player_status_only_packet.rs old mode 100644 new mode 100755 diff --git a/azalea-protocol/src/packets/game/serverbound_move_vehicle_packet.rs b/azalea-protocol/src/packets/game/serverbound_move_vehicle_packet.rs old mode 100644 new mode 100755 diff --git a/azalea-protocol/src/packets/game/serverbound_paddle_boat_packet.rs b/azalea-protocol/src/packets/game/serverbound_paddle_boat_packet.rs old mode 100644 new mode 100755 diff --git a/azalea-protocol/src/packets/game/serverbound_pick_item_packet.rs b/azalea-protocol/src/packets/game/serverbound_pick_item_packet.rs old mode 100644 new mode 100755 diff --git a/azalea-protocol/src/packets/game/serverbound_place_recipe_packet.rs b/azalea-protocol/src/packets/game/serverbound_place_recipe_packet.rs old mode 100644 new mode 100755 diff --git a/azalea-protocol/src/packets/game/serverbound_player_abilities_packet.rs b/azalea-protocol/src/packets/game/serverbound_player_abilities_packet.rs old mode 100644 new mode 100755 diff --git a/azalea-protocol/src/packets/game/serverbound_player_action_packet.rs b/azalea-protocol/src/packets/game/serverbound_player_action_packet.rs old mode 100644 new mode 100755 diff --git a/azalea-protocol/src/packets/game/serverbound_player_command_packet.rs b/azalea-protocol/src/packets/game/serverbound_player_command_packet.rs old mode 100644 new mode 100755 diff --git a/azalea-protocol/src/packets/game/serverbound_player_input_packet.rs b/azalea-protocol/src/packets/game/serverbound_player_input_packet.rs old mode 100644 new mode 100755 diff --git a/azalea-protocol/src/packets/game/serverbound_pong_packet.rs b/azalea-protocol/src/packets/game/serverbound_pong_packet.rs old mode 100644 new mode 100755 diff --git a/azalea-protocol/src/packets/game/serverbound_recipe_book_change_settings_packet.rs b/azalea-protocol/src/packets/game/serverbound_recipe_book_change_settings_packet.rs old mode 100644 new mode 100755 diff --git a/azalea-protocol/src/packets/game/serverbound_recipe_book_seen_recipe_packet.rs b/azalea-protocol/src/packets/game/serverbound_recipe_book_seen_recipe_packet.rs old mode 100644 new mode 100755 diff --git a/azalea-protocol/src/packets/game/serverbound_rename_item_packet.rs b/azalea-protocol/src/packets/game/serverbound_rename_item_packet.rs old mode 100644 new mode 100755 diff --git a/azalea-protocol/src/packets/game/serverbound_resource_pack_packet.rs b/azalea-protocol/src/packets/game/serverbound_resource_pack_packet.rs old mode 100644 new mode 100755 diff --git a/azalea-protocol/src/packets/game/serverbound_seen_advancements_packet.rs b/azalea-protocol/src/packets/game/serverbound_seen_advancements_packet.rs old mode 100644 new mode 100755 diff --git a/azalea-protocol/src/packets/game/serverbound_select_trade_packet.rs b/azalea-protocol/src/packets/game/serverbound_select_trade_packet.rs old mode 100644 new mode 100755 diff --git a/azalea-protocol/src/packets/game/serverbound_set_beacon_packet.rs b/azalea-protocol/src/packets/game/serverbound_set_beacon_packet.rs old mode 100644 new mode 100755 diff --git a/azalea-protocol/src/packets/game/serverbound_set_carried_item_packet.rs b/azalea-protocol/src/packets/game/serverbound_set_carried_item_packet.rs old mode 100644 new mode 100755 diff --git a/azalea-protocol/src/packets/game/serverbound_set_command_block_packet.rs b/azalea-protocol/src/packets/game/serverbound_set_command_block_packet.rs old mode 100644 new mode 100755 diff --git a/azalea-protocol/src/packets/game/serverbound_set_command_minecart_packet.rs b/azalea-protocol/src/packets/game/serverbound_set_command_minecart_packet.rs old mode 100644 new mode 100755 diff --git a/azalea-protocol/src/packets/game/serverbound_set_creative_mode_slot_packet.rs b/azalea-protocol/src/packets/game/serverbound_set_creative_mode_slot_packet.rs old mode 100644 new mode 100755 diff --git a/azalea-protocol/src/packets/game/serverbound_set_jigsaw_block_packet.rs b/azalea-protocol/src/packets/game/serverbound_set_jigsaw_block_packet.rs old mode 100644 new mode 100755 diff --git a/azalea-protocol/src/packets/game/serverbound_set_structure_block_packet.rs b/azalea-protocol/src/packets/game/serverbound_set_structure_block_packet.rs old mode 100644 new mode 100755 diff --git a/azalea-protocol/src/packets/game/serverbound_sign_update_packet.rs b/azalea-protocol/src/packets/game/serverbound_sign_update_packet.rs old mode 100644 new mode 100755 diff --git a/azalea-protocol/src/packets/game/serverbound_swing_packet.rs b/azalea-protocol/src/packets/game/serverbound_swing_packet.rs old mode 100644 new mode 100755 diff --git a/azalea-protocol/src/packets/game/serverbound_teleport_to_entity_packet.rs b/azalea-protocol/src/packets/game/serverbound_teleport_to_entity_packet.rs old mode 100644 new mode 100755 diff --git a/azalea-protocol/src/packets/game/serverbound_use_item_on_packet.rs b/azalea-protocol/src/packets/game/serverbound_use_item_on_packet.rs old mode 100644 new mode 100755 diff --git a/azalea-protocol/src/packets/game/serverbound_use_item_packet.rs b/azalea-protocol/src/packets/game/serverbound_use_item_packet.rs old mode 100644 new mode 100755 diff --git a/azalea-protocol/src/packets/login/clientbound_login_disconnect_packet.rs b/azalea-protocol/src/packets/login/clientbound_login_disconnect_packet.rs old mode 100644 new mode 100755 diff --git a/azalea-protocol/src/packets/login/serverbound_custom_query_packet.rs b/azalea-protocol/src/packets/login/serverbound_custom_query_packet.rs old mode 100644 new mode 100755 diff --git a/azalea-protocol/src/packets/login/serverbound_key_packet.rs b/azalea-protocol/src/packets/login/serverbound_key_packet.rs old mode 100644 new mode 100755 diff --git a/azalea-protocol/src/packets/mod.rs b/azalea-protocol/src/packets/mod.rs old mode 100644 new mode 100755 diff --git a/azalea-protocol/src/packets/status/clientbound_pong_response_packet.rs b/azalea-protocol/src/packets/status/clientbound_pong_response_packet.rs old mode 100644 new mode 100755 diff --git a/azalea-protocol/src/packets/status/serverbound_ping_request_packet.rs b/azalea-protocol/src/packets/status/serverbound_ping_request_packet.rs old mode 100644 new mode 100755 diff --git a/azalea-protocol/src/read.rs b/azalea-protocol/src/read.rs old mode 100644 new mode 100755 diff --git a/azalea-registry/Cargo.toml b/azalea-registry/Cargo.toml old mode 100644 new mode 100755 diff --git a/azalea-registry/README.md b/azalea-registry/README.md old mode 100644 new mode 100755 diff --git a/azalea-registry/azalea-registry-macros/Cargo.toml b/azalea-registry/azalea-registry-macros/Cargo.toml old mode 100644 new mode 100755 diff --git a/azalea-registry/azalea-registry-macros/src/lib.rs b/azalea-registry/azalea-registry-macros/src/lib.rs old mode 100644 new mode 100755 diff --git a/azalea-registry/src/lib.rs b/azalea-registry/src/lib.rs old mode 100644 new mode 100755 diff --git a/azalea-world/Cargo.toml b/azalea-world/Cargo.toml old mode 100644 new mode 100755 index b828d72f..20dccbba --- a/azalea-world/Cargo.toml +++ b/azalea-world/Cargo.toml @@ -9,15 +9,16 @@ version = "0.3.0" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -azalea-block = {path = "../azalea-block", default-features = false, version = "^0.3.0" } -azalea-buf = {path = "../azalea-buf", version = "^0.3.0" } -azalea-chat = {path = "../azalea-chat", version = "^0.3.0" } -azalea-core = {path = "../azalea-core", version = "^0.3.0" } -azalea-nbt = {path = "../azalea-nbt", version = "^0.3.0" } -azalea-registry = {path = "../azalea-registry", version = "^0.3.0" } +azalea-block = {path = "../azalea-block", default-features = false, version = "^0.3.0"} +azalea-buf = {path = "../azalea-buf", version = "^0.3.0"} +azalea-chat = {path = "../azalea-chat", version = "^0.3.0"} +azalea-core = {path = "../azalea-core", version = "^0.3.0"} +azalea-nbt = {path = "../azalea-nbt", version = "^0.3.0"} +azalea-registry = {path = "../azalea-registry", version = "^0.3.0"} enum-as-inner = "0.5.1" log = "0.4.17" nohash-hasher = "0.2.0" +parking_lot = "^0.12.1" thiserror = "1.0.34" uuid = "1.1.2" diff --git a/azalea-world/README.md b/azalea-world/README.md old mode 100644 new mode 100755 diff --git a/azalea-world/src/bit_storage.rs b/azalea-world/src/bit_storage.rs old mode 100644 new mode 100755 diff --git a/azalea-world/src/chunk_storage.rs b/azalea-world/src/chunk_storage.rs old mode 100644 new mode 100755 index 5bc744c3..85f0ebb3 --- a/azalea-world/src/chunk_storage.rs +++ b/azalea-world/src/chunk_storage.rs @@ -6,12 +6,15 @@ use azalea_buf::BufReadError; use azalea_buf::{McBufReadable, McBufWritable}; use azalea_core::floor_mod; use azalea_core::{BlockPos, ChunkBlockPos, ChunkPos, ChunkSectionBlockPos}; +use log::debug; +use log::trace; +use parking_lot::Mutex; use std::fmt::Debug; use std::io::Cursor; use std::{ io::Write, ops::{Index, IndexMut}, - sync::{Arc, Mutex}, + sync::Arc, }; const SECTION_HEIGHT: u32 = 16; @@ -82,7 +85,7 @@ impl ChunkStorage { pub fn get_block_state(&self, pos: &BlockPos) -> Option { let chunk_pos = ChunkPos::from(pos); let chunk = self[&chunk_pos].as_ref()?; - let chunk = chunk.lock().unwrap(); + let chunk = chunk.lock(); chunk.get(&ChunkBlockPos::from(pos), self.min_y) } @@ -92,7 +95,7 @@ impl ChunkStorage { } let chunk_pos = ChunkPos::from(pos); let chunk = self[&chunk_pos].as_ref()?; - let mut chunk = chunk.lock().unwrap(); + let mut chunk = chunk.lock(); Some(chunk.get_and_set(&ChunkBlockPos::from(pos), state, self.min_y)) } @@ -101,8 +104,9 @@ impl ChunkStorage { pos: &ChunkPos, data: &mut Cursor<&[u8]>, ) -> Result<(), BufReadError> { + debug!("Replacing chunk at {:?}", pos); if !self.in_range(pos) { - log::trace!( + trace!( "Ignoring chunk since it's not in the view range: {}, {}", pos.x, pos.z @@ -115,7 +119,7 @@ impl ChunkStorage { self.height, )?)); - log::trace!("Loaded chunk {:?}", pos); + trace!("Loaded chunk {:?}", pos); self[pos] = Some(chunk); Ok(()) @@ -164,6 +168,10 @@ impl Chunk { } pub fn get(&self, pos: &ChunkBlockPos, min_y: i32) -> Option { + if pos.y < min_y { + // y position is out of bounds + return None; + } let section_index = self.section_index(pos.y, min_y) as usize; if section_index >= self.sections.len() { // y position is out of bounds diff --git a/azalea-world/src/entity/attributes.rs b/azalea-world/src/entity/attributes.rs new file mode 100644 index 00000000..1050615c --- /dev/null +++ b/azalea-world/src/entity/attributes.rs @@ -0,0 +1,116 @@ +//! https://minecraft.fandom.com/wiki/Attribute + +use std::{ + collections::HashMap, + io::{Cursor, Write}, +}; + +use azalea_buf::{BufReadError, McBuf, McBufReadable, McBufWritable}; +use thiserror::Error; +use uuid::{uuid, Uuid}; + +#[derive(Clone, Debug)] +pub struct AttributeModifiers { + pub speed: AttributeInstance, +} + +#[derive(Clone, Debug)] +pub struct AttributeInstance { + pub base: f64, + modifiers_by_uuid: HashMap, +} + +#[derive(Clone, Debug, Error)] +#[error("A modifier with this UUID is already present.")] +pub struct AlreadyPresentError; + +impl AttributeInstance { + pub fn new(base: f64) -> Self { + Self { + base, + modifiers_by_uuid: HashMap::new(), + } + } + + pub fn calculate(&self) -> f64 { + let mut total = self.base; + for modifier in self.modifiers_by_uuid.values() { + match modifier.operation { + AttributeModifierOperation::Addition => total += modifier.amount, + AttributeModifierOperation::MultiplyBase => total += self.base * modifier.amount, + _ => {} + } + match modifier.operation { + AttributeModifierOperation::MultiplyTotal => total *= 1.0 + modifier.amount, + _ => {} + } + } + total + } + + /// Add a new modifier to this attribute. + pub fn insert(&mut self, modifier: AttributeModifier) -> Result<(), AlreadyPresentError> { + if self + .modifiers_by_uuid + .insert(modifier.uuid, modifier) + .is_some() + { + Err(AlreadyPresentError) + } else { + Ok(()) + } + } + + /// Remove the modifier with the given UUID from this attribute, returning + /// the previous modifier is present. + pub fn remove(&mut self, uuid: &Uuid) -> Option { + self.modifiers_by_uuid.remove(uuid) + } +} + +#[derive(Clone, Debug)] +pub struct AttributeModifier { + pub uuid: Uuid, + pub name: String, + pub amount: f64, + pub operation: AttributeModifierOperation, +} + +#[derive(Clone, Debug, Copy, McBuf)] +pub enum AttributeModifierOperation { + Addition, + MultiplyBase, + MultiplyTotal, +} + +pub fn sprinting_modifier() -> AttributeModifier { + AttributeModifier { + uuid: uuid!("662A6B8D-DA3E-4C1C-8813-96EA6097278D"), + name: "Sprinting speed boost".to_string(), + amount: 0.30000001192092896, + operation: AttributeModifierOperation::MultiplyTotal, + } +} + +impl McBufReadable for AttributeModifier { + fn read_from(buf: &mut Cursor<&[u8]>) -> Result { + let uuid = Uuid::read_from(buf)?; + let amount = f64::read_from(buf)?; + let operation = AttributeModifierOperation::read_from(buf)?; + Ok(Self { + uuid, + name: "Unknown synced attribute modifier".to_string(), + amount, + operation, + }) + } +} + +impl McBufWritable for AttributeModifier { + fn write_into(&self, buf: &mut impl Write) -> Result<(), std::io::Error> { + self.uuid.write_into(buf)?; + self.amount.write_into(buf)?; + self.operation.write_into(buf)?; + Ok(()) + } +} diff --git a/azalea-world/src/entity/data.rs b/azalea-world/src/entity/data.rs old mode 100644 new mode 100755 diff --git a/azalea-world/src/entity/dimensions.rs b/azalea-world/src/entity/dimensions.rs old mode 100644 new mode 100755 diff --git a/azalea-world/src/entity/metadata.rs b/azalea-world/src/entity/metadata.rs index 59a8cb88..a031ade2 100644 --- a/azalea-world/src/entity/metadata.rs +++ b/azalea-world/src/entity/metadata.rs @@ -6,7 +6,10 @@ use super::{EntityDataValue, Pose, Rotations, VillagerData}; use azalea_block::BlockState; use azalea_chat::Component; use azalea_core::{BlockPos, Direction, Particle, Slot}; -use std::{collections::VecDeque, ops::Deref}; +use std::{ + collections::VecDeque, + ops::{Deref, DerefMut}, +}; use uuid::Uuid; #[derive(Debug, Clone)] @@ -64,6 +67,11 @@ impl Deref for Allay { &self.abstract_creature } } +impl DerefMut for Allay { + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.abstract_creature + } +} #[derive(Debug, Clone)] pub struct AreaEffectCloud { @@ -132,6 +140,11 @@ impl Deref for AreaEffectCloud { &self.abstract_entity } } +impl DerefMut for AreaEffectCloud { + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.abstract_entity + } +} #[derive(Debug, Clone)] pub struct ArmorStand { @@ -250,6 +263,11 @@ impl Deref for ArmorStand { &self.abstract_living } } +impl DerefMut for ArmorStand { + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.abstract_living + } +} #[derive(Debug, Clone)] pub struct Arrow { @@ -336,6 +354,11 @@ impl Deref for Arrow { &self.abstract_entity } } +impl DerefMut for Arrow { + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.abstract_entity + } +} #[derive(Debug, Clone)] pub struct Axolotl { @@ -398,6 +421,11 @@ impl Deref for Axolotl { &self.abstract_animal } } +impl DerefMut for Axolotl { + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.abstract_animal + } +} #[derive(Debug, Clone)] pub struct Bat { @@ -456,6 +484,11 @@ impl Deref for Bat { &self.abstract_insentient } } +impl DerefMut for Bat { + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.abstract_insentient + } +} #[derive(Debug, Clone)] pub struct Bee { @@ -536,6 +569,11 @@ impl Deref for Bee { &self.abstract_animal } } +impl DerefMut for Bee { + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.abstract_animal + } +} #[derive(Debug, Clone)] pub struct Blaze { @@ -594,6 +632,11 @@ impl Deref for Blaze { &self.abstract_monster } } +impl DerefMut for Blaze { + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.abstract_monster + } +} #[derive(Debug, Clone)] pub struct Boat { @@ -680,6 +723,11 @@ impl Deref for Boat { &self.abstract_entity } } +impl DerefMut for Boat { + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.abstract_entity + } +} #[derive(Debug, Clone)] pub struct Cat { @@ -748,6 +796,11 @@ impl Deref for Cat { &self.abstract_tameable } } +impl DerefMut for Cat { + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.abstract_tameable + } +} #[derive(Debug, Clone)] pub struct CaveSpider { @@ -786,6 +839,11 @@ impl Deref for CaveSpider { &self.spider } } +impl DerefMut for CaveSpider { + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.spider + } +} #[derive(Debug, Clone)] pub struct ChestBoat { @@ -824,6 +882,11 @@ impl Deref for ChestBoat { &self.boat } } +impl DerefMut for ChestBoat { + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.boat + } +} #[derive(Debug, Clone)] pub struct ChestMinecart { @@ -862,6 +925,11 @@ impl Deref for ChestMinecart { &self.abstract_minecart } } +impl DerefMut for ChestMinecart { + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.abstract_minecart + } +} #[derive(Debug, Clone)] pub struct Chicken { @@ -900,6 +968,11 @@ impl Deref for Chicken { &self.abstract_animal } } +impl DerefMut for Chicken { + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.abstract_animal + } +} #[derive(Debug, Clone)] pub struct Cod { @@ -950,6 +1023,11 @@ impl Deref for Cod { &self.abstract_creature } } +impl DerefMut for Cod { + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.abstract_creature + } +} #[derive(Debug, Clone)] pub struct CommandBlockMinecart { @@ -1006,6 +1084,11 @@ impl Deref for CommandBlockMinecart { &self.abstract_minecart } } +impl DerefMut for CommandBlockMinecart { + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.abstract_minecart + } +} #[derive(Debug, Clone)] pub struct Cow { @@ -1044,6 +1127,11 @@ impl Deref for Cow { &self.abstract_animal } } +impl DerefMut for Cow { + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.abstract_animal + } +} #[derive(Debug, Clone)] pub struct Creeper { @@ -1106,6 +1194,11 @@ impl Deref for Creeper { &self.abstract_monster } } +impl DerefMut for Creeper { + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.abstract_monster + } +} #[derive(Debug, Clone)] pub struct Dolphin { @@ -1168,6 +1261,11 @@ impl Deref for Dolphin { &self.abstract_creature } } +impl DerefMut for Dolphin { + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.abstract_creature + } +} #[derive(Debug, Clone)] pub struct Donkey { @@ -1270,6 +1368,11 @@ impl Deref for Donkey { &self.abstract_animal } } +impl DerefMut for Donkey { + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.abstract_animal + } +} #[derive(Debug, Clone)] pub struct DragonFireball { @@ -1308,6 +1411,11 @@ impl Deref for DragonFireball { &self.abstract_entity } } +impl DerefMut for DragonFireball { + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.abstract_entity + } +} #[derive(Debug, Clone)] pub struct Drowned { @@ -1346,6 +1454,11 @@ impl Deref for Drowned { &self.zombie } } +impl DerefMut for Drowned { + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.zombie + } +} #[derive(Debug, Clone)] pub struct Egg { @@ -1396,6 +1509,11 @@ impl Deref for Egg { &self.abstract_entity } } +impl DerefMut for Egg { + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.abstract_entity + } +} #[derive(Debug, Clone)] pub struct ElderGuardian { @@ -1434,6 +1552,11 @@ impl Deref for ElderGuardian { &self.guardian } } +impl DerefMut for ElderGuardian { + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.guardian + } +} #[derive(Debug, Clone)] pub struct EndCrystal { @@ -1490,6 +1613,11 @@ impl Deref for EndCrystal { &self.abstract_entity } } +impl DerefMut for EndCrystal { + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.abstract_entity + } +} #[derive(Debug, Clone)] pub struct EnderDragon { @@ -1540,6 +1668,11 @@ impl Deref for EnderDragon { &self.abstract_insentient } } +impl DerefMut for EnderDragon { + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.abstract_insentient + } +} #[derive(Debug, Clone)] pub struct EnderPearl { @@ -1590,6 +1723,11 @@ impl Deref for EnderPearl { &self.abstract_entity } } +impl DerefMut for EnderPearl { + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.abstract_entity + } +} #[derive(Debug, Clone)] pub struct Enderman { @@ -1654,6 +1792,11 @@ impl Deref for Enderman { &self.abstract_monster } } +impl DerefMut for Enderman { + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.abstract_monster + } +} #[derive(Debug, Clone)] pub struct Endermite { @@ -1692,6 +1835,11 @@ impl Deref for Endermite { &self.abstract_monster } } +impl DerefMut for Endermite { + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.abstract_monster + } +} #[derive(Debug, Clone)] pub struct Evoker { @@ -1748,6 +1896,11 @@ impl Deref for Evoker { &self.abstract_monster } } +impl DerefMut for Evoker { + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.abstract_monster + } +} #[derive(Debug, Clone)] pub struct EvokerFangs { @@ -1786,6 +1939,11 @@ impl Deref for EvokerFangs { &self.abstract_entity } } +impl DerefMut for EvokerFangs { + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.abstract_entity + } +} #[derive(Debug, Clone)] pub struct ExperienceBottle { @@ -1836,6 +1994,11 @@ impl Deref for ExperienceBottle { &self.abstract_entity } } +impl DerefMut for ExperienceBottle { + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.abstract_entity + } +} #[derive(Debug, Clone)] pub struct ExperienceOrb { @@ -1874,6 +2037,11 @@ impl Deref for ExperienceOrb { &self.abstract_entity } } +impl DerefMut for ExperienceOrb { + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.abstract_entity + } +} #[derive(Debug, Clone)] pub struct EyeOfEnder { @@ -1924,6 +2092,11 @@ impl Deref for EyeOfEnder { &self.abstract_entity } } +impl DerefMut for EyeOfEnder { + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.abstract_entity + } +} #[derive(Debug, Clone)] pub struct FallingBlock { @@ -1974,6 +2147,11 @@ impl Deref for FallingBlock { &self.abstract_entity } } +impl DerefMut for FallingBlock { + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.abstract_entity + } +} #[derive(Debug, Clone)] pub struct Fireball { @@ -2024,6 +2202,11 @@ impl Deref for Fireball { &self.abstract_entity } } +impl DerefMut for Fireball { + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.abstract_entity + } +} #[derive(Debug, Clone)] pub struct FireworkRocket { @@ -2088,6 +2271,11 @@ impl Deref for FireworkRocket { &self.abstract_entity } } +impl DerefMut for FireworkRocket { + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.abstract_entity + } +} #[derive(Debug, Clone)] pub struct FishingBobber { @@ -2144,6 +2332,11 @@ impl Deref for FishingBobber { &self.abstract_entity } } +impl DerefMut for FishingBobber { + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.abstract_entity + } +} #[derive(Debug, Clone)] pub struct Fox { @@ -2260,6 +2453,11 @@ impl Deref for Fox { &self.abstract_animal } } +impl DerefMut for Fox { + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.abstract_animal + } +} #[derive(Debug, Clone)] pub struct Frog { @@ -2318,6 +2516,11 @@ impl Deref for Frog { &self.abstract_animal } } +impl DerefMut for Frog { + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.abstract_animal + } +} #[derive(Debug, Clone)] pub struct FurnaceMinecart { @@ -2368,6 +2571,11 @@ impl Deref for FurnaceMinecart { &self.abstract_minecart } } +impl DerefMut for FurnaceMinecart { + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.abstract_minecart + } +} #[derive(Debug, Clone)] pub struct Ghast { @@ -2418,6 +2626,11 @@ impl Deref for Ghast { &self.abstract_insentient } } +impl DerefMut for Ghast { + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.abstract_insentient + } +} #[derive(Debug, Clone)] pub struct Giant { @@ -2456,6 +2669,11 @@ impl Deref for Giant { &self.abstract_monster } } +impl DerefMut for Giant { + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.abstract_monster + } +} #[derive(Debug, Clone)] pub struct GlowItemFrame { @@ -2494,6 +2712,11 @@ impl Deref for GlowItemFrame { &self.item_frame } } +impl DerefMut for GlowItemFrame { + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.item_frame + } +} #[derive(Debug, Clone)] pub struct GlowSquid { @@ -2544,6 +2767,11 @@ impl Deref for GlowSquid { &self.squid } } +impl DerefMut for GlowSquid { + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.squid + } +} #[derive(Debug, Clone)] pub struct Goat { @@ -2606,6 +2834,11 @@ impl Deref for Goat { &self.abstract_animal } } +impl DerefMut for Goat { + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.abstract_animal + } +} #[derive(Debug, Clone)] pub struct Guardian { @@ -2662,6 +2895,11 @@ impl Deref for Guardian { &self.abstract_monster } } +impl DerefMut for Guardian { + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.abstract_monster + } +} #[derive(Debug, Clone)] pub struct Hoglin { @@ -2714,6 +2952,11 @@ impl Deref for Hoglin { &self.abstract_animal } } +impl DerefMut for Hoglin { + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.abstract_animal + } +} #[derive(Debug, Clone)] pub struct HopperMinecart { @@ -2752,6 +2995,11 @@ impl Deref for HopperMinecart { &self.abstract_minecart } } +impl DerefMut for HopperMinecart { + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.abstract_minecart + } +} #[derive(Debug, Clone)] pub struct Horse { @@ -2854,6 +3102,11 @@ impl Deref for Horse { &self.abstract_animal } } +impl DerefMut for Horse { + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.abstract_animal + } +} #[derive(Debug, Clone)] pub struct Husk { @@ -2892,6 +3145,11 @@ impl Deref for Husk { &self.zombie } } +impl DerefMut for Husk { + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.zombie + } +} #[derive(Debug, Clone)] pub struct Illusioner { @@ -2948,6 +3206,11 @@ impl Deref for Illusioner { &self.abstract_monster } } +impl DerefMut for Illusioner { + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.abstract_monster + } +} #[derive(Debug, Clone)] pub struct IronGolem { @@ -3006,6 +3269,11 @@ impl Deref for IronGolem { &self.abstract_creature } } +impl DerefMut for IronGolem { + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.abstract_creature + } +} #[derive(Debug, Clone)] pub struct Item { @@ -3056,6 +3324,11 @@ impl Deref for Item { &self.abstract_entity } } +impl DerefMut for Item { + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.abstract_entity + } +} #[derive(Debug, Clone)] pub struct ItemFrame { @@ -3112,6 +3385,11 @@ impl Deref for ItemFrame { &self.abstract_entity } } +impl DerefMut for ItemFrame { + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.abstract_entity + } +} #[derive(Debug, Clone)] pub struct LeashKnot { @@ -3150,6 +3428,11 @@ impl Deref for LeashKnot { &self.abstract_entity } } +impl DerefMut for LeashKnot { + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.abstract_entity + } +} #[derive(Debug, Clone)] pub struct LightningBolt { @@ -3188,6 +3471,11 @@ impl Deref for LightningBolt { &self.abstract_entity } } +impl DerefMut for LightningBolt { + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.abstract_entity + } +} #[derive(Debug, Clone)] pub struct Llama { @@ -3308,6 +3596,11 @@ impl Deref for Llama { &self.abstract_animal } } +impl DerefMut for Llama { + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.abstract_animal + } +} #[derive(Debug, Clone)] pub struct LlamaSpit { @@ -3346,6 +3639,11 @@ impl Deref for LlamaSpit { &self.abstract_entity } } +impl DerefMut for LlamaSpit { + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.abstract_entity + } +} #[derive(Debug, Clone)] pub struct MagmaCube { @@ -3384,6 +3682,11 @@ impl Deref for MagmaCube { &self.slime } } +impl DerefMut for MagmaCube { + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.slime + } +} #[derive(Debug, Clone)] pub struct Marker { @@ -3422,6 +3725,11 @@ impl Deref for Marker { &self.abstract_entity } } +impl DerefMut for Marker { + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.abstract_entity + } +} #[derive(Debug, Clone)] pub struct Minecart { @@ -3460,6 +3768,11 @@ impl Deref for Minecart { &self.abstract_minecart } } +impl DerefMut for Minecart { + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.abstract_minecart + } +} #[derive(Debug, Clone)] pub struct Mooshroom { @@ -3507,6 +3820,11 @@ impl Deref for Mooshroom { &self.cow } } +impl DerefMut for Mooshroom { + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.cow + } +} #[derive(Debug, Clone)] pub struct Mule { @@ -3609,6 +3927,11 @@ impl Deref for Mule { &self.abstract_animal } } +impl DerefMut for Mule { + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.abstract_animal + } +} #[derive(Debug, Clone)] pub struct Ocelot { @@ -3659,6 +3982,11 @@ impl Deref for Ocelot { &self.abstract_animal } } +impl DerefMut for Ocelot { + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.abstract_animal + } +} #[derive(Debug, Clone)] pub struct Painting { @@ -3711,6 +4039,11 @@ impl Deref for Painting { &self.abstract_entity } } +impl DerefMut for Painting { + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.abstract_entity + } +} #[derive(Debug, Clone)] pub struct Panda { @@ -3823,6 +4156,11 @@ impl Deref for Panda { &self.abstract_animal } } +impl DerefMut for Panda { + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.abstract_animal + } +} #[derive(Debug, Clone)] pub struct Parrot { @@ -3873,6 +4211,11 @@ impl Deref for Parrot { &self.abstract_tameable } } +impl DerefMut for Parrot { + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.abstract_tameable + } +} #[derive(Debug, Clone)] pub struct Phantom { @@ -3923,6 +4266,11 @@ impl Deref for Phantom { &self.abstract_insentient } } +impl DerefMut for Phantom { + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.abstract_insentient + } +} #[derive(Debug, Clone)] pub struct Pig { @@ -3979,6 +4327,11 @@ impl Deref for Pig { &self.abstract_animal } } +impl DerefMut for Pig { + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.abstract_animal + } +} #[derive(Debug, Clone)] pub struct Piglin { @@ -4049,6 +4402,11 @@ impl Deref for Piglin { &self.abstract_monster } } +impl DerefMut for Piglin { + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.abstract_monster + } +} #[derive(Debug, Clone)] pub struct PiglinBrute { @@ -4101,6 +4459,11 @@ impl Deref for PiglinBrute { &self.abstract_monster } } +impl DerefMut for PiglinBrute { + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.abstract_monster + } +} #[derive(Debug, Clone)] pub struct Pillager { @@ -4157,6 +4520,11 @@ impl Deref for Pillager { &self.abstract_monster } } +impl DerefMut for Pillager { + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.abstract_monster + } +} #[derive(Debug, Clone)] pub struct Player { @@ -4239,6 +4607,11 @@ impl Deref for Player { &self.abstract_living } } +impl DerefMut for Player { + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.abstract_living + } +} #[derive(Debug, Clone)] pub struct PolarBear { @@ -4289,6 +4662,11 @@ impl Deref for PolarBear { &self.abstract_animal } } +impl DerefMut for PolarBear { + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.abstract_animal + } +} #[derive(Debug, Clone)] pub struct Potion { @@ -4339,6 +4717,11 @@ impl Deref for Potion { &self.abstract_entity } } +impl DerefMut for Potion { + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.abstract_entity + } +} #[derive(Debug, Clone)] pub struct Pufferfish { @@ -4395,6 +4778,11 @@ impl Deref for Pufferfish { &self.abstract_creature } } +impl DerefMut for Pufferfish { + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.abstract_creature + } +} #[derive(Debug, Clone)] pub struct Rabbit { @@ -4445,6 +4833,11 @@ impl Deref for Rabbit { &self.abstract_animal } } +impl DerefMut for Rabbit { + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.abstract_animal + } +} #[derive(Debug, Clone)] pub struct Ravager { @@ -4495,6 +4888,11 @@ impl Deref for Ravager { &self.abstract_monster } } +impl DerefMut for Ravager { + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.abstract_monster + } +} #[derive(Debug, Clone)] pub struct Salmon { @@ -4545,6 +4943,11 @@ impl Deref for Salmon { &self.abstract_creature } } +impl DerefMut for Salmon { + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.abstract_creature + } +} #[derive(Debug, Clone)] pub struct Sheep { @@ -4603,6 +5006,11 @@ impl Deref for Sheep { &self.abstract_animal } } +impl DerefMut for Sheep { + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.abstract_animal + } +} #[derive(Debug, Clone)] pub struct Shulker { @@ -4665,6 +5073,11 @@ impl Deref for Shulker { &self.abstract_creature } } +impl DerefMut for Shulker { + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.abstract_creature + } +} #[derive(Debug, Clone)] pub struct ShulkerBullet { @@ -4703,6 +5116,11 @@ impl Deref for ShulkerBullet { &self.abstract_entity } } +impl DerefMut for ShulkerBullet { + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.abstract_entity + } +} #[derive(Debug, Clone)] pub struct Silverfish { @@ -4741,6 +5159,11 @@ impl Deref for Silverfish { &self.abstract_monster } } +impl DerefMut for Silverfish { + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.abstract_monster + } +} #[derive(Debug, Clone)] pub struct Skeleton { @@ -4791,6 +5214,11 @@ impl Deref for Skeleton { &self.abstract_monster } } +impl DerefMut for Skeleton { + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.abstract_monster + } +} #[derive(Debug, Clone)] pub struct SkeletonHorse { @@ -4887,6 +5315,11 @@ impl Deref for SkeletonHorse { &self.abstract_animal } } +impl DerefMut for SkeletonHorse { + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.abstract_animal + } +} #[derive(Debug, Clone)] pub struct Slime { @@ -4937,6 +5370,11 @@ impl Deref for Slime { &self.abstract_insentient } } +impl DerefMut for Slime { + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.abstract_insentient + } +} #[derive(Debug, Clone)] pub struct SmallFireball { @@ -4987,6 +5425,11 @@ impl Deref for SmallFireball { &self.abstract_entity } } +impl DerefMut for SmallFireball { + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.abstract_entity + } +} #[derive(Debug, Clone)] pub struct SnowGolem { @@ -5045,6 +5488,11 @@ impl Deref for SnowGolem { &self.abstract_creature } } +impl DerefMut for SnowGolem { + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.abstract_creature + } +} #[derive(Debug, Clone)] pub struct Snowball { @@ -5095,6 +5543,11 @@ impl Deref for Snowball { &self.abstract_entity } } +impl DerefMut for Snowball { + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.abstract_entity + } +} #[derive(Debug, Clone)] pub struct SpawnerMinecart { @@ -5133,6 +5586,11 @@ impl Deref for SpawnerMinecart { &self.abstract_minecart } } +impl DerefMut for SpawnerMinecart { + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.abstract_minecart + } +} #[derive(Debug, Clone)] pub struct SpectralArrow { @@ -5213,6 +5671,11 @@ impl Deref for SpectralArrow { &self.abstract_entity } } +impl DerefMut for SpectralArrow { + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.abstract_entity + } +} #[derive(Debug, Clone)] pub struct Spider { @@ -5271,6 +5734,11 @@ impl Deref for Spider { &self.abstract_monster } } +impl DerefMut for Spider { + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.abstract_monster + } +} #[derive(Debug, Clone)] pub struct Squid { @@ -5309,6 +5777,11 @@ impl Deref for Squid { &self.abstract_creature } } +impl DerefMut for Squid { + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.abstract_creature + } +} #[derive(Debug, Clone)] pub struct Stray { @@ -5347,6 +5820,11 @@ impl Deref for Stray { &self.abstract_monster } } +impl DerefMut for Stray { + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.abstract_monster + } +} #[derive(Debug, Clone)] pub struct Strider { @@ -5409,6 +5887,11 @@ impl Deref for Strider { &self.abstract_animal } } +impl DerefMut for Strider { + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.abstract_animal + } +} #[derive(Debug, Clone)] pub struct Tadpole { @@ -5459,6 +5942,11 @@ impl Deref for Tadpole { &self.abstract_creature } } +impl DerefMut for Tadpole { + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.abstract_creature + } +} #[derive(Debug, Clone)] pub struct Tnt { @@ -5509,6 +5997,11 @@ impl Deref for Tnt { &self.abstract_entity } } +impl DerefMut for Tnt { + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.abstract_entity + } +} #[derive(Debug, Clone)] pub struct TntMinecart { @@ -5547,6 +6040,11 @@ impl Deref for TntMinecart { &self.abstract_minecart } } +impl DerefMut for TntMinecart { + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.abstract_minecart + } +} #[derive(Debug, Clone)] pub struct TraderLlama { @@ -5585,6 +6083,11 @@ impl Deref for TraderLlama { &self.llama } } +impl DerefMut for TraderLlama { + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.llama + } +} #[derive(Debug, Clone)] pub struct Trident { @@ -5677,6 +6180,11 @@ impl Deref for Trident { &self.abstract_entity } } +impl DerefMut for Trident { + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.abstract_entity + } +} #[derive(Debug, Clone)] pub struct TropicalFish { @@ -5733,6 +6241,11 @@ impl Deref for TropicalFish { &self.abstract_creature } } +impl DerefMut for TropicalFish { + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.abstract_creature + } +} #[derive(Debug, Clone)] pub struct Turtle { @@ -5813,6 +6326,11 @@ impl Deref for Turtle { &self.abstract_animal } } +impl DerefMut for Turtle { + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.abstract_animal + } +} #[derive(Debug, Clone)] pub struct Vex { @@ -5863,6 +6381,11 @@ impl Deref for Vex { &self.abstract_monster } } +impl DerefMut for Vex { + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.abstract_monster + } +} #[derive(Debug, Clone)] pub struct Villager { @@ -5919,6 +6442,11 @@ impl Deref for Villager { &self.abstract_ageable } } +impl DerefMut for Villager { + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.abstract_ageable + } +} #[derive(Debug, Clone)] pub struct Vindicator { @@ -5969,6 +6497,11 @@ impl Deref for Vindicator { &self.abstract_monster } } +impl DerefMut for Vindicator { + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.abstract_monster + } +} #[derive(Debug, Clone)] pub struct WanderingTrader { @@ -6019,6 +6552,11 @@ impl Deref for WanderingTrader { &self.abstract_ageable } } +impl DerefMut for WanderingTrader { + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.abstract_ageable + } +} #[derive(Debug, Clone)] pub struct Warden { @@ -6069,6 +6607,11 @@ impl Deref for Warden { &self.abstract_monster } } +impl DerefMut for Warden { + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.abstract_monster + } +} #[derive(Debug, Clone)] pub struct Witch { @@ -6125,6 +6668,11 @@ impl Deref for Witch { &self.abstract_monster } } +impl DerefMut for Witch { + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.abstract_monster + } +} #[derive(Debug, Clone)] pub struct Wither { @@ -6193,6 +6741,11 @@ impl Deref for Wither { &self.abstract_monster } } +impl DerefMut for Wither { + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.abstract_monster + } +} #[derive(Debug, Clone)] pub struct WitherSkeleton { @@ -6231,6 +6784,11 @@ impl Deref for WitherSkeleton { &self.abstract_monster } } +impl DerefMut for WitherSkeleton { + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.abstract_monster + } +} #[derive(Debug, Clone)] pub struct WitherSkull { @@ -6281,6 +6839,11 @@ impl Deref for WitherSkull { &self.abstract_entity } } +impl DerefMut for WitherSkull { + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.abstract_entity + } +} #[derive(Debug, Clone)] pub struct Wolf { @@ -6343,6 +6906,11 @@ impl Deref for Wolf { &self.abstract_tameable } } +impl DerefMut for Wolf { + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.abstract_tameable + } +} #[derive(Debug, Clone)] pub struct Zoglin { @@ -6393,6 +6961,11 @@ impl Deref for Zoglin { &self.abstract_monster } } +impl DerefMut for Zoglin { + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.abstract_monster + } +} #[derive(Debug, Clone)] pub struct Zombie { @@ -6455,6 +7028,11 @@ impl Deref for Zombie { &self.abstract_monster } } +impl DerefMut for Zombie { + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.abstract_monster + } +} #[derive(Debug, Clone)] pub struct ZombieHorse { @@ -6551,6 +7129,11 @@ impl Deref for ZombieHorse { &self.abstract_animal } } +impl DerefMut for ZombieHorse { + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.abstract_animal + } +} #[derive(Debug, Clone)] pub struct ZombieVillager { @@ -6607,6 +7190,11 @@ impl Deref for ZombieVillager { &self.zombie } } +impl DerefMut for ZombieVillager { + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.zombie + } +} #[derive(Debug, Clone)] pub struct ZombifiedPiglin { @@ -6645,6 +7233,11 @@ impl Deref for ZombifiedPiglin { &self.zombie } } +impl DerefMut for ZombifiedPiglin { + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.zombie + } +} #[derive(Debug, Clone)] pub struct AbstractAgeable { @@ -6695,6 +7288,11 @@ impl Deref for AbstractAgeable { &self.abstract_creature } } +impl DerefMut for AbstractAgeable { + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.abstract_creature + } +} #[derive(Debug, Clone)] pub struct AbstractAnimal { @@ -6733,6 +7331,11 @@ impl Deref for AbstractAnimal { &self.abstract_ageable } } +impl DerefMut for AbstractAnimal { + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.abstract_ageable + } +} #[derive(Debug, Clone)] pub struct AbstractCreature { @@ -6773,6 +7376,11 @@ impl Deref for AbstractCreature { &self.abstract_insentient } } +impl DerefMut for AbstractCreature { + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.abstract_insentient + } +} #[derive(Debug, Clone)] pub struct AbstractEntity { @@ -6982,6 +7590,11 @@ impl Deref for AbstractInsentient { &self.abstract_living } } +impl DerefMut for AbstractInsentient { + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.abstract_living + } +} #[derive(Debug, Clone)] pub struct AbstractLiving { @@ -7084,6 +7697,11 @@ impl Deref for AbstractLiving { &self.abstract_entity } } +impl DerefMut for AbstractLiving { + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.abstract_entity + } +} #[derive(Debug, Clone)] pub struct AbstractMinecart { @@ -7164,6 +7782,11 @@ impl Deref for AbstractMinecart { &self.abstract_entity } } +impl DerefMut for AbstractMinecart { + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.abstract_entity + } +} #[derive(Debug, Clone)] pub struct AbstractMonster { @@ -7202,6 +7825,11 @@ impl Deref for AbstractMonster { &self.abstract_creature } } +impl DerefMut for AbstractMonster { + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.abstract_creature + } +} #[derive(Debug, Clone)] pub struct AbstractTameable { @@ -7274,6 +7902,11 @@ impl Deref for AbstractTameable { &self.abstract_animal } } +impl DerefMut for AbstractTameable { + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.abstract_animal + } +} #[derive(Debug, Clone)] pub enum EntityMetadata { @@ -7748,3 +8381,253 @@ impl EntityMetadata { } } } + +impl Deref for EntityMetadata { + type Target = AbstractEntity; + fn deref(&self) -> &Self::Target { + match self { + EntityMetadata::Allay(entity) => entity, + EntityMetadata::AreaEffectCloud(entity) => entity, + EntityMetadata::ArmorStand(entity) => entity, + EntityMetadata::Arrow(entity) => entity, + EntityMetadata::Axolotl(entity) => entity, + EntityMetadata::Bat(entity) => entity, + EntityMetadata::Bee(entity) => entity, + EntityMetadata::Blaze(entity) => entity, + EntityMetadata::Boat(entity) => entity, + EntityMetadata::Cat(entity) => entity, + EntityMetadata::CaveSpider(entity) => entity, + EntityMetadata::ChestBoat(entity) => entity, + EntityMetadata::ChestMinecart(entity) => entity, + EntityMetadata::Chicken(entity) => entity, + EntityMetadata::Cod(entity) => entity, + EntityMetadata::CommandBlockMinecart(entity) => entity, + EntityMetadata::Cow(entity) => entity, + EntityMetadata::Creeper(entity) => entity, + EntityMetadata::Dolphin(entity) => entity, + EntityMetadata::Donkey(entity) => entity, + EntityMetadata::DragonFireball(entity) => entity, + EntityMetadata::Drowned(entity) => entity, + EntityMetadata::Egg(entity) => entity, + EntityMetadata::ElderGuardian(entity) => entity, + EntityMetadata::EndCrystal(entity) => entity, + EntityMetadata::EnderDragon(entity) => entity, + EntityMetadata::EnderPearl(entity) => entity, + EntityMetadata::Enderman(entity) => entity, + EntityMetadata::Endermite(entity) => entity, + EntityMetadata::Evoker(entity) => entity, + EntityMetadata::EvokerFangs(entity) => entity, + EntityMetadata::ExperienceBottle(entity) => entity, + EntityMetadata::ExperienceOrb(entity) => entity, + EntityMetadata::EyeOfEnder(entity) => entity, + EntityMetadata::FallingBlock(entity) => entity, + EntityMetadata::Fireball(entity) => entity, + EntityMetadata::FireworkRocket(entity) => entity, + EntityMetadata::FishingBobber(entity) => entity, + EntityMetadata::Fox(entity) => entity, + EntityMetadata::Frog(entity) => entity, + EntityMetadata::FurnaceMinecart(entity) => entity, + EntityMetadata::Ghast(entity) => entity, + EntityMetadata::Giant(entity) => entity, + EntityMetadata::GlowItemFrame(entity) => entity, + EntityMetadata::GlowSquid(entity) => entity, + EntityMetadata::Goat(entity) => entity, + EntityMetadata::Guardian(entity) => entity, + EntityMetadata::Hoglin(entity) => entity, + EntityMetadata::HopperMinecart(entity) => entity, + EntityMetadata::Horse(entity) => entity, + EntityMetadata::Husk(entity) => entity, + EntityMetadata::Illusioner(entity) => entity, + EntityMetadata::IronGolem(entity) => entity, + EntityMetadata::Item(entity) => entity, + EntityMetadata::ItemFrame(entity) => entity, + EntityMetadata::LeashKnot(entity) => entity, + EntityMetadata::LightningBolt(entity) => entity, + EntityMetadata::Llama(entity) => entity, + EntityMetadata::LlamaSpit(entity) => entity, + EntityMetadata::MagmaCube(entity) => entity, + EntityMetadata::Marker(entity) => entity, + EntityMetadata::Minecart(entity) => entity, + EntityMetadata::Mooshroom(entity) => entity, + EntityMetadata::Mule(entity) => entity, + EntityMetadata::Ocelot(entity) => entity, + EntityMetadata::Painting(entity) => entity, + EntityMetadata::Panda(entity) => entity, + EntityMetadata::Parrot(entity) => entity, + EntityMetadata::Phantom(entity) => entity, + EntityMetadata::Pig(entity) => entity, + EntityMetadata::Piglin(entity) => entity, + EntityMetadata::PiglinBrute(entity) => entity, + EntityMetadata::Pillager(entity) => entity, + EntityMetadata::Player(entity) => entity, + EntityMetadata::PolarBear(entity) => entity, + EntityMetadata::Potion(entity) => entity, + EntityMetadata::Pufferfish(entity) => entity, + EntityMetadata::Rabbit(entity) => entity, + EntityMetadata::Ravager(entity) => entity, + EntityMetadata::Salmon(entity) => entity, + EntityMetadata::Sheep(entity) => entity, + EntityMetadata::Shulker(entity) => entity, + EntityMetadata::ShulkerBullet(entity) => entity, + EntityMetadata::Silverfish(entity) => entity, + EntityMetadata::Skeleton(entity) => entity, + EntityMetadata::SkeletonHorse(entity) => entity, + EntityMetadata::Slime(entity) => entity, + EntityMetadata::SmallFireball(entity) => entity, + EntityMetadata::SnowGolem(entity) => entity, + EntityMetadata::Snowball(entity) => entity, + EntityMetadata::SpawnerMinecart(entity) => entity, + EntityMetadata::SpectralArrow(entity) => entity, + EntityMetadata::Spider(entity) => entity, + EntityMetadata::Squid(entity) => entity, + EntityMetadata::Stray(entity) => entity, + EntityMetadata::Strider(entity) => entity, + EntityMetadata::Tadpole(entity) => entity, + EntityMetadata::Tnt(entity) => entity, + EntityMetadata::TntMinecart(entity) => entity, + EntityMetadata::TraderLlama(entity) => entity, + EntityMetadata::Trident(entity) => entity, + EntityMetadata::TropicalFish(entity) => entity, + EntityMetadata::Turtle(entity) => entity, + EntityMetadata::Vex(entity) => entity, + EntityMetadata::Villager(entity) => entity, + EntityMetadata::Vindicator(entity) => entity, + EntityMetadata::WanderingTrader(entity) => entity, + EntityMetadata::Warden(entity) => entity, + EntityMetadata::Witch(entity) => entity, + EntityMetadata::Wither(entity) => entity, + EntityMetadata::WitherSkeleton(entity) => entity, + EntityMetadata::WitherSkull(entity) => entity, + EntityMetadata::Wolf(entity) => entity, + EntityMetadata::Zoglin(entity) => entity, + EntityMetadata::Zombie(entity) => entity, + EntityMetadata::ZombieHorse(entity) => entity, + EntityMetadata::ZombieVillager(entity) => entity, + EntityMetadata::ZombifiedPiglin(entity) => entity, + } + } +} +impl DerefMut for EntityMetadata { + fn deref_mut(&mut self) -> &mut Self::Target { + match self { + EntityMetadata::Allay(entity) => entity, + EntityMetadata::AreaEffectCloud(entity) => entity, + EntityMetadata::ArmorStand(entity) => entity, + EntityMetadata::Arrow(entity) => entity, + EntityMetadata::Axolotl(entity) => entity, + EntityMetadata::Bat(entity) => entity, + EntityMetadata::Bee(entity) => entity, + EntityMetadata::Blaze(entity) => entity, + EntityMetadata::Boat(entity) => entity, + EntityMetadata::Cat(entity) => entity, + EntityMetadata::CaveSpider(entity) => entity, + EntityMetadata::ChestBoat(entity) => entity, + EntityMetadata::ChestMinecart(entity) => entity, + EntityMetadata::Chicken(entity) => entity, + EntityMetadata::Cod(entity) => entity, + EntityMetadata::CommandBlockMinecart(entity) => entity, + EntityMetadata::Cow(entity) => entity, + EntityMetadata::Creeper(entity) => entity, + EntityMetadata::Dolphin(entity) => entity, + EntityMetadata::Donkey(entity) => entity, + EntityMetadata::DragonFireball(entity) => entity, + EntityMetadata::Drowned(entity) => entity, + EntityMetadata::Egg(entity) => entity, + EntityMetadata::ElderGuardian(entity) => entity, + EntityMetadata::EndCrystal(entity) => entity, + EntityMetadata::EnderDragon(entity) => entity, + EntityMetadata::EnderPearl(entity) => entity, + EntityMetadata::Enderman(entity) => entity, + EntityMetadata::Endermite(entity) => entity, + EntityMetadata::Evoker(entity) => entity, + EntityMetadata::EvokerFangs(entity) => entity, + EntityMetadata::ExperienceBottle(entity) => entity, + EntityMetadata::ExperienceOrb(entity) => entity, + EntityMetadata::EyeOfEnder(entity) => entity, + EntityMetadata::FallingBlock(entity) => entity, + EntityMetadata::Fireball(entity) => entity, + EntityMetadata::FireworkRocket(entity) => entity, + EntityMetadata::FishingBobber(entity) => entity, + EntityMetadata::Fox(entity) => entity, + EntityMetadata::Frog(entity) => entity, + EntityMetadata::FurnaceMinecart(entity) => entity, + EntityMetadata::Ghast(entity) => entity, + EntityMetadata::Giant(entity) => entity, + EntityMetadata::GlowItemFrame(entity) => entity, + EntityMetadata::GlowSquid(entity) => entity, + EntityMetadata::Goat(entity) => entity, + EntityMetadata::Guardian(entity) => entity, + EntityMetadata::Hoglin(entity) => entity, + EntityMetadata::HopperMinecart(entity) => entity, + EntityMetadata::Horse(entity) => entity, + EntityMetadata::Husk(entity) => entity, + EntityMetadata::Illusioner(entity) => entity, + EntityMetadata::IronGolem(entity) => entity, + EntityMetadata::Item(entity) => entity, + EntityMetadata::ItemFrame(entity) => entity, + EntityMetadata::LeashKnot(entity) => entity, + EntityMetadata::LightningBolt(entity) => entity, + EntityMetadata::Llama(entity) => entity, + EntityMetadata::LlamaSpit(entity) => entity, + EntityMetadata::MagmaCube(entity) => entity, + EntityMetadata::Marker(entity) => entity, + EntityMetadata::Minecart(entity) => entity, + EntityMetadata::Mooshroom(entity) => entity, + EntityMetadata::Mule(entity) => entity, + EntityMetadata::Ocelot(entity) => entity, + EntityMetadata::Painting(entity) => entity, + EntityMetadata::Panda(entity) => entity, + EntityMetadata::Parrot(entity) => entity, + EntityMetadata::Phantom(entity) => entity, + EntityMetadata::Pig(entity) => entity, + EntityMetadata::Piglin(entity) => entity, + EntityMetadata::PiglinBrute(entity) => entity, + EntityMetadata::Pillager(entity) => entity, + EntityMetadata::Player(entity) => entity, + EntityMetadata::PolarBear(entity) => entity, + EntityMetadata::Potion(entity) => entity, + EntityMetadata::Pufferfish(entity) => entity, + EntityMetadata::Rabbit(entity) => entity, + EntityMetadata::Ravager(entity) => entity, + EntityMetadata::Salmon(entity) => entity, + EntityMetadata::Sheep(entity) => entity, + EntityMetadata::Shulker(entity) => entity, + EntityMetadata::ShulkerBullet(entity) => entity, + EntityMetadata::Silverfish(entity) => entity, + EntityMetadata::Skeleton(entity) => entity, + EntityMetadata::SkeletonHorse(entity) => entity, + EntityMetadata::Slime(entity) => entity, + EntityMetadata::SmallFireball(entity) => entity, + EntityMetadata::SnowGolem(entity) => entity, + EntityMetadata::Snowball(entity) => entity, + EntityMetadata::SpawnerMinecart(entity) => entity, + EntityMetadata::SpectralArrow(entity) => entity, + EntityMetadata::Spider(entity) => entity, + EntityMetadata::Squid(entity) => entity, + EntityMetadata::Stray(entity) => entity, + EntityMetadata::Strider(entity) => entity, + EntityMetadata::Tadpole(entity) => entity, + EntityMetadata::Tnt(entity) => entity, + EntityMetadata::TntMinecart(entity) => entity, + EntityMetadata::TraderLlama(entity) => entity, + EntityMetadata::Trident(entity) => entity, + EntityMetadata::TropicalFish(entity) => entity, + EntityMetadata::Turtle(entity) => entity, + EntityMetadata::Vex(entity) => entity, + EntityMetadata::Villager(entity) => entity, + EntityMetadata::Vindicator(entity) => entity, + EntityMetadata::WanderingTrader(entity) => entity, + EntityMetadata::Warden(entity) => entity, + EntityMetadata::Witch(entity) => entity, + EntityMetadata::Wither(entity) => entity, + EntityMetadata::WitherSkeleton(entity) => entity, + EntityMetadata::WitherSkull(entity) => entity, + EntityMetadata::Wolf(entity) => entity, + EntityMetadata::Zoglin(entity) => entity, + EntityMetadata::Zombie(entity) => entity, + EntityMetadata::ZombieHorse(entity) => entity, + EntityMetadata::ZombieVillager(entity) => entity, + EntityMetadata::ZombifiedPiglin(entity) => entity, + } + } +} diff --git a/azalea-world/src/entity/mod.rs b/azalea-world/src/entity/mod.rs index e537e7e0..63147ced 100644 --- a/azalea-world/src/entity/mod.rs +++ b/azalea-world/src/entity/mod.rs @@ -1,108 +1,44 @@ +pub mod attributes; mod data; mod dimensions; pub mod metadata; +use self::attributes::{AttributeInstance, AttributeModifiers}; pub use self::metadata::EntityMetadata; use crate::Dimension; use azalea_block::BlockState; use azalea_core::{BlockPos, Vec3, AABB}; pub use data::*; pub use dimensions::*; +use std::marker::PhantomData; use std::ops::{Deref, DerefMut}; use std::ptr::NonNull; use uuid::Uuid; +/// A reference to an entity in a dimension. #[derive(Debug)] -pub struct EntityRef<'d> { +pub struct Entity<'d, D = &'d mut Dimension> { /// The dimension this entity is in. - pub dimension: &'d Dimension, + pub dimension: D, /// The incrementing numerical id of the entity. pub id: u32, - pub data: &'d EntityData, + pub data: NonNull, + _marker: PhantomData<&'d ()>, } -impl<'d> EntityRef<'d> { - pub fn new(dimension: &'d Dimension, id: u32, data: &'d EntityData) -> Self { +impl<'d, D: Deref> Entity<'d, D> { + pub fn new(dimension: D, id: u32, data: NonNull) -> Self { // TODO: have this be based on the entity type Self { dimension, id, data, + _marker: PhantomData, } } } -impl<'d> EntityRef<'d> { - #[inline] - pub fn pos(&self) -> &Vec3 { - &self.pos - } - - pub fn make_bounding_box(&self) -> AABB { - self.dimensions.make_bounding_box(self.pos()) - } - - /// Get the position of the block below the entity, but a little lower. - pub fn on_pos_legacy(&self) -> BlockPos { - self.on_pos(0.2) - } - - // int x = Mth.floor(this.position.x); - // int y = Mth.floor(this.position.y - (double)var1); - // int z = Mth.floor(this.position.z); - // BlockPos var5 = new BlockPos(x, y, z); - // if (this.level.getBlockState(var5).isAir()) { - // BlockPos var6 = var5.below(); - // BlockState var7 = this.level.getBlockState(var6); - // if (var7.is(BlockTags.FENCES) || var7.is(BlockTags.WALLS) || var7.getBlock() instanceof FenceGateBlock) { - // return var6; - // } - // } - // return var5; - pub fn on_pos(&self, offset: f32) -> BlockPos { - let x = self.pos().x.floor() as i32; - let y = (self.pos().y - offset as f64).floor() as i32; - let z = self.pos().z.floor() as i32; - let pos = BlockPos { x, y, z }; - - // TODO: check if block below is a fence, wall, or fence gate - let block_pos = pos.below(); - let block_state = self.dimension.get_block_state(&block_pos); - if block_state == Some(BlockState::Air) { - let block_pos_below = block_pos.below(); - let block_state_below = self.dimension.get_block_state(&block_pos_below); - if let Some(_block_state_below) = block_state_below { - // if block_state_below.is_fence() - // || block_state_below.is_wall() - // || block_state_below.is_fence_gate() - // { - // return block_pos_below; - // } - } - } - - pos - } -} - -#[derive(Debug)] -pub struct EntityMut<'d> { - /// The dimension this entity is in. - pub dimension: &'d mut Dimension, - /// The incrementing numerical id of the entity. - pub id: u32, - pub data: NonNull, -} - -impl<'d> EntityMut<'d> { - pub fn new(dimension: &'d mut Dimension, id: u32, data: NonNull) -> Self { - Self { - dimension, - id, - data, - } - } - +impl<'d, D: DerefMut> Entity<'d, D> { /// Sets the position of the entity. This doesn't update the cache in /// azalea-world, and should only be used within azalea-world! /// @@ -158,7 +94,7 @@ impl<'d> EntityMut<'d> { } } -impl<'d> EntityMut<'d> { +impl<'d, D: Deref> Entity<'d, D> { #[inline] pub fn pos(&self) -> &Vec3 { &self.pos @@ -192,10 +128,10 @@ impl<'d> EntityMut<'d> { let pos = BlockPos { x, y, z }; // TODO: check if block below is a fence, wall, or fence gate - let block_pos = pos.below(); + let block_pos = pos.down(1); let block_state = self.dimension.get_block_state(&block_pos); if block_state == Some(BlockState::Air) { - let block_pos_below = block_pos.below(); + let block_pos_below = block_pos.down(1); let block_state_below = self.dimension.get_block_state(&block_pos_below); if let Some(_block_state_below) = block_state_below { // if block_state_below.is_fence() @@ -211,36 +147,33 @@ impl<'d> EntityMut<'d> { } } -impl<'d> From> for EntityRef<'d> { - fn from(entity: EntityMut<'d>) -> EntityRef<'d> { - let data = unsafe { entity.data.as_ref() }; - EntityRef { - dimension: entity.dimension, - id: entity.id, - data, - } - } -} +// impl< +// 'd, +// D: DerefMut + Deref, +// D2: Deref, +// > From> for Entity<'d, D2> +// { +// fn from(entity: Entity<'d, D>) -> Entity<'d, D> { +// Entity { +// dimension: entity.dimension, +// id: entity.id, +// data: entity.data, +// _marker: PhantomData, +// } +// } +// } -impl Deref for EntityMut<'_> { - type Target = EntityData; - - fn deref(&self) -> &Self::Target { - unsafe { self.data.as_ref() } - } -} - -impl DerefMut for EntityMut<'_> { +impl> DerefMut for Entity<'_, D> { fn deref_mut(&mut self) -> &mut Self::Target { unsafe { self.data.as_mut() } } } -impl Deref for EntityRef<'_> { +impl> Deref for Entity<'_, D> { type Target = EntityData; fn deref(&self) -> &Self::Target { - self.data + unsafe { self.data.as_ref() } } } @@ -279,8 +212,13 @@ pub struct EntityData { /// (equivalent to the space key being held down in vanilla). pub jumping: bool, + pub has_impulse: bool, + /// Stores some extra data about the entity, including the entity type. pub metadata: EntityMetadata, + + /// The attributes and modifiers that the entity has (for example, speed). + pub attributes: AttributeModifiers, } impl EntityData { @@ -313,20 +251,33 @@ impl EntityData { bounding_box: dimensions.make_bounding_box(&pos), dimensions, + has_impulse: false, + jumping: false, metadata, + + attributes: AttributeModifiers { + // TODO: do the correct defaults for everything, some entities have different defaults + speed: AttributeInstance::new(0.1), + }, } } + /// Get the position of the entity in the dimension. #[inline] pub fn pos(&self) -> &Vec3 { &self.pos } - pub(crate) unsafe fn as_ptr(&mut self) -> NonNull { + pub unsafe fn as_ptr(&mut self) -> NonNull { NonNull::new_unchecked(self as *mut EntityData) } + + pub unsafe fn as_const_ptr(&self) -> NonNull { + // this is cursed + NonNull::new_unchecked(self as *const EntityData as *mut EntityData) + } } #[cfg(test)] @@ -345,8 +296,8 @@ mod tests { EntityMetadata::Player(metadata::Player::default()), ), ); - let entity: EntityMut = dim.entity_mut(0).unwrap(); - let entity_ref: EntityRef = entity.into(); + let entity: Entity = dim.entity_mut(0).unwrap(); + let entity_ref = Entity::from(entity); assert_eq!(entity_ref.uuid, uuid); } } diff --git a/azalea-world/src/entity_storage.rs b/azalea-world/src/entity_storage.rs old mode 100644 new mode 100755 diff --git a/azalea-world/src/lib.rs b/azalea-world/src/lib.rs old mode 100644 new mode 100755 index 5fbb7b4d..30e09fe9 --- a/azalea-world/src/lib.rs +++ b/azalea-world/src/lib.rs @@ -11,23 +11,23 @@ use azalea_buf::BufReadError; use azalea_core::{BlockPos, ChunkPos, PositionDelta8, Vec3}; pub use bit_storage::BitStorage; pub use chunk_storage::{Chunk, ChunkStorage}; -use entity::{EntityData, EntityMut, EntityRef}; +use entity::{Entity, EntityData}; pub use entity_storage::EntityStorage; +use parking_lot::Mutex; use std::{ io::Cursor, ops::{Index, IndexMut}, - sync::{Arc, Mutex}, + sync::Arc, }; use thiserror::Error; use uuid::Uuid; /// A dimension is a collection of chunks and entities. /// Minecraft calls these "Levels", Fabric calls them "Worlds", Minestom calls them "Instances". -/// Yeah. #[derive(Debug, Default)] pub struct Dimension { - chunk_storage: ChunkStorage, - entity_storage: EntityStorage, + pub chunk_storage: ChunkStorage, + pub entity_storage: EntityStorage, } #[derive(Error, Debug)] @@ -127,16 +127,16 @@ impl Dimension { self.entity_storage.get_mut_by_id(id) } - pub fn entity(&self, id: u32) -> Option { + pub fn entity(&self, id: u32) -> Option> { let entity_data = self.entity_storage.get_by_id(id)?; - Some(EntityRef::new(self, id, entity_data)) + let entity_ptr = unsafe { entity_data.as_const_ptr() }; + Some(Entity::new(self, id, entity_ptr)) } - pub fn entity_mut(&mut self, id: u32) -> Option { + pub fn entity_mut(&mut self, id: u32) -> Option> { let entity_data = self.entity_storage.get_mut_by_id(id)?; - let entity_ptr = unsafe { entity_data.as_ptr() }; - Some(EntityMut::new(self, id, entity_ptr)) + Some(Entity::new(self, id, entity_ptr)) } pub fn entity_by_uuid(&self, uuid: &Uuid) -> Option<&EntityData> { diff --git a/azalea-world/src/palette.rs b/azalea-world/src/palette.rs old mode 100644 new mode 100755 diff --git a/azalea/Cargo.toml b/azalea/Cargo.toml old mode 100644 new mode 100755 index 2719b43c..846abad5 --- a/azalea/Cargo.toml +++ b/azalea/Cargo.toml @@ -11,9 +11,15 @@ version = "0.3.0" [dependencies] anyhow = "^1.0.65" async-trait = "^0.1.57" +azalea-block = { version = "0.3.0", path = "../azalea-block" } azalea-client = {version = "0.3.0", path = "../azalea-client"} +azalea-core = {version = "0.3.0", path = "../azalea-core"} +azalea-physics = { version = "0.3.0", path = "../azalea-physics" } azalea-protocol = {version = "0.3.0", path = "../azalea-protocol"} -parking_lot = "^0.12.1" +azalea-world = { version = "0.3.0", path = "../azalea-world" } +num-traits = "0.2.15" +parking_lot = {version = "^0.12.1", features = ["deadlock_detection"]} +priority-queue = "1.3.0" thiserror = "^1.0.37" tokio = "^1.21.2" diff --git a/azalea/README.md b/azalea/README.md old mode 100644 new mode 100755 diff --git a/azalea/examples/craft_dig_straight_down.rs b/azalea/examples/craft_dig_straight_down.rs old mode 100644 new mode 100755 index 82960a9c..d6c0ed1c --- a/azalea/examples/craft_dig_straight_down.rs +++ b/azalea/examples/craft_dig_straight_down.rs @@ -17,7 +17,7 @@ async fn main() { account, address: "localhost", state: State::default(), - plugins: vec![], + plugins: plugins![], handle, }) .await diff --git a/azalea/examples/echo.rs b/azalea/examples/echo.rs old mode 100644 new mode 100755 index 8c11d6e7..51896e53 --- a/azalea/examples/echo.rs +++ b/azalea/examples/echo.rs @@ -11,7 +11,7 @@ async fn main() { account, address: "localhost", state: State::default(), - plugins: vec![], + plugins: plugins![], handle, }) .await diff --git a/azalea/examples/mine_a_chunk.rs b/azalea/examples/mine_a_chunk.rs old mode 100644 new mode 100755 index 3bb712fa..2e30b2c5 --- a/azalea/examples/mine_a_chunk.rs +++ b/azalea/examples/mine_a_chunk.rs @@ -1,4 +1,4 @@ -use azalea::{pathfinder, Account, Accounts, Client, Event, Swarm}; +use azalea::{Account, Accounts, Client, Event, Swarm}; use parking_lot::Mutex; use std::sync::Arc; @@ -17,8 +17,8 @@ async fn main() { swarm_state: State::default(), state: State::default(), - swarm_plugins: vec![Arc::new(pathfinder::Plugin::default())], - plugins: vec![], + swarm_plugins: plugins![azalea_pathfinder::Plugin::default()], + plugins: plugins![], handle: Box::new(handle), swarm_handle: Box::new(swarm_handle), diff --git a/azalea/examples/potatobot/README.md b/azalea/examples/potatobot/README.md old mode 100644 new mode 100755 diff --git a/azalea/examples/potatobot/autoeat.rs b/azalea/examples/potatobot/autoeat.rs old mode 100644 new mode 100755 index 8042e2a2..0f0ccc6d --- a/azalea/examples/potatobot/autoeat.rs +++ b/azalea/examples/potatobot/autoeat.rs @@ -2,7 +2,8 @@ use async_trait::async_trait; use azalea::{Client, Event}; -use std::sync::{Arc, Mutex}; +use parking_lot::Mutex; +use std::sync::Arc; #[derive(Default, Clone)] pub struct Plugin { diff --git a/azalea/examples/potatobot/main.rs b/azalea/examples/potatobot/main.rs old mode 100644 new mode 100755 index 54c84570..66ddfcc0 --- a/azalea/examples/potatobot/main.rs +++ b/azalea/examples/potatobot/main.rs @@ -1,5 +1,4 @@ mod autoeat; - use azalea::prelude::*; use azalea::{pathfinder, BlockPos, ItemKind, Vec3}; @@ -16,10 +15,7 @@ async fn main() { account, address: "localhost", state: State::default(), - plugins: vec![ - Box::new(autoeat::Plugin::default()), - Box::new(pathfinder::Plugin::default()), - ], + plugins: plugins![autoeat::Plugin::default(), pathfinder::Plugin::default(),], handle, }) .await diff --git a/azalea/examples/pvp.rs b/azalea/examples/pvp.rs old mode 100644 new mode 100755 index ec2a08f0..435c335c --- a/azalea/examples/pvp.rs +++ b/azalea/examples/pvp.rs @@ -15,8 +15,8 @@ async fn main() { swarm_state: State::default(), state: State::default(), - swarm_plugins: vec![Box::new(pathfinder::Plugin::default())], - plugins: vec![], + swarm_plugins: plugins![pathfinder::Plugin::default()], + plugins: plugins![], handle: Box::new(handle), swarm_handle: Box::new(swarm_handle), diff --git a/azalea/src/bot.rs b/azalea/src/bot.rs old mode 100644 new mode 100755 index 566ab1e7..961f093d --- a/azalea/src/bot.rs +++ b/azalea/src/bot.rs @@ -1,7 +1,8 @@ use crate::{Client, Event}; use async_trait::async_trait; +use azalea_core::Vec3; use parking_lot::Mutex; -use std::sync::Arc; +use std::{f64::consts::PI, sync::Arc}; #[derive(Default, Clone)] pub struct Plugin { @@ -14,20 +15,22 @@ pub struct State { } pub trait BotTrait { - fn jump(&self); + fn jump(&mut self); + fn look_at(&mut self, pos: &Vec3); } impl BotTrait for azalea_client::Client { /// Queue a jump for the next tick. - fn jump(&self) { - let player_lock = self.player.lock(); - let mut dimension_lock = self.dimension.lock(); + fn jump(&mut self) { + self.set_jumping(true); + let state = self.plugins.get::().unwrap().state.clone(); + *state.jumping_once.lock() = true; + } - let mut player_entity = player_lock - .entity_mut(&mut dimension_lock) - .expect("Player must exist"); - - player_entity.jumping = true; + /// Turn the bot's head to look at the coordinate in the world. + fn look_at(&mut self, pos: &Vec3) { + let (y_rot, x_rot) = direction_looking_at(self.entity().pos(), pos); + self.set_rotation(y_rot, x_rot); } } @@ -38,10 +41,18 @@ impl crate::Plugin for Plugin { if *self.state.jumping_once.lock() { if bot.jumping() { *self.state.jumping_once.lock() = false; - } else { - bot.set_jumping(true); + bot.set_jumping(false); } } } } } + +fn direction_looking_at(current: &Vec3, target: &Vec3) -> (f32, f32) { + // borrowed from mineflayer's Bot.lookAt because i didn't want to do math + let delta = target - current; + let y_rot = (PI - f64::atan2(-delta.x, -delta.z)) * (180.0 / PI); + let ground_distance = f64::sqrt(delta.x * delta.x + delta.z * delta.z); + let x_rot = f64::atan2(delta.y, ground_distance) * -(180.0 / PI); + (y_rot as f32, x_rot as f32) +} diff --git a/azalea/src/lib.rs b/azalea/src/lib.rs old mode 100644 new mode 100755 index 83ad8d36..89754409 --- a/azalea/src/lib.rs +++ b/azalea/src/lib.rs @@ -51,7 +51,7 @@ //! account, //! address: "localhost", //! state: State::default(), -//! plugins: vec![], +//! plugins: plugins![], //! handle, //! }) //! .await @@ -76,39 +76,15 @@ //! [`azalea_client`]: https://crates.io/crates/azalea-client mod bot; +pub mod pathfinder; pub mod prelude; -use async_trait::async_trait; pub use azalea_client::*; +pub use azalea_core::{BlockPos, Vec3}; use azalea_protocol::ServerAddress; -use std::future::Future; +use std::{future::Future, sync::Arc}; use thiserror::Error; -/// Plugins can keep their own personal state, listen to events, and add new functions to Client. -#[async_trait] -pub trait Plugin: Send + Sync + PluginClone + 'static { - async fn handle(self: Box, event: Event, bot: Client); -} - -/// An internal trait that allows Plugin to be cloned. -#[doc(hidden)] -pub trait PluginClone { - fn clone_box(&self) -> Box; -} -impl PluginClone for T -where - T: 'static + Plugin + Clone, -{ - fn clone_box(&self) -> Box { - Box::new(self.clone()) - } -} -impl Clone for Box { - fn clone(&self) -> Self { - self.clone_box() - } -} - pub type HandleFn = fn(Client, Event, S) -> Fut; /// The options that are passed to [`azalea::start`]. @@ -127,9 +103,14 @@ where pub address: A, /// The account that's going to join the server. pub account: Account, - /// A list of plugins that are going to be used. Plugins are external - /// crates that add extra functionality to Azalea. - pub plugins: Vec>, + /// The plugins that are going to be used. Plugins are external crates that + /// add extra functionality to Azalea. You should use the [`plugins`] macro + /// for this field. + /// + /// ```rust,no_run + /// plugins![azalea_pathfinder::Plugin::default()] + /// ``` + pub plugins: Plugins, /// A struct that contains the data that you want your bot to remember /// across events. /// @@ -177,7 +158,7 @@ pub enum Error { /// account, /// address: "localhost", /// state: State::default(), -/// plugins: vec![Box::new(autoeat::Plugin::default())], +/// plugins: plugins![azalea_pathfinder::Plugin::default()], /// handle, /// }).await; /// ``` @@ -193,24 +174,53 @@ pub async fn start< Err(_) => return Err(Error::InvalidAddress), }; - let (bot, mut rx) = Client::join(&options.account, address).await?; + let (mut bot, mut rx) = Client::join(&options.account, address).await?; + + let mut plugins = options.plugins; + plugins.add(bot::Plugin::default()); + plugins.add(pathfinder::Plugin::default()); + bot.plugins = Arc::new(plugins); let state = options.state; - let bot_plugin = bot::Plugin::default(); while let Some(event) = rx.recv().await { - for plugin in &options.plugins { - let plugin = plugin.clone(); + let cloned_plugins = (*bot.plugins).clone(); + for plugin in cloned_plugins.into_iter() { tokio::spawn(plugin.handle(event.clone(), bot.clone())); } tokio::spawn(bot::Plugin::handle( - Box::new(bot_plugin.clone()), + Box::new(bot.plugins.get::().unwrap().clone()), event.clone(), bot.clone(), )); + tokio::spawn(pathfinder::Plugin::handle( + Box::new(bot.plugins.get::().unwrap().clone()), + event.clone(), + bot.clone(), + )); + tokio::spawn((options.handle)(bot.clone(), event.clone(), state.clone())); } Ok(()) } + +/// A helper macro that generates a [`Plugins`] struct from a list of objects +/// that implement [`Plugin`]. +/// +/// ```rust,no_run +/// plugins![azalea_pathfinder::Plugin::default()]; +/// ``` +#[macro_export] +macro_rules! plugins { + ($($plugin:expr),*) => { + { + let mut plugins = azalea::Plugins::new(); + $( + plugins.add($plugin); + )* + plugins + } + }; +} diff --git a/azalea/src/pathfinder/mod.rs b/azalea/src/pathfinder/mod.rs new file mode 100644 index 00000000..d62b3e05 --- /dev/null +++ b/azalea/src/pathfinder/mod.rs @@ -0,0 +1,208 @@ +mod moves; +mod mtdstarlite; + +use crate::{prelude::*, SprintDirection, WalkDirection}; +use crate::{Client, Event}; +use async_trait::async_trait; +use azalea_core::{BlockPos, CardinalDirection}; +use azalea_world::entity::EntityData; +use mtdstarlite::Edge; +pub use mtdstarlite::MTDStarLite; +use parking_lot::Mutex; +use std::collections::VecDeque; +use std::sync::Arc; + +#[derive(Default, Clone)] +pub struct Plugin { + pub state: State, +} + +#[derive(Default, Clone)] +pub struct State { + // pathfinder: Option>, + pub path: Arc>>, +} + +#[async_trait] +impl crate::Plugin for Plugin { + async fn handle(self: Box, event: Event, mut bot: Client) { + if let Event::Tick = event { + let mut path = self.state.path.lock(); + + if !path.is_empty() { + tick_execute_path(&mut bot, &mut path); + } + } + } +} + +pub trait Trait { + fn goto(&self, goal: impl Goal); +} + +impl Trait for azalea_client::Client { + fn goto(&self, goal: impl Goal) { + let start = Node { + pos: BlockPos::from(self.entity().pos()), + vertical_vel: VerticalVel::None, + }; + let end = goal.goal_node(); + println!("start: {:?}, end: {:?}", start, end); + + let possible_moves: Vec<&dyn moves::Move> = vec![ + &moves::ForwardMove(CardinalDirection::North), + &moves::ForwardMove(CardinalDirection::East), + &moves::ForwardMove(CardinalDirection::South), + &moves::ForwardMove(CardinalDirection::West), + // + &moves::AscendMove(CardinalDirection::North), + &moves::AscendMove(CardinalDirection::East), + &moves::AscendMove(CardinalDirection::South), + &moves::AscendMove(CardinalDirection::West), + // + &moves::DescendMove(CardinalDirection::North), + &moves::DescendMove(CardinalDirection::East), + &moves::DescendMove(CardinalDirection::South), + &moves::DescendMove(CardinalDirection::West), + // + &moves::DiagonalMove(CardinalDirection::North), + &moves::DiagonalMove(CardinalDirection::East), + &moves::DiagonalMove(CardinalDirection::South), + &moves::DiagonalMove(CardinalDirection::West), + ]; + + let successors = |node: &Node| { + let mut edges = Vec::new(); + + let dimension = self.dimension.read(); + for possible_move in possible_moves.iter() { + edges.push(Edge { + target: possible_move.next_node(&node), + cost: possible_move.cost(&dimension, node), + }); + } + edges + }; + + let mut pf = MTDStarLite::new( + start, + end, + |n| goal.heuristic(n), + successors, + successors, + |n| goal.success(n), + ); + + let start = std::time::Instant::now(); + let p = pf.find_path(); + let end = std::time::Instant::now(); + println!("path: {:?}", p); + println!("time: {:?}", end - start); + + let state = self + .plugins + .get::() + .expect("Pathfinder plugin not installed!") + .state + .clone(); + // convert the Option> to a VecDeque + *state.path.lock() = p.expect("no path").into_iter().collect(); + } +} + +fn tick_execute_path(bot: &mut Client, path: &mut VecDeque) { + let target = if let Some(target) = path.front() { + target + } else { + return; + }; + let center = target.pos.center(); + // println!("going to {center:?} (at {pos:?})", pos = bot.entity().pos()); + bot.look_at(¢er); + bot.sprint(SprintDirection::Forward); + // check if we should jump + if target.pos.y > bot.entity().pos().y.floor() as i32 { + bot.jump(); + } + + if target.is_reached(&bot.entity()) { + println!("ok target {target:?} reached"); + path.pop_front(); + if path.is_empty() { + bot.walk(WalkDirection::None); + } + // tick again, maybe we already reached the next node! + tick_execute_path(bot, path); + } +} + +/// Information about our vertical velocity +#[derive(Eq, PartialEq, Hash, Clone, Copy, Debug)] +pub enum VerticalVel { + None, + /// No vertical velocity, but we're not on the ground + NoneMidair, + // less than 3 blocks (no fall damage) + FallingLittle, +} + +#[derive(Eq, PartialEq, Hash, Clone, Copy, Debug)] +pub struct Node { + pub pos: BlockPos, + pub vertical_vel: VerticalVel, +} + +pub trait Goal { + fn heuristic(&self, n: &Node) -> f32; + fn success(&self, n: &Node) -> bool; + // TODO: this should be removed and mtdstarlite should stop depending on + // being given a goal node + fn goal_node(&self) -> Node; +} + +impl Node { + /// Returns whether the entity is at the node and should start going to the + /// next node. + pub fn is_reached(&self, entity: &EntityData) -> bool { + println!( + "entity.delta.y: {} {:?}=={:?}, self.vertical_vel={:?}", + entity.delta.y, + BlockPos::from(entity.pos()), + self.pos, + self.vertical_vel + ); + BlockPos::from(entity.pos()) == self.pos + && match self.vertical_vel { + VerticalVel::NoneMidair => entity.delta.y > -0.1 && entity.delta.y < 0.1, + VerticalVel::None => entity.on_ground, + VerticalVel::FallingLittle => entity.delta.y < -0.1, + } + } +} + +pub struct BlockPosGoal { + pub pos: BlockPos, +} +impl Goal for BlockPosGoal { + fn heuristic(&self, n: &Node) -> f32 { + let dx = (self.pos.x - n.pos.x) as f32; + let dy = (self.pos.y - n.pos.y) as f32; + let dz = (self.pos.z - n.pos.z) as f32; + dx * dx + dy * dy + dz * dz + } + fn success(&self, n: &Node) -> bool { + n.pos == self.pos + } + fn goal_node(&self) -> Node { + Node { + pos: self.pos, + vertical_vel: VerticalVel::None, + } + } +} + +impl From for BlockPosGoal { + fn from(pos: BlockPos) -> Self { + Self { pos } + } +} diff --git a/azalea/src/pathfinder/moves.rs b/azalea/src/pathfinder/moves.rs new file mode 100644 index 00000000..ed98b70d --- /dev/null +++ b/azalea/src/pathfinder/moves.rs @@ -0,0 +1,191 @@ +use super::{Node, VerticalVel}; +use azalea_core::{BlockPos, CardinalDirection}; +use azalea_physics::collision::{self, BlockWithShape}; +use azalea_world::Dimension; + +/// whether this block is passable +fn is_block_passable(pos: &BlockPos, dim: &Dimension) -> bool { + if let Some(block) = dim.get_block_state(pos) { + block.shape() == &collision::empty_shape() + } else { + false + } +} + +/// whether this block has a solid hitbox (i.e. we can stand on it) +fn is_block_solid(pos: &BlockPos, dim: &Dimension) -> bool { + if let Some(block) = dim.get_block_state(pos) { + block.shape() == &collision::block_shape() + } else { + false + } +} + +/// Whether this block and the block above are passable +fn is_passable(pos: &BlockPos, dim: &Dimension) -> bool { + is_block_passable(pos, dim) && is_block_passable(&pos.up(1), dim) +} + +/// Whether we can stand in this position. Checks if the block below is solid, +/// and that the two blocks above that are passable. +fn is_standable(pos: &BlockPos, dim: &Dimension) -> bool { + is_block_solid(&pos.down(1), dim) && is_passable(&pos, dim) +} + +const JUMP_COST: f32 = 0.5; +const WALK_ONE_BLOCK_COST: f32 = 1.0; + +pub trait Move { + fn cost(&self, dim: &Dimension, node: &Node) -> f32; + /// Returns by how much the entity's position should be changed when this move is executed. + fn offset(&self) -> BlockPos; + fn next_node(&self, node: &Node) -> Node { + Node { + pos: node.pos + self.offset(), + vertical_vel: VerticalVel::None, + } + } +} + +pub struct ForwardMove(pub CardinalDirection); +impl Move for ForwardMove { + fn cost(&self, dim: &Dimension, node: &Node) -> f32 { + if is_standable(&(node.pos + self.offset()), dim) && node.vertical_vel == VerticalVel::None + { + WALK_ONE_BLOCK_COST + } else { + f32::INFINITY + } + } + fn offset(&self) -> BlockPos { + BlockPos::new(self.0.x(), 0, self.0.z()) + } +} + +pub struct AscendMove(pub CardinalDirection); +impl Move for AscendMove { + fn cost(&self, dim: &Dimension, node: &Node) -> f32 { + if node.vertical_vel == VerticalVel::None + && is_block_passable(&node.pos.up(2), dim) + && is_standable(&(node.pos + self.offset()), dim) + { + WALK_ONE_BLOCK_COST + JUMP_COST + } else { + f32::INFINITY + } + } + fn offset(&self) -> BlockPos { + BlockPos::new(self.0.x(), 1, self.0.z()) + } + fn next_node(&self, node: &Node) -> Node { + Node { + pos: node.pos + self.offset(), + vertical_vel: VerticalVel::None, + } + } +} +pub struct DescendMove(pub CardinalDirection); +impl Move for DescendMove { + fn cost(&self, dim: &Dimension, node: &Node) -> f32 { + // check whether 3 blocks vertically forward are passable + if node.vertical_vel == VerticalVel::None + && is_standable(&(node.pos + self.offset()), dim) + && is_block_passable(&(node.pos + self.offset().up(2)), dim) + { + WALK_ONE_BLOCK_COST + } else { + f32::INFINITY + } + } + fn offset(&self) -> BlockPos { + BlockPos::new(self.0.x(), -1, self.0.z()) + } + fn next_node(&self, node: &Node) -> Node { + Node { + pos: node.pos + self.offset(), + vertical_vel: VerticalVel::None, + } + } +} +pub struct DiagonalMove(pub CardinalDirection); +impl Move for DiagonalMove { + fn cost(&self, dim: &Dimension, node: &Node) -> f32 { + if node.vertical_vel != VerticalVel::None { + return f32::INFINITY; + } + if !is_passable( + &BlockPos::new(node.pos.x + self.0.x(), node.pos.y, node.pos.z + self.0.z()), + dim, + ) && !is_passable( + &BlockPos::new( + node.pos.x + self.0.right().x(), + node.pos.y, + node.pos.z + self.0.right().z(), + ), + dim, + ) { + return f32::INFINITY; + } + if !is_standable(&(node.pos + self.offset()), dim) { + return f32::INFINITY; + } + WALK_ONE_BLOCK_COST * 1.4 + } + fn offset(&self) -> BlockPos { + let right = self.0.right(); + BlockPos::new(self.0.x() + right.x(), 0, self.0.z() + right.z()) + } + fn next_node(&self, node: &Node) -> Node { + Node { + pos: node.pos + self.offset(), + vertical_vel: VerticalVel::None, + } + } +} + +#[cfg(test)] +mod tests { + use super::*; + use azalea_block::BlockState; + use azalea_core::ChunkPos; + use azalea_world::Chunk; + + #[test] + fn test_is_passable() { + let mut dim = Dimension::default(); + dim.set_chunk(&ChunkPos { x: 0, z: 0 }, Some(Chunk::default())) + .unwrap(); + dim.set_block_state(&BlockPos::new(0, 0, 0), BlockState::Stone); + dim.set_block_state(&BlockPos::new(0, 1, 0), BlockState::Air); + + assert_eq!(is_block_passable(&BlockPos::new(0, 0, 0), &dim), false); + assert_eq!(is_block_passable(&BlockPos::new(0, 1, 0), &dim), true); + } + + #[test] + fn test_is_solid() { + let mut dim = Dimension::default(); + dim.set_chunk(&ChunkPos { x: 0, z: 0 }, Some(Chunk::default())) + .unwrap(); + dim.set_block_state(&BlockPos::new(0, 0, 0), BlockState::Stone); + dim.set_block_state(&BlockPos::new(0, 1, 0), BlockState::Air); + + assert_eq!(is_block_solid(&BlockPos::new(0, 0, 0), &dim), true); + assert_eq!(is_block_solid(&BlockPos::new(0, 1, 0), &dim), false); + } + + #[test] + fn test_is_standable() { + let mut dim = Dimension::default(); + dim.set_chunk(&ChunkPos { x: 0, z: 0 }, Some(Chunk::default())) + .unwrap(); + dim.set_block_state(&BlockPos::new(0, 0, 0), BlockState::Stone); + dim.set_block_state(&BlockPos::new(0, 1, 0), BlockState::Air); + dim.set_block_state(&BlockPos::new(0, 2, 0), BlockState::Air); + dim.set_block_state(&BlockPos::new(0, 3, 0), BlockState::Air); + + assert!(is_standable(&BlockPos::new(0, 1, 0), &dim)); + assert!(!is_standable(&BlockPos::new(0, 0, 0), &dim)); + assert!(!is_standable(&BlockPos::new(0, 2, 0), &dim)); + } +} diff --git a/azalea/src/pathfinder/mtdstarlite.rs b/azalea/src/pathfinder/mtdstarlite.rs new file mode 100644 index 00000000..8a40ec37 --- /dev/null +++ b/azalea/src/pathfinder/mtdstarlite.rs @@ -0,0 +1,453 @@ +//! An implementation of Moving Target D* Lite as described in +//! +//! +//! Future optimization attempt ideas: +//! - Use a different priority queue (e.g. fibonacci heap) +//! - Use FxHash instead of the default hasher +//! - Have `par` be a raw pointer +//! - Try borrowing vs copying the Node in several places (like state_mut) +//! - Store edge costs in their own map + +use priority_queue::DoublePriorityQueue; +use std::{collections::HashMap, fmt::Debug, hash::Hash, ops::Add}; + +/// Nodes are coordinates. +pub struct MTDStarLite< + N: Eq + Hash + Copy + Debug, + W: PartialOrd + Default + Copy + num_traits::Bounded + Debug, + HeuristicFn: Fn(&N) -> W, + SuccessorsFn: Fn(&N) -> Vec>, + PredecessorsFn: Fn(&N) -> Vec>, + SuccessFn: Fn(&N) -> bool, +> { + /// Returns a rough estimate of how close we are to the goal. Lower = closer. + pub heuristic: HeuristicFn, + /// Returns the nodes that can be reached from the given node. + pub successors: SuccessorsFn, + /// Returns the nodes that would direct us to the given node. If the graph + /// isn't directed (i.e. you can always return to the previous node), this + /// can be the same as `successors`. + pub predecessors: PredecessorsFn, + /// Returns true if the given node is at the goal. + /// A simple implementation is to check if the given node is equal to the goal. + pub success: SuccessFn, + + start: N, + goal: N, + + old_start: N, + old_goal: N, + + k_m: W, + open: DoublePriorityQueue>, + node_states: HashMap>, + updated_edge_costs: Vec>, + + /// This only exists so it can be referenced by `state()` when there's no state. + default_state: NodeState, +} + +impl< + N: Eq + Hash + Copy + Debug, + W: PartialOrd + Add + Default + Copy + num_traits::Bounded + Debug, + HeuristicFn: Fn(&N) -> W, + SuccessorsFn: Fn(&N) -> Vec>, + PredecessorsFn: Fn(&N) -> Vec>, + SuccessFn: Fn(&N) -> bool, + > MTDStarLite +{ + fn calculate_key(&self, n: &N) -> Priority { + let s = self.state(n); + let min_score = if s.g < s.rhs { s.g } else { s.rhs }; + Priority( + if min_score == W::max_value() { + min_score + } else { + min_score + (self.heuristic)(n) + self.k_m + }, + min_score, + ) + } + + pub fn new( + start: N, + goal: N, + heuristic: HeuristicFn, + successors: SuccessorsFn, + predecessors: PredecessorsFn, + success: SuccessFn, + ) -> Self { + let open = DoublePriorityQueue::default(); + let k_m = W::default(); + + let known_nodes = vec![start, goal]; + + let mut pf = MTDStarLite { + heuristic, + successors, + predecessors, + success, + + start, + goal, + + old_start: start, + old_goal: goal, + + k_m, + open, + node_states: HashMap::new(), + updated_edge_costs: Vec::new(), + + default_state: NodeState::default(), + }; + + for n in &known_nodes { + *pf.state_mut(n) = NodeState::default(); + } + (*pf.state_mut(&start)).rhs = W::default(); + pf.open.push(start, pf.calculate_key(&start)); + + pf + } + + fn update_state(&mut self, n: &N) { + let u = self.state_mut(n); + if u.g != u.rhs { + if self.open.get(n).is_some() { + self.open.change_priority(n, self.calculate_key(n)); + } else { + self.open.push(*n, self.calculate_key(n)); + } + } else if self.open.get(n).is_some() { + self.open.remove(n); + } + } + + fn compute_cost_minimal_path(&mut self) { + while { + if let Some((_, top_key)) = self.open.peek_min() { + (top_key < &self.calculate_key(&self.goal)) || { + let goal_state = self.state(&self.goal); + goal_state.rhs > goal_state.g + } + } else { + false + } + } { + let (u_node, k_old) = self.open.pop_min().unwrap(); + let k_new = self.calculate_key(&u_node); + if k_old < k_new { + self.open.change_priority(&u_node, k_new); + continue; + } + let u = self.state_mut(&u_node); + if u.g > u.rhs { + u.g = u.rhs; + self.open.remove(&u_node); + for edge in (self.successors)(&u_node) { + let s_node = edge.target; + let s = self.state(&s_node); + let u = self.state(&u_node); + if s_node != self.start && (s.rhs > u.g + edge.cost) { + let s_rhs = u.g + edge.cost; + let s = self.state_mut(&s_node); + s.par = Some(u_node); + s.rhs = s_rhs; + self.update_state(&s_node); + } + } + } else { + u.g = W::max_value(); + let u_edge = Edge { + target: u_node, + cost: W::default(), + }; + for edge in (self.successors)(&u_node) + .iter() + .chain([&u_edge].into_iter()) + { + let s_node = edge.target; + let s = self.state(&s_node); + if s_node != self.start && s.par == Some(u_node) { + let mut min_pred = u_node; + let mut min_score = W::max_value(); + + for edge in (self.predecessors)(&s_node) { + let s = self.state(&edge.target); + let score = s.g + edge.cost; + if score < min_score { + min_score = score; + min_pred = edge.target; + } + } + + let s = self.state_mut(&s_node); + s.rhs = min_score; + if s.rhs == W::max_value() { + s.par = None; + } else { + s.par = Some(min_pred); + } + } + self.update_state(&s_node); + } + } + } + } + + pub fn find_path(&mut self) -> Option> { + if (self.success)(&self.start) { + return None; + } + + // + self.k_m = self.k_m + (self.heuristic)(&self.old_goal); + + if self.old_start != self.start { + self.optimized_deletion(); + } + + while let Some(edge) = self.updated_edge_costs.pop() { + let (u_node, v_node) = (edge.predecessor, edge.successor); + // update the edge cost c(u, v); + if edge.old_cost > edge.cost { + let u_g = self.state(&u_node).g; + if v_node != self.start && self.state(&v_node).rhs > u_g + edge.cost { + let v = self.state_mut(&v_node); + v.par = Some(u_node); + v.rhs = u_g + edge.cost; + } + } else if v_node != self.start && self.state(&v_node).par == Some(u_node) { + let mut min_pred = u_node; + let mut min_score = W::max_value(); + + for edge in (self.predecessors)(&v_node) { + let s = self.state(&edge.target); + let score = s.g + edge.cost; + if score < min_score { + min_score = score; + min_pred = edge.target; + } + } + + let v = self.state_mut(&v_node); + v.rhs = min_score; + if v.rhs == W::max_value() { + v.par = None; + } else { + v.par = Some(min_pred); + } + self.update_state(&v_node); + } + } + // + + self.old_start = self.start; + self.old_goal = self.goal; + + self.compute_cost_minimal_path(); + if self.state(&self.goal).rhs == W::max_value() { + // no path exists + return None; + } + + let mut reverse_path = vec![self.goal]; + + // identify a path from sstart to sgoal using the parent pointers + let mut target = self.state(&self.goal).par; + while !(Some(self.start) == target) { + let this_target = if let Some(this_target) = target { + this_target + } else { + break; + }; + // hunter follows path from start to goal; + reverse_path.push(this_target); + target = self.state(&this_target).par; + } + + // if hunter caught target { + // return None; + // } + + let path: Vec = reverse_path.into_iter().rev().collect(); + + Some(path) + } + + fn optimized_deletion(&mut self) { + let start = self.start; + self.state_mut(&start).par = None; + + let mut min_pred = self.old_start; + let mut min_score = W::max_value(); + + for edge in (self.predecessors)(&self.old_start) { + let s = self.state(&edge.target); + let score = s.g + edge.cost; + if score < min_score { + min_score = score; + min_pred = edge.target; + } + } + + let old_start = self.old_start; + let s = self.state_mut(&old_start); + s.rhs = min_score; + if s.rhs == W::max_value() { + s.par = None; + } else { + s.par = Some(min_pred); + } + self.update_state(&old_start); + } + + fn state(&self, n: &N) -> &NodeState { + self.node_states.get(n).unwrap_or(&self.default_state) + } + + fn state_mut(&mut self, n: &N) -> &mut NodeState { + self.node_states.entry(*n).or_default() + } +} + +#[derive(PartialEq, Debug)] +pub struct Priority(W, W) +where + W: PartialOrd + Debug; + +impl PartialOrd for Priority { + fn partial_cmp(&self, other: &Self) -> Option { + if self.0 < other.0 { + Some(std::cmp::Ordering::Less) + } else if self.0 > other.0 { + Some(std::cmp::Ordering::Greater) + } else if self.1 < other.1 { + Some(std::cmp::Ordering::Less) + } else if self.1 > other.1 { + Some(std::cmp::Ordering::Greater) + } else { + Some(std::cmp::Ordering::Equal) + } + } +} +impl Ord for Priority { + fn cmp(&self, other: &Self) -> std::cmp::Ordering { + self.partial_cmp(other) + .expect("Partial compare should not fail for Priority") + } +} +impl Eq for Priority {} + +#[derive(Debug)] +pub struct NodeState { + pub g: W, + pub rhs: W, + // future possible optimization: try making this a pointer + pub par: Option, +} + +impl Default + for NodeState +{ + fn default() -> Self { + NodeState { + g: W::max_value(), + rhs: W::max_value(), + par: None, + } + } +} + +pub struct Edge { + pub target: N, + pub cost: W, +} + +pub struct ChangedEdge { + pub predecessor: N, + pub successor: N, + pub old_cost: W, + pub cost: W, +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_mtdstarlite() { + let maze = [ + [0, 1, 0, 0, 0], + [0, 1, 0, 1, 0], + [0, 0, 0, 1, 0], + [0, 1, 0, 1, 0], + [0, 0, 1, 0, 0], + ]; + let width = maze[0].len(); + let height = maze.len(); + + let goal = (4, 4); + + let heuristic = |n: &(usize, usize)| -> usize { + ((n.0 as isize - goal.0 as isize).abs() + (n.1 as isize - goal.1 as isize).abs()) + as usize + }; + let successors = |n: &(usize, usize)| -> Vec> { + let mut successors = Vec::with_capacity(4); + let (x, y) = *n; + + if x > 0 && maze[y][x - 1] == 0 { + successors.push(Edge { + target: ((x - 1, y)), + cost: 1, + }); + } + if x < width - 1 && maze[y][x + 1] == 0 { + successors.push(Edge { + target: ((x + 1, y)), + cost: 1, + }); + } + if y > 0 && maze[y - 1][x] == 0 { + successors.push(Edge { + target: ((x, y - 1)), + cost: 1, + }); + } + if y < height - 1 && maze[y + 1][x] == 0 { + successors.push(Edge { + target: ((x, y + 1)), + cost: 1, + }); + } + + successors + }; + let predecessors = + |n: &(usize, usize)| -> Vec> { successors(n) }; + + let mut pf = MTDStarLite::new((0, 0), goal, heuristic, successors, predecessors, |n| { + n == &goal + }); + let path = pf.find_path().unwrap(); + assert_eq!( + path, + vec![ + (0, 1), + (0, 2), + (1, 2), + (2, 2), + (2, 1), + (2, 0), + (3, 0), + (4, 0), + (4, 1), + (4, 2), + (4, 3), + (4, 4), + ] + ); + } +} diff --git a/azalea/src/prelude.rs b/azalea/src/prelude.rs old mode 100644 new mode 100755 index c09d85e2..9fa1ac1a --- a/azalea/src/prelude.rs +++ b/azalea/src/prelude.rs @@ -1,4 +1,6 @@ //! The Azalea prelude. Things that are necessary for a bare-bones bot are re-exported here. pub use crate::bot::BotTrait; +pub use crate::pathfinder::Trait; +pub use crate::plugins; pub use azalea_client::{Account, Client, Event}; diff --git a/bot/Cargo.toml b/bot/Cargo.toml index 9212f796..6663d1f7 100644 --- a/bot/Cargo.toml +++ b/bot/Cargo.toml @@ -11,6 +11,6 @@ version = "0.2.0" anyhow = "1.0.65" azalea = {path = "../azalea"} env_logger = "0.9.1" -parking_lot = "^0.12.1" -tokio = "^1.21.2" +parking_lot = {version = "^0.12.1", features = ["deadlock_detection"]} +tokio = "1.19.2" uuid = "1.1.2" diff --git a/bot/src/main.rs b/bot/src/main.rs old mode 100644 new mode 100755 index 3ab90bfd..f1398062 --- a/bot/src/main.rs +++ b/bot/src/main.rs @@ -1,4 +1,5 @@ -use azalea::prelude::*; +use azalea::pathfinder::BlockPosGoal; +use azalea::{prelude::*, BlockPos}; use azalea::{Account, Client, Event}; #[derive(Default, Clone)] @@ -8,6 +9,31 @@ struct State {} async fn main() -> anyhow::Result<()> { env_logger::init(); + { + // only for #[cfg] + use parking_lot::deadlock; + use std::thread; + use std::time::Duration; + + // Create a background thread which checks for deadlocks every 10s + thread::spawn(move || loop { + thread::sleep(Duration::from_secs(10)); + let deadlocks = deadlock::check_deadlock(); + if deadlocks.is_empty() { + continue; + } + + println!("{} deadlocks detected", deadlocks.len()); + for (i, threads) in deadlocks.iter().enumerate() { + println!("Deadlock #{}", i); + for t in threads { + println!("Thread Id {:#?}", t.thread_id()); + println!("{:#?}", t.backtrace()); + } + } + }); + } // only for #[cfg] + // let account = Account::microsoft("example@example.com").await?; let account = Account::offline("bot"); @@ -16,7 +42,7 @@ async fn main() -> anyhow::Result<()> { account: account.clone(), address: "localhost", state: State::default(), - plugins: vec![], + plugins: plugins![], handle, }) .await; @@ -27,13 +53,29 @@ async fn main() -> anyhow::Result<()> { async fn handle(bot: Client, event: Event, _state: State) -> anyhow::Result<()> { match event { Event::Login => { - bot.chat("Hello world").await?; + // bot.chat("Hello world").await?; + } + Event::Chat(m) => { + println!("{}", m.message().to_ansi(None)); + if m.message().to_string() == " goto" { + let target_pos_vec3 = bot + .dimension + .read() + .entity_by_uuid(&uuid::uuid!("6536bfed869548fd83a1ecd24cf2a0fd")) + .unwrap() + .pos() + .clone(); + let target_pos: BlockPos = (&target_pos_vec3).into(); + // bot.look_at(&target_pos_vec3); + bot.goto(BlockPosGoal::from(target_pos)); + // bot.walk(WalkDirection::Forward); + } } Event::Initialize => { println!("initialized"); } Event::Tick => { - bot.jump(); + // bot.jump(); } _ => {} } diff --git a/codegen/.gitignore b/codegen/.gitignore old mode 100644 new mode 100755 diff --git a/codegen/README.md b/codegen/README.md old mode 100644 new mode 100755 diff --git a/codegen/genblocks.py b/codegen/genblocks.py old mode 100644 new mode 100755 diff --git a/codegen/genregistries.py b/codegen/genregistries.py old mode 100644 new mode 100755 diff --git a/codegen/lib/code/blocks.py b/codegen/lib/code/blocks.py old mode 100644 new mode 100755 diff --git a/codegen/lib/code/entity.py b/codegen/lib/code/entity.py index 13f99022..9b976ef6 100644 --- a/codegen/lib/code/entity.py +++ b/codegen/lib/code/entity.py @@ -44,7 +44,7 @@ def generate_entity_metadata(burger_entity_data: dict, mappings: Mappings): code.append('use azalea_block::BlockState;') code.append('use azalea_chat::Component;') code.append('use azalea_core::{BlockPos, Direction, Particle, Slot};') - code.append('use std::{collections::VecDeque, ops::Deref};') + code.append('use std::{collections::VecDeque, ops::{Deref, DerefMut}};') code.append('use uuid::Uuid;') code.append('') @@ -271,6 +271,10 @@ def generate_entity_metadata(burger_entity_data: dict, mappings: Mappings): code.append( f'fn deref(&self) -> &Self::Target {{ &self.{parent_field_name} }}') code.append('}') + code.append(f'impl DerefMut for {struct_name} {{') + code.append( + f'fn deref_mut(&mut self) -> &mut Self::Target {{ &mut self.{parent_field_name} }}') + code.append('}') code.append('') # make the EntityMetadata enum from entity_structs @@ -309,6 +313,36 @@ def generate_entity_metadata(burger_entity_data: dict, mappings: Mappings): code.append('}') code.append('') + # impl Deref for EntityMetadata { + # type Target = AbstractEntity; + # fn deref(&self) -> &Self::Target { + # match self { + # EntityMetadata::Allay(entity) => entity, + # _ => {} + # } + # } + # } + code.append('impl Deref for EntityMetadata {') + code.append('type Target = AbstractEntity;') + code.append('fn deref(&self) -> &Self::Target {') + code.append('match self {') + for struct_name in entity_structs: + code.append( + f'EntityMetadata::{struct_name}(entity) => entity,') + code.append('}') + code.append('}') + code.append('}') + code.append('impl DerefMut for EntityMetadata {') + code.append('fn deref_mut(&mut self) -> &mut Self::Target {') + code.append('match self {') + for struct_name in entity_structs: + code.append( + f'EntityMetadata::{struct_name}(entity) => entity,') + code.append('}') + code.append('}') + code.append('}') + code.append('') + with open(METADATA_RS_DIR, 'w') as f: f.write('\n'.join(code)) diff --git a/codegen/lib/code/packet.py b/codegen/lib/code/packet.py old mode 100644 new mode 100755 diff --git a/codegen/lib/code/registry.py b/codegen/lib/code/registry.py old mode 100644 new mode 100755 diff --git a/codegen/lib/code/shapes.py b/codegen/lib/code/shapes.py old mode 100644 new mode 100755 diff --git a/codegen/lib/code/utils.py b/codegen/lib/code/utils.py old mode 100644 new mode 100755 diff --git a/codegen/lib/code/version.py b/codegen/lib/code/version.py old mode 100644 new mode 100755 diff --git a/codegen/lib/download.py b/codegen/lib/download.py old mode 100644 new mode 100755 diff --git a/codegen/lib/extract.py b/codegen/lib/extract.py old mode 100644 new mode 100755 diff --git a/codegen/lib/mappings.py b/codegen/lib/mappings.py old mode 100644 new mode 100755 diff --git a/codegen/lib/utils.py b/codegen/lib/utils.py old mode 100644 new mode 100755 diff --git a/codegen/migrate.py b/codegen/migrate.py old mode 100644 new mode 100755 diff --git a/codegen/newpacket.py b/codegen/newpacket.py old mode 100644 new mode 100755