Expand description
§chunkedge_equipment
Manages Minecraft’s entity equipment (armor, held items) via the Equipment component.
By default this is separated from an entities Inventory (which means that changes are only visible to other players), but it can be synced by attaching the EquipmentInventorySync
component to a entity (currently only Players).
§Example
use bevy_ecs::prelude::*;
use chunkedge_equipment::*;
use chunkedge_server::{
ItemStack, ItemKind,
entity::player::PlayerEntity,
};
// Add equipment to players when they are added to the world.
fn init_equipment(
mut clients: Query<
&mut Equipment,
(
Added<Equipment>,
With<PlayerEntity>,
),
>,
) {
for mut equipment in &mut clients
{
equipment.set_main_hand(ItemStack::new(ItemKind::DiamondSword, 1));
equipment.set_off_hand(ItemStack::new(ItemKind::Shield, 1));
equipment.set_feet(ItemStack::new(ItemKind::DiamondBoots, 1));
equipment.set_legs(ItemStack::new(ItemKind::DiamondLeggings, 1));
equipment.set_chest(ItemStack::new(ItemKind::DiamondChestplate, 1));
equipment.set_head(ItemStack::new(ItemKind::DiamondHelmet, 1));
}
}§See also
Examples related to inventories in the chunkedge/examples/ directory:
equipment
Structs§
- Equipment
- Contains the visible equipment of a [
LivingEntity], such as armor and held items. By default this is not synced with a player’s [chunkedge_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 theEquipmentInventorySynccomponent to the player entity to sync the equipment with the inventory. - Equipment
Change Event - Equipment
Interaction Broadcast - This component will broadcast item interactions (e.g. drawing a bow, eating
food) to other players using
LivingFlags::set_using_item. - Equipment
Inventory Sync - This component will sync a player’s
Equipment, which is visible to other players, with the player [Inventory]. - Equipment
Plugin - Equipment
Slot Change