valence/crates
Tachibana Yui 61f2279831
Implement world border (#364)
## Description

Basic implementation of world border
World border is not enabled by default. It can be enabled by inserting
`WorldBorderBundle` bundle. Currently, this PR only implements world
borders per instance, I'm considering expanding this per client.
However, the same functionality can be achieved by Visibility Layers
#362

<details>
<summary>Playground:</summary>

```rust
fn border_controls(
    mut events: EventReader<ChatMessageEvent>,
    mut instances: Query<(Entity, &WorldBorderDiameter, &mut WorldBorderCenter), With<Instance>>,
    mut event_writer: EventWriter<SetWorldBorderSizeEvent>,
) {
    for x in events.iter() {
        let parts: Vec<&str> = x.message.split(' ').collect();
        match parts[0] {
            "add" => {
                let Ok(value) = parts[1].parse::<f64>() else {
                    return;
                };

                let Ok(speed) = parts[2].parse::<i64>() else {
                    return;
                };

                let Ok((entity, diameter, _)) = instances.get_single_mut() else {
                    return;
                };

                event_writer.send(SetWorldBorderSizeEvent {
                    instance: entity,
                    new_diameter: diameter.diameter() + value,
                    speed,
                })
            }
            "center" => {
                let Ok(x) = parts[1].parse::<f64>() else {
                    return;
                };

                let Ok(z) = parts[2].parse::<f64>() else {
                    return;
                };

                instances.single_mut().2 .0 = DVec2 { x, y: z };
            }
            _ => (),
        }
    }
}
``` 
</details>

example: `cargo run --package valence --example world_border`
tests: `cargo test --package valence --lib -- tests::world_border`


**Related**
part of #210
2023-06-14 22:15:47 -07:00
..
valence Implement world border (#364) 2023-06-14 22:15:47 -07:00
valence_advancement Update to Minecraft 1.20.1 (#358) 2023-06-13 14:38:55 -07:00
valence_anvil serde support for valence_nbt + fixes. (#352) 2023-06-04 05:56:10 -07:00
valence_biome Registry Redesign (#361) 2023-06-11 09:08:38 -07:00
valence_block Move packets out of valence_core. (#335) 2023-05-29 01:36:11 -07:00
valence_build_utils Reorganize Project (#321) 2023-04-21 14:43:59 -07:00
valence_client Update to Minecraft 1.20.1 (#358) 2023-06-13 14:38:55 -07:00
valence_core Update to Minecraft 1.20.1 (#358) 2023-06-13 14:38:55 -07:00
valence_core_macros Move packets out of valence_core. (#335) 2023-05-29 01:36:11 -07:00
valence_dimension Registry Redesign (#361) 2023-06-11 09:08:38 -07:00
valence_entity Update to Minecraft 1.20.1 (#358) 2023-06-13 14:38:55 -07:00
valence_instance Implement world border (#364) 2023-06-14 22:15:47 -07:00
valence_inventory Update to Minecraft 1.20.1 (#358) 2023-06-13 14:38:55 -07:00
valence_nbt Registry Redesign (#361) 2023-06-11 09:08:38 -07:00
valence_network Move packets out of valence_core. (#335) 2023-05-29 01:36:11 -07:00
valence_player_list Move packets out of valence_core. (#335) 2023-05-29 01:36:11 -07:00
valence_registry Update to Minecraft 1.20.1 (#358) 2023-06-13 14:38:55 -07:00
valence_spatial_index Reorganize Project (#321) 2023-04-21 14:43:59 -07:00
valence_world_border Implement world border (#364) 2023-06-14 22:15:47 -07:00
README.md Implement world border (#364) 2023-06-14 22:15:47 -07:00

Crates

The standard crates used in Valence projects.

All crates here are exported by the main valence crate. valence is the intended interface for both end users and plugin authors.

Crates are versioned in lockstep with the exception of valence_nbt.

Ignoring transitive dependencies and valence_core, the dependency graph can be described like this:

graph TD
  network --> client
	client --> instance
	biome --> registry
	dimension --> registry
	instance --> biome
	instance --> dimension
	instance --> entity
	player_list --> client
	inventory --> client
	anvil --> instance
	entity --> block
	advancement --> client
	world_border --> client