Skip to main content

chunkedge/
lib.rs

1#![cfg_attr(
2    unstable_doc,
3    doc = "**❗ NOTE:** This documentation is sourced from the `main` branch. Guides and general \
4           project documentation can be found in [`docs`].\n\n---\n"
5)]
6#![doc = include_str!("../README.md")]
7#![cfg_attr(
8    doc,
9    doc = "\n\n## General Project Documentation\n\nThe guides, FAQ, and other pages are available \
10           in [`docs`].\n"
11)]
12#![doc(
13    html_logo_url = "https://raw.githubusercontent.com/ChunkEdge/ChunkEdge/main/assets/logo.svg",
14    html_favicon_url = "https://raw.githubusercontent.com/ChunkEdge/ChunkEdge/main/assets/logo.svg"
15)]
16#![deny(
17    rustdoc::broken_intra_doc_links,
18    rustdoc::private_intra_doc_links,
19    rustdoc::missing_crate_level_docs,
20    rustdoc::invalid_codeblock_attributes,
21    rustdoc::invalid_rust_codeblocks,
22    rustdoc::bare_urls,
23    rustdoc::invalid_html_tags
24)]
25#![warn(
26    trivial_casts,
27    trivial_numeric_casts,
28    unused_lifetimes,
29    unused_import_braces,
30    unreachable_pub,
31    clippy::dbg_macro
32)]
33
34use bevy_app::{PluginGroup, PluginGroupBuilder};
35
36#[cfg(doc)]
37pub mod docs;
38
39#[cfg(feature = "testing")]
40pub mod testing;
41
42#[cfg(test)]
43mod tests;
44
45#[cfg(feature = "log")]
46pub use bevy_log as log;
47#[cfg(feature = "advancement")]
48pub use chunkedge_advancement as advancement;
49#[cfg(feature = "anvil")]
50pub use chunkedge_anvil as anvil;
51#[cfg(feature = "boss_bar")]
52pub use chunkedge_boss_bar as boss_bar;
53#[cfg(feature = "command")]
54pub use chunkedge_command as command;
55#[cfg(feature = "command")]
56pub use chunkedge_command_macros as command_macros;
57#[cfg(feature = "equipment")]
58pub use chunkedge_equipment as equipment;
59#[cfg(feature = "inventory")]
60pub use chunkedge_inventory as inventory;
61pub use chunkedge_item as item;
62pub use chunkedge_lang as lang;
63#[cfg(feature = "network")]
64pub use chunkedge_network as network;
65#[cfg(feature = "player_list")]
66pub use chunkedge_player_list as player_list;
67use chunkedge_registry::RegistryPlugin;
68#[cfg(feature = "scoreboard")]
69pub use chunkedge_scoreboard as scoreboard;
70use chunkedge_server::abilities::AbilitiesPlugin;
71use chunkedge_server::action::ActionPlugin;
72use chunkedge_server::client::ClientPlugin;
73use chunkedge_server::client_command::ClientCommandPlugin;
74use chunkedge_server::client_settings::ClientSettingsPlugin;
75use chunkedge_server::custom_payload::CustomPayloadPlugin;
76use chunkedge_server::entity::EntityPlugin;
77use chunkedge_server::entity::hitbox::HitboxPlugin;
78use chunkedge_server::event_loop::EventLoopPlugin;
79use chunkedge_server::hand_swing::HandSwingPlugin;
80use chunkedge_server::interact_block::InteractBlockPlugin;
81use chunkedge_server::interact_entity::InteractEntityPlugin;
82use chunkedge_server::interact_item::InteractItemPlugin;
83use chunkedge_server::keepalive::KeepalivePlugin;
84use chunkedge_server::layer::LayerPlugin;
85use chunkedge_server::message::MessagePlugin;
86use chunkedge_server::movement::MovementPlugin;
87use chunkedge_server::op_level::OpLevelPlugin;
88use chunkedge_server::passenger::PassengerPlugin;
89pub use chunkedge_server::protocol::status_effects;
90use chunkedge_server::resource_pack::ResourcePackPlugin;
91use chunkedge_server::status::StatusPlugin;
92use chunkedge_server::status_effect::StatusEffectPlugin;
93use chunkedge_server::teleport::TeleportPlugin;
94pub use chunkedge_server::*;
95#[cfg(feature = "weather")]
96pub use chunkedge_weather as weather;
97#[cfg(feature = "world_border")]
98pub use chunkedge_world_border as world_border;
99use registry::biome::BiomePlugin;
100use registry::dimension_type::DimensionTypePlugin;
101
102/// Contains the most frequently used items in ChunkEdge projects.
103///
104/// This is usually glob imported like so:
105///
106/// ```no_run
107/// use chunkedge::prelude::*; // Glob import.
108///
109/// let mut app = App::empty();
110/// app.add_systems(Update, || println!("yippee!"));
111/// app.update()
112/// // ...
113/// ```
114pub mod prelude {
115    pub use bevy_app::prelude::*;
116    pub use bevy_ecs; // Needed for bevy_ecs macros to function correctly.
117    pub use bevy_ecs::prelude::*;
118    #[cfg(feature = "advancement")]
119    pub use chunkedge_advancement::{
120        Advancement, AdvancementBundle, AdvancementClientUpdate, AdvancementCriteria,
121        AdvancementDisplay, AdvancementFrameType, AdvancementRequirements,
122        message::AdvancementTabChangeMessage,
123    };
124    #[cfg(feature = "equipment")]
125    pub use chunkedge_equipment::Equipment;
126    #[cfg(feature = "inventory")]
127    pub use chunkedge_inventory::{
128        CursorItem, Inventory, InventoryKind, InventoryWindow, InventoryWindowMut, OpenInventory,
129    };
130    #[cfg(feature = "network")]
131    pub use chunkedge_network::{
132        ConnectionMode, ErasedNetworkCallbacks, NetworkCallbacks, NetworkSettings, NewClientInfo,
133        SharedNetworkState,
134    };
135    #[cfg(feature = "player_list")]
136    pub use chunkedge_player_list::{PlayerList, PlayerListEntry};
137    pub use chunkedge_registry::biome::{Biome, BiomeId, BiomeRegistry};
138    pub use chunkedge_registry::dimension_type::{DimensionType, DimensionTypeRegistry};
139    pub use chunkedge_server::action::{DiggingMessage, DiggingState};
140    pub use chunkedge_server::block::{BlockKind, BlockState, PropName, PropValue};
141    pub use chunkedge_server::client::{
142        Client, Ip, OldView, OldViewDistance, Properties, Username, View, ViewDistance,
143        VisibleChunkLayer, VisibleEntityLayers, despawn_disconnected_clients,
144    };
145    pub use chunkedge_server::client_command::{
146        JumpWithHorseMessage, JumpWithHorseState, LeaveBedMessage, PlayerCommand, SneakMessage,
147        SneakState, SprintMessage, SprintState,
148    };
149    pub use chunkedge_server::entity::hitbox::{Hitbox, HitboxShape};
150    pub use chunkedge_server::entity::{
151        EntityAnimation, EntityKind, EntityLayerId, EntityManager, EntityStatus, HeadYaw, Look,
152        OldEntityLayerId, OldPosition, Position,
153    };
154    pub use chunkedge_server::event_loop::{
155        EventLoopPostUpdate, EventLoopPreUpdate, EventLoopUpdate,
156    };
157    pub use chunkedge_server::ident::Ident;
158    pub use chunkedge_server::interact_entity::{EntityInteraction, InteractEntityMessage};
159    pub use chunkedge_server::layer::chunk::{
160        Block, BlockRef, Chunk, ChunkLayer, LoadedChunk, UnloadedChunk,
161    };
162    pub use chunkedge_server::layer::{EntityLayer, LayerBundle};
163    pub use chunkedge_server::math::{DVec2, DVec3, Vec2, Vec3};
164    pub use chunkedge_server::message::SendMessage as _;
165    pub use chunkedge_server::nbt::Compound;
166    pub use chunkedge_server::passenger::{Passengers, Riding};
167    pub use chunkedge_server::protocol::RegistryId;
168    pub use chunkedge_server::protocol::packets::play::level_particles_s2c::Particle;
169    pub use chunkedge_server::protocol::text::{Color, IntoText, Text};
170    pub use chunkedge_server::spawn::{
171        ClientSpawnQuery, ClientSpawnQueryReadOnly, RespawnPosition,
172    };
173    pub use chunkedge_server::title::SetTitle as _;
174    pub use chunkedge_server::{
175        BlockPos, ChunkPos, ChunkView, Despawned, Direction, GameMode, Hand, ItemKind, ItemStack,
176        Server, UniqueId, ident,
177    };
178    pub use uuid::Uuid;
179
180    pub use super::DefaultPlugins;
181}
182
183/// This plugin group will add all the default plugins for a ChunkEdge
184/// application.
185///
186/// [`DefaultPlugins`] obeys Cargo feature flags. Users may exert control over
187/// this plugin group by disabling `default-features` in their `Cargo.toml` and
188/// enabling only those features that they wish to use.
189pub struct DefaultPlugins;
190
191impl PluginGroup for DefaultPlugins {
192    fn build(self) -> PluginGroupBuilder {
193        #[allow(unused_mut)]
194        let mut group = PluginGroupBuilder::start::<Self>()
195            .add(ServerPlugin)
196            .add(RegistryPlugin)
197            .add(BiomePlugin)
198            .add(DimensionTypePlugin)
199            .add(EntityPlugin)
200            .add(HitboxPlugin)
201            .add(LayerPlugin)
202            .add(ClientPlugin)
203            .add(EventLoopPlugin)
204            .add(MovementPlugin)
205            .add(ClientCommandPlugin)
206            .add(KeepalivePlugin)
207            .add(InteractEntityPlugin)
208            .add(PassengerPlugin)
209            .add(ClientSettingsPlugin)
210            .add(ActionPlugin)
211            .add(TeleportPlugin)
212            .add(MessagePlugin)
213            .add(CustomPayloadPlugin)
214            .add(HandSwingPlugin)
215            .add(InteractBlockPlugin)
216            .add(InteractItemPlugin)
217            .add(OpLevelPlugin)
218            .add(ResourcePackPlugin)
219            .add(StatusPlugin)
220            .add(StatusEffectPlugin)
221            .add(AbilitiesPlugin);
222
223        #[cfg(feature = "log")]
224        {
225            group = group.add(bevy_log::LogPlugin::default())
226        }
227
228        #[cfg(feature = "network")]
229        {
230            group = group.add(chunkedge_network::NetworkPlugin)
231        }
232
233        #[cfg(feature = "player_list")]
234        {
235            group = group.add(chunkedge_player_list::PlayerListPlugin)
236        }
237
238        #[cfg(feature = "equipment")]
239        {
240            group = group.add(chunkedge_equipment::EquipmentPlugin)
241        }
242
243        #[cfg(feature = "inventory")]
244        {
245            group = group.add(chunkedge_inventory::InventoryPlugin)
246        }
247
248        #[cfg(feature = "anvil")]
249        {
250            group = group.add(chunkedge_anvil::AnvilPlugin)
251        }
252
253        #[cfg(feature = "advancement")]
254        {
255            group = group.add(chunkedge_advancement::AdvancementPlugin)
256        }
257
258        #[cfg(feature = "weather")]
259        {
260            group = group.add(chunkedge_weather::WeatherPlugin)
261        }
262
263        #[cfg(feature = "world_border")]
264        {
265            group = group.add(chunkedge_world_border::WorldBorderPlugin)
266        }
267
268        #[cfg(feature = "boss_bar")]
269        {
270            group = group.add(chunkedge_boss_bar::BossBarPlugin)
271        }
272
273        #[cfg(feature = "command")]
274        {
275            group = group.add(chunkedge_command::manager::CommandPlugin)
276        }
277
278        #[cfg(feature = "scoreboard")]
279        {
280            group = group.add(chunkedge_scoreboard::ScoreboardPlugin)
281        }
282
283        group
284    }
285}