Module prelude

Source
Expand description

Contains the most frequently used items in Valence projects.

This is usually glob imported like so:

use valence::prelude::*; // Glob import.

let mut app = App::empty();
app.add_systems(Update, || println!("yippee!"));
app.update()
// ...

Re-exports§

pub use valence_server::message::SendMessage as _;
pub use valence_server::title::SetTitle as _;
pub use super::DefaultPlugins;
pub use bevy_ecs;
pub use valence_server::ident;

Macros§

ident
Creates a new Ident at compile time from a string literal. A compile error is raised if the string is not a valid resource identifier.

Structs§

Added
A filter on a component that only retains results the first time after they have been added.
Advancement
Advancement’s id. May not be updated.
AdvancementBundle
Components for advancement that are required Optional components: AdvancementDisplay [Parent] - parent advancement
AdvancementClientUpdate
AdvancementCriteria
Criteria’s identifier. May not be updated
AdvancementDisplay
Advancement display. Optional component
AdvancementRequirements
Requirements for advancement to be completed. All columns should be completed, column is completed when any of criteria in this column is completed.
AdvancementTabChangeEvent
This event sends when the client changes or closes advancement’s tab.
AnyOf
The AnyOf query parameter fetches entities with any of the component types included in T.
App
App is the primary API for writing user applications. It automates the setup of a standard lifecycle and provides interface glue for plugins.
AppTypeRegistry
A Resource storing [TypeRegistry] for type registrations relevant to a whole app.
Biome
BiomeId
BiomeRegistry
Block
Represents a complete block, which is a pair of block state and optional NBT data for the block entity.
BlockPos
Represents an absolute block position in world space.
BlockRef
Like Block, but immutably referenced.
BlockState
Represents the state of a block. This does not include block entity data such as the text on a sign, the design on a banner, or the content of a spawner.
Changed
A filter on a component that only retains results the first time after they have been added or mutably dereferenced.
ChunkLayer
A Component containing the chunks and dimension information of a Minecraft world.
ChunkPos
The X and Z position of a chunk.
ChunkView
Represents the set of all chunk positions that a client can see, defined by a center chunk position pos and view distance dist.
Client
The main client component. Contains the underlying network connection and packet buffer.
ClientSpawnQuery
A convenient QueryData for obtaining client spawn components. Also see ClientSpawnQueryReadOnly.
ClientSpawnQueryReadOnly
Automatically generated [WorldQuery] type for a read-only variant of ClientSpawnQuery.
Commands
A Command queue to perform structural changes to the World.
Compound
A map type with String keys and Value values.
CursorItem
The item stack that the client thinks it’s holding under the mouse cursor.
DVec2
A 2-dimensional vector.
DVec3
A 3-dimensional vector.
Deferred
A SystemParam that stores a buffer which gets applied to the World during apply_deferred. This is used internally by Commands to defer World mutations.
Despawned
A marker Component for entities that should be despawned at the end of the tick.
DiggingEvent
DimensionType
DimensionTypeRegistry
Entity
Lightweight identifier of an entity.
EntityKind
Identifies the type of an entity. As a component, the entity kind should not be modified.
EntityLayer
A Component containing Minecraft entities.
EntityLayerId
Contains the entity layer an entity is on.
EntityManager
A Resource which maintains information about all spawned Minecraft entities.
EntityMut
Provides mutable access to a single entity and all of its components.
EntityRef
A read-only reference to a particular Entity and all of its components.
EntityWorldMut
A mutable reference to a particular Entity, and the entire world. This is essentially a performance-optimized (Entity, &mut World) tuple, which caches the EntityLocation to reduce duplicate lookups.
Equipment
Contains the visible equipment of a LivingEntity, such as armor and held items. By default this is not synced with a player’s valence_inventory::Inventory, so the armor the player has equipped in their inventory, will not be visible by other players. You would have to change the equipment in this component here or attach the EquipmentInventorySync component to the player entity to sync the equipment with the inventory.
ErasedNetworkCallbacks
A type-erased wrapper around an NetworkCallbacks object.
EventLoopPostUpdate
EventLoopPreUpdate
EventLoopUpdate
EventReader
Reads events of type T in order and tracks which events have already been read.
EventWriter
Sends events of type T.
Events
An event collection that represents the events that occurred within the last two Events::update calls. Events can be written to using an EventWriter and are typically cheaply read using an EventReader.
First
Runs first in the schedule.
FixedFirst
Runs first in the FixedMain schedule.
FixedLast
The schedule that runs last in FixedMain
FixedPostUpdate
The schedule that runs after the FixedUpdate schedule, for reacting to changes made in the main update logic.
FixedPreUpdate
The schedule that contains logic that must run before FixedUpdate.
FixedUpdate
The schedule that contains most gameplay logic.
Has
Returns a bool that describes if an entity has the component T.
HeadYaw
Hitbox
Hitbox, aabb of which is calculated each tick using its position and Hitbox. In order to change size of this hitbox you need to change Hitbox.
HitboxShape
Size of hitbox. The only way to manipulate it without losing it on the next tick is using a marker entity. Marker entity’s hitbox is never updated.
Ident
A wrapper around a string type S which guarantees the wrapped string is a valid resource identifier.
In
Wrapper type to mark a SystemParam as an input.
InteractEntityEvent
Inventory
InventoryWindow
A helper to represent the inventory window that the player is currently viewing. Handles dispatching reads to the correct inventory.
InventoryWindowMut
A helper to represent the inventory window that the player is currently viewing. Handles dispatching reads/writes to the correct inventory.
Ip
ItemStack
A stack of items in an inventory.
JumpWithHorseEvent
Last
Runs last in the schedule.
LayerBundle
Convenience Bundle for spawning a layer entity with both ChunkLayer and EntityLayer components.
LeaveBedEvent
LoadedChunk
Local
A system local SystemParam.
Look
Describes the direction an entity is looking using pitch and yaw angles.
Main
The schedule that contains the app logic that is evaluated each tick of App::update().
Mut
Unique mutable borrow of an entity’s component or of a resource.
NetworkSettings
Settings for NetworkPlugin. Note that mutations to these fields have no effect after the plugin is built.
NewClientInfo
Contains information about a new client joining the server.
NonSend
Shared borrow of a non-Send resource.
NonSendMut
Unique borrow of a non-Send resource.
Observer
An Observer system. Add this Component to an Entity to turn it into an “observer”.
OldEntityLayerId
The value of EntityLayerId from the end of the previous tick.
OldPosition
The value of Position from the end of the previous tick.
OldView
OldViewDistance
The ViewDistance at the end of the previous tick. Automatically updated as ViewDistance is changed.
OnAdd
Trigger emitted when a component is added to an entity.
OnInsert
Trigger emitted when a component is inserted on to to an entity.
OnRemove
Trigger emitted when a component is removed from an entity.
OpenInventory
Used to indicate that the client with this component is currently viewing an inventory.
Or
A filter that tests if any of the given filters apply.
ParallelCommands
An alternative to Commands that can be used in parallel contexts, such as those in Query::par_iter
ParamSet
A collection of potentially conflicting SystemParams allowed by disjoint access.
PlayerList
PlayerListEntry
Marker component for player list entries.
Position
PostStartup
The schedule that runs once after Startup.
PostUpdate
The schedule that contains logic that must run after Update. For example, synchronizing “local transforms” in a hierarchy to “global” absolute transforms. This enables the PostUpdate transform-sync system to react to “local transform” changes in Update without the Update systems needing to know about (or add scheduler dependencies for) the “global transform sync system”.
PreStartup
The schedule that runs before Startup.
PreUpdate
The schedule that contains logic that must run before Update. For example, a system that reads raw keyboard input OS events into an Events resource. This enables systems in Update to consume the events from the Events resource without actually knowing about (or taking a direct scheduler dependency on) the “os-level keyboard event system”.
Properties
Player properties from the game profile.
Query
System parameter that provides selective access to the Component data stored in a World.
QueryBuilder
Builder struct to create QueryState instances at runtime.
QueryState
Provides scoped access to a World state according to a given QueryData and QueryFilter.
Ref
Shared borrow of an entity’s component with access to change detection. Similar to Mut but is immutable and so doesn’t require unique access.
ReflectComponent
A struct used to operate on reflected Component trait of a type.
ReflectFromWorld
A struct used to operate on the reflected FromWorld trait of a type.
ReflectResource
A struct used to operate on reflected Resource of a type.
RemovedComponents
A SystemParam that yields entities that had their T Component removed or have been despawned with it.
Res
Shared borrow of a Resource.
ResMut
Unique mutable borrow of a Resource.
RespawnPosition
The position and angle that clients will respawn with. Also controls the position that compasses point towards.
Schedule
A collection of systems, and the metadata and executor needed to run them in a certain order under certain conditions.
Schedules
Resource that stores Schedules mapped to ScheduleLabels excluding the current running Schedule.
Server
Contains global server state accessible as a Resource.
SharedNetworkState
SneakEvent
SpawnScene
The schedule that contains scene spawning.
SprintEvent
Startup
The schedule that runs once when the app starts.
SubApp
A secondary application with its own World. These can run independently of each other.
SystemBuilder
Builder struct used to construct state for SystemParam passed to a system.
Text
Represents formatted text in Minecraft’s JSON text format.
Trigger
Type containing triggered Event information for a given run of an Observer. This contains the Event data itself. If it was triggered for a specific Entity, it includes that as well.
UniqueId
The universally unique identifier of an entity. Component wrapper for a Uuid.
UnloadedChunk
Update
The schedule that contains app logic. Ideally containing anything that must run once per render frame, such as UI.
Username
Uuid
A Universally Unique Identifier (UUID).
Vec2
A 2-dimensional vector.
Vec3
A 3-dimensional vector.
View
ViewDistance
VisibleChunkLayer
A Component containing a handle to the ChunkLayer a client can see.
VisibleEntityLayers
A Component containing the set of EntityLayers a client can see. All Minecraft entities from all layers in this set are potentially visible to the client.
With
Filter that selects entities with a component T.
Without
Filter that selects entities without a component T.
World
Stores and exposes operations on entities, components, resources, and their associated metadata.

Enums§

AdvancementFrameType
AppExit
An event that indicates the App should exit. If one or more of these are present at the end of an update, the runner will end and (maybe) return control to the caller.
BlockKind
An enumeration of all block kinds.
ClientCommand
Color
Text color
ConnectionMode
Describes how new connections to the server are handled.
DiggingState
Direction
EntityAnimation
EntityInteraction
EntityStatus
GameMode
Hand
InventoryKind
ItemKind
Represents an item from the game
JumpWithHorseState
Particle
PropName
Contains all possible block state property names.
PropValue
Contains all possible values that a block property might have.
ShouldUpdateEvents
Controls whether or not the events in an EventRegistry should be updated.
SneakState
SprintState

Traits§

Bundle
The Bundle trait enables insertion and removal of Components from an entity.
Chunk
Common operations on chunks. Notable implementors are LoadedChunk and UnloadedChunk.
Component
A data type that can be used to store data for an entity.
Condition
A system that determines if one or more scheduled systems should run.
DetectChanges
Types that can read change detection information. This change detection is controlled by DetectChangesMut types such as ResMut.
DetectChangesMut
Types that implement reliable change detection.
EntityMapper
An implementor of this trait knows how to map an Entity into another Entity.
Event
Something that “happens” and might be read / observed by app logic.
FromWorld
Creates an instance of the type this trait is implemented for using data from the supplied World.
IntoSystem
Conversion trait to turn something into a System.
IntoSystemConfigs
Types that can convert into a SystemConfigs.
IntoSystemSet
Types that can be converted into a SystemSet.
IntoSystemSetConfigs
Types that can convert into a SystemSetConfigs.
IntoText
Trait for any data that can be converted to a Text object.
NetworkCallbacks
This trait uses async_trait.
Plugin
A collection of Bevy app logic and configuration.
PluginGroup
Combines multiple Plugins into a single unit.
ReadOnlySystem
System types that do not modify the World when run. This is implemented for any systems whose parameters all implement ReadOnlySystemParam.
Resource
A type that can be inserted into a World as a singleton.
System
An ECS system that can be added to a Schedule
SystemParamFunction
A trait implemented for all functions that can be used as Systems.
SystemSet
Types that identify logical groups of systems.

Functions§

any_component_removed
Generates a Condition-satisfying closure that returns true if there are any entity with a component of the given type removed.
any_with_component
A Condition-satisfying system that returns true if there are any entities with the given component type.
apply_deferred
Instructs the executor to call System::apply_deferred on the systems that have run but not applied their Deferred system parameters (like Commands) or other system buffers.
despawn_disconnected_clients
A system for adding Despawned components to disconnected clients. This works by listening for removed Client components.
not
Generates a Condition that inverses the result of passed one.
on_event
Generates a Condition-satisfying closure that returns true if there are any new events of the given type since it was last called.
resource_added
A Condition-satisfying system that returns true if the resource of the given type has been added since the condition was last checked.
resource_changed
A Condition-satisfying system that returns true if the resource of the given type has had its value changed since the condition was last checked.
resource_changed_or_removed
Generates a Condition-satisfying closure that returns true if the resource of the given type has had its value changed since the condition was last checked.
resource_equals
Generates a Condition-satisfying closure that returns true if the resource is equal to value.
resource_exists
A Condition-satisfying system that returns true if the resource exists.
resource_exists_and_changed
A Condition-satisfying system that returns true if the resource of the given type has had its value changed since the condition was last checked.
resource_exists_and_equals
Generates a Condition-satisfying closure that returns true if the resource exists and is equal to value.
resource_removed
Generates a Condition-satisfying closure that returns true if the resource of the given type has been removed since the condition was last checked.
run_once
Generates a Condition-satisfying closure that returns true if the first time the condition is run and false every time after

Derive Macros§

Bundle
Component
DynamicPlugin
Generates a dynamic plugin entry point function for the given Plugin type.
Event
Resource
SystemSet
Derive macro generating an impl of the trait SystemSet.