2023-04-22 11:13:54 +10: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:
|
|
|
|
|
|
|
|
```mermaid
|
|
|
|
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
|
2023-05-02 18:35:35 +10:00
|
|
|
advancement --> client
|
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-15 15:15:47 +10:00
|
|
|
world_border --> client
|
2023-04-22 11:13:54 +10:00
|
|
|
```
|