aboutsummaryrefslogtreecommitdiff
path: root/azalea-client/tests/simulation/move_and_despawn_entity.rs
blob: a30870e34a620b1077dc21023a3c973fd7d9c7f3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
use azalea_client::test_utils::prelude::*;
use azalea_core::{
    entity_id::MinecraftEntityId,
    position::{ChunkPos, Vec3},
};
use azalea_protocol::{
    common::movements::{PositionMoveRotation, RelativeMovements},
    packets::{
        ConnectionProtocol,
        game::{ClientboundRemoveEntities, ClientboundTeleportEntity},
    },
};
use azalea_registry::builtin::EntityKind;

#[test]
fn test_move_and_despawn_entity() {
    let _lock = init();

    let mut simulation = Simulation::new(ConnectionProtocol::Game);
    simulation.receive_packet(default_login_packet());

    simulation.receive_packet(make_basic_empty_chunk(ChunkPos::new(0, 0), (384 + 64) / 16));
    simulation.tick();

    simulation.receive_packet(make_basic_add_entity(EntityKind::Cow, 123, (0.5, 64., 0.5)));
    simulation.tick();

    simulation.receive_packet(ClientboundTeleportEntity {
        id: MinecraftEntityId(123),
        change: PositionMoveRotation {
            pos: Vec3::new(16., 0., 0.),
            delta: Vec3::ZERO,
            look_direction: Default::default(),
        },
        relative: RelativeMovements::all_relative(),
        on_ground: true,
    });
    simulation.receive_packet(ClientboundRemoveEntities {
        entity_ids: vec![MinecraftEntityId(123)],
    });
    simulation.tick();
}