ghast-client 0.5.4

Headless Minecraft Java Edition client for the ghast library: connection, login, fixed 50 ms tick loop and a version-agnostic bot API (1.8.9, 1.12.2, 1.16.5, 26.1, 26.2 and 26.3)
Documentation
//! Test only: a boxed [`Sim`] is a [`WorldView`] and a [`Sim`] (every hook forwards to the
//! boxed one).

use super::*;

#[cfg(test)]
impl WorldView for Box<dyn Sim> {
    fn column(&self, chunk_x: i32, chunk_z: i32) -> Option<&ghast_world::Column> {
        (**self).column(chunk_x, chunk_z)
    }
    fn is_column_loaded(&self, chunk_x: i32, chunk_z: i32) -> bool {
        (**self).is_column_loaded(chunk_x, chunk_z)
    }
    fn raw_block(&self, x: i32, y: i32, z: i32) -> Option<u32> {
        (**self).raw_block(x, y, z)
    }
    fn entities(&self) -> Option<&ghast_entity::Entities> {
        (**self).entities()
    }
    fn loaded_columns(&self) -> usize {
        (**self).loaded_columns()
    }
    fn collisions(&self) -> (bool, bool) {
        (**self).collisions()
    }

    fn block_query(&self, x: i32, y: i32, z: i32) -> Option<BlockQuery> {
        (**self).block_query(x, y, z)
    }

    fn crosshair(
        &self,
        eyes: Vec3,
        rotation: (f32, f32),
        look: Vec3,
        reach: f64,
    ) -> Option<crate::BlockHit> {
        (**self).crosshair(eyes, rotation, look, reach)
    }
}

#[cfg(test)]
impl Sim for Box<dyn Sim> {
    fn world_packet(&mut self, raw: &RawPacket) -> Result<(), SimError> {
        (**self).world_packet(raw)
    }
    fn reset_player(&mut self) {
        (**self).reset_player();
    }
    fn respawn_player(&mut self, keep: u8) {
        (**self).respawn_player(keep);
    }
    fn teleport(&mut self, pose: &mut Pose, t: &Teleport) {
        (**self).teleport(pose, t);
    }
    fn abilities(&mut self, a: Abilities) {
        (**self).abilities(a);
    }
    fn food(&mut self, food: i32) {
        (**self).food(food);
    }
    fn velocity(&mut self, v: Vec3, add: bool) {
        (**self).velocity(v, add);
    }
    fn step(
        &mut self,
        pose: &mut Pose,
        controls: Controls,
        using_item: bool,
        entity_id: i32,
        out: &mut Vec<Outbound>,
    ) {
        (**self).step(pose, controls, using_item, entity_id, out);
    }
    fn set_flying(&mut self, flying: bool, out: &mut Vec<Outbound>) {
        (**self).set_flying(flying, out);
    }
    fn collect_block_updates(&mut self, on: bool) {
        (**self).collect_block_updates(on);
    }
    fn drain_block_updates(&mut self, out: &mut Vec<(BlockPos, u32)>) -> usize {
        (**self).drain_block_updates(out)
    }
    fn world_packet_ids(&self) -> Vec<i32> {
        (**self).world_packet_ids()
    }
    fn entity_config(&self) -> Option<ghast_entity::Config> {
        (**self).entity_config()
    }
    fn set_entities(&mut self, config: Option<ghast_entity::Config>) {
        (**self).set_entities(config);
    }
    fn entity_packet_ids(&self) -> Vec<i32> {
        (**self).entity_packet_ids()
    }
    fn predict_air(&mut self, x: i32, y: i32, z: i32) {
        (**self).predict_air(x, y, z);
    }
    fn dig_sent(
        &mut self,
        pos: BlockPos,
        status: crate::common::DigStatus,
        broken: bool,
        sequence: i32,
        player: Vec3,
    ) {
        (**self).dig_sent(pos, status, broken, sequence, player);
    }
    fn records_digs(&self) -> bool {
        (**self).records_digs()
    }
    fn place_sent(&mut self, p: &predict::PlaceSent<'_>) -> bool {
        (**self).place_sent(p)
    }
    fn place_suppressed(&self, pos: BlockPos, face: crate::common::Face, held: u16) -> bool {
        (**self).place_suppressed(pos, face, held)
    }
    fn place_rules(&self, q: &predict::PlaceQuery<'_>) -> predict::PlaceRules {
        (**self).place_rules(q)
    }
    fn air_use(&self, q: &predict::AirQuery<'_>) -> predict::AirAnswer {
        (**self).air_use(q)
    }
    fn air_use_sent(&mut self, blocks: &[(BlockPos, u32)]) {
        (**self).air_use_sent(blocks);
    }
    fn set_player_pos(&mut self, p: Vec3) {
        (**self).set_player_pos(p);
    }
    fn teleport_sequence(&mut self, sequence: Option<i32>) {
        (**self).teleport_sequence(sequence);
    }
    fn take_snap(&mut self) -> Option<Vec3> {
        (**self).take_snap()
    }
    fn movement_speed(&mut self, base: f64, modifiers: &[(u128, f64, u8)]) {
        (**self).movement_speed(base, modifiers);
    }
    fn status_effects(&mut self, effects: &std::collections::BTreeMap<i8, i8>) {
        (**self).status_effects(effects);
    }
    fn boots(&mut self, depth_strider: u8, soul_speed: u8) {
        (**self).boots(depth_strider, soul_speed);
    }
    fn feet_item(&mut self, id: Option<i32>) {
        (**self).feet_item(id);
    }
    fn hand_items(&mut self, inv: &mut ghast_inventory::Inventory) {
        (**self).hand_items(inv);
    }
    fn hands_at_packet(&mut self, inv: &ghast_inventory::Inventory) {
        (**self).hands_at_packet(inv);
    }
    fn spectator(&mut self, on: bool) {
        (**self).spectator(on);
    }
    fn held_item(&self, id: u16, count: u8, efficiency: u8) -> HeldItem {
        (**self).held_item(id, count, efficiency)
    }
    fn item_use_facts(
        &self,
        stack: &ghast_inventory::Stack,
        off_hand: bool,
        held: HeldItem,
    ) -> HeldItem {
        (**self).item_use_facts(stack, off_hand, held)
    }
    fn modern_inputs(&self) -> bool {
        (**self).modern_inputs()
    }
    fn held_use_inputs(&mut self, inv: &mut ghast_inventory::Inventory) {
        (**self).held_use_inputs(inv);
    }
    fn pre_tick_wanted(&self) -> bool {
        (**self).pre_tick_wanted()
    }
    fn pre_tick(&mut self, inv: &ghast_inventory::Inventory, t: &PreTick) -> bool {
        (**self).pre_tick(inv, t)
    }
    fn gliding(&self) -> bool {
        (**self).gliding()
    }
    fn weather(&mut self, reason: u8, value: f32) {
        (**self).weather(reason, value);
    }
    fn mount_info(&self, entity_id: i32) -> Option<(i32, bool, bool)> {
        (**self).mount_info(entity_id)
    }
    fn mount_rules(&self, entity_id: i32) -> Option<ghast_inventory::MountRules> {
        (**self).mount_rules(entity_id)
    }
    #[cfg(ghast_modern)]
    fn modern_player(&self) -> Option<&ghast_physics::modern::PlayerState> {
        (**self).modern_player()
    }
    fn take_reply(&mut self) -> Option<Outbound> {
        (**self).take_reply()
    }
    fn take_filter_dirty(&mut self) -> bool {
        (**self).take_filter_dirty()
    }
    fn vehicle(&self) -> Option<crate::common::Vehicle> {
        (**self).vehicle()
    }
    #[cfg(all(test, ghast_modern, feature = "v1_8", feature = "v1_16_5"))]
    fn test_set_modern(
        &mut self,
        p: ghast_physics::modern::PlayerState,
        x: ghast_physics::modern::PlayerExt,
    ) {
        (**self).test_set_modern(p, x);
    }
    #[cfg(all(test, ghast_modern, feature = "v1_8", feature = "v1_16_5"))]
    fn test_shared_flags(&self) -> u8 {
        (**self).test_shared_flags()
    }
    #[cfg(all(test, ghast_modern, feature = "v1_8", feature = "v1_16_5"))]
    fn test_set_own_id(&mut self, id: i32) {
        (**self).test_set_own_id(id);
    }
    fn set_main_arm_left(&mut self, left: bool) {
        (**self).set_main_arm_left(left);
    }
    fn crosshair_now(
        &self,
        eyes: Vec3,
        rotation: (f32, f32),
        look: Vec3,
        held: Option<u16>,
    ) -> Option<crate::BlockHit> {
        (**self).crosshair_now(eyes, rotation, look, held)
    }
    fn crosshair_target(&self, q: &PickQuery<'_>) -> Crosshair {
        (**self).crosshair_target(q)
    }
    fn pick_margin(&self, e: &ghast_entity::Entity) -> Option<f32> {
        (**self).pick_margin(e)
    }
    fn search_order(&self, e: &ghast_entity::Entity) -> Option<(i32, i32, i32, u32)> {
        (**self).search_order(e)
    }
    fn tick_entities(&mut self, pose: &mut Pose) {
        (**self).tick_entities(pose);
    }
    fn send_changes(&mut self, entity_id: i32, out: &mut Vec<Outbound>) {
        (**self).send_changes(entity_id, out);
    }
    fn entity_event(&mut self, entity_id: i32, status: i8) {
        (**self).entity_event(entity_id, status);
    }
    fn entities_mut(&mut self) -> Option<&mut ghast_entity::Entities> {
        (**self).entities_mut()
    }
    fn set_entity_push(&mut self, on: bool) {
        (**self).set_entity_push(on);
    }
    fn set_entity_physics(&mut self, on: bool) {
        (**self).set_entity_physics(on);
    }
    fn sign_at(&self, pos: ghast_protocol::BlockPos) -> Option<bool> {
        (**self).sign_at(pos)
    }
    fn sleep_at(&mut self, pose: &mut Pose, bed: ghast_protocol::BlockPos) {
        (**self).sleep_at(pose, bed);
    }
    fn wake_up(&mut self) {
        (**self).wake_up();
    }
    fn take_sleep(&mut self, pose: &mut Pose) -> Option<Option<ghast_protocol::BlockPos>> {
        (**self).take_sleep(pose)
    }
    fn fishing(&self) -> Option<&crate::fishing::Bobber> {
        (**self).fishing()
    }
    fn fishing_news(&self) -> bool {
        (**self).fishing_news()
    }
    fn drain_fishing(&mut self, out: &mut Vec<crate::fishing::FishingEvent>) {
        (**self).drain_fishing(out);
    }
    fn block_interaction_range(&self) -> f64 {
        (**self).block_interaction_range()
    }
    fn level_load_start(&mut self) {
        (**self).level_load_start();
    }
    fn player_alive(&mut self, alive: bool) {
        (**self).player_alive(alive);
    }
    fn load_gate_tick(&mut self, section_compiled: bool, timed_out: bool) -> bool {
        (**self).load_gate_tick(section_compiled, timed_out)
    }
    fn tick_unloaded(&mut self) {
        (**self).tick_unloaded();
    }
    fn attributes(&mut self, attributes: &[crate::common::AttributeUpdate]) {
        (**self).attributes(attributes);
    }
    fn entity_attributes(&mut self, entity_id: i32, attributes: &[crate::common::AttributeUpdate]) {
        (**self).entity_attributes(entity_id, attributes);
    }
    fn chunk_batch_start(&mut self, now_nanos: i64) {
        (**self).chunk_batch_start(now_nanos);
    }
    fn chunk_batch_finished(&mut self, batch_size: i32, now_nanos: i64) -> f32 {
        (**self).chunk_batch_finished(batch_size, now_nanos)
    }
    fn registry_data(&mut self, raw: &RawPacket) {
        (**self).registry_data(raw);
    }
    fn day_clock(&self) -> Option<i32> {
        (**self).day_clock()
    }
    fn attack_hurts(&self, e: &ghast_entity::Entity) -> bool {
        (**self).attack_hurts(e)
    }
    fn eye_height(&self) -> Option<f64> {
        (**self).eye_height()
    }
    fn awake_eye_height(&self) -> Option<f64> {
        (**self).awake_eye_height()
    }
    fn attack_slow(&mut self, target: i32, yaw: f32, knockback: i32, sprint_bonus: bool) {
        (**self).attack_slow(target, yaw, knockback, sprint_bonus);
    }
    fn sprinting(&self) -> bool {
        (**self).sprinting()
    }
    fn server_flags(&self) -> Option<u8> {
        (**self).server_flags()
    }
    fn take_living_flags(&mut self) -> Option<u8> {
        (**self).take_living_flags()
    }
    fn take_absorption(&mut self) -> Option<f32> {
        (**self).take_absorption()
    }
    fn velocity_now(&self) -> Vec3 {
        (**self).velocity_now()
    }
}