mirror of
https://github.com/mat-1/azalea.git
synced 2025-08-02 14:26:04 +00:00
ItemSlot -> ItemStack for more consistency with mojmap
This commit is contained in:
parent
4dcd95e182
commit
eabb329085
30 changed files with 180 additions and 180 deletions
|
@ -10,7 +10,7 @@ use azalea_core::{
|
||||||
use azalea_entity::{
|
use azalea_entity::{
|
||||||
clamp_look_direction, view_vector, Attributes, EyeHeight, LocalEntity, LookDirection, Position,
|
clamp_look_direction, view_vector, Attributes, EyeHeight, LocalEntity, LookDirection, Position,
|
||||||
};
|
};
|
||||||
use azalea_inventory::{ItemSlot, ItemSlotData};
|
use azalea_inventory::{ItemStack, ItemStackData};
|
||||||
use azalea_physics::clip::{BlockShapeType, ClipContext, FluidPickType};
|
use azalea_physics::clip::{BlockShapeType, ClipContext, FluidPickType};
|
||||||
use azalea_protocol::packets::game::{
|
use azalea_protocol::packets::game::{
|
||||||
s_interact::InteractionHand,
|
s_interact::InteractionHand,
|
||||||
|
@ -245,7 +245,7 @@ pub fn check_is_interaction_restricted(
|
||||||
// way of modifying that
|
// way of modifying that
|
||||||
|
|
||||||
let held_item = inventory.held_item();
|
let held_item = inventory.held_item();
|
||||||
if let ItemSlot::Present(item) = &held_item {
|
if let ItemStack::Present(item) = &held_item {
|
||||||
let block = instance.chunks.get_block_state(block_pos);
|
let block = instance.chunks.get_block_state(block_pos);
|
||||||
let Some(block) = block else {
|
let Some(block) = block else {
|
||||||
// block isn't loaded so just say that it is restricted
|
// block isn't loaded so just say that it is restricted
|
||||||
|
@ -263,7 +263,7 @@ pub fn check_is_interaction_restricted(
|
||||||
|
|
||||||
/// Check if the item has the `CanDestroy` tag for the block.
|
/// Check if the item has the `CanDestroy` tag for the block.
|
||||||
pub fn check_block_can_be_broken_by_item_in_adventure_mode(
|
pub fn check_block_can_be_broken_by_item_in_adventure_mode(
|
||||||
item: &ItemSlotData,
|
item: &ItemStackData,
|
||||||
_block: &BlockState,
|
_block: &BlockState,
|
||||||
) -> bool {
|
) -> bool {
|
||||||
// minecraft caches the last checked block but that's kind of an unnecessary
|
// minecraft caches the last checked block but that's kind of an unnecessary
|
||||||
|
|
|
@ -97,7 +97,7 @@ pub struct Inventory {
|
||||||
///
|
///
|
||||||
/// This is different from [`Self::selected_hotbar_slot`], which is the
|
/// This is different from [`Self::selected_hotbar_slot`], which is the
|
||||||
/// item that's selected in the hotbar.
|
/// item that's selected in the hotbar.
|
||||||
pub carried: ItemSlot,
|
pub carried: ItemStack,
|
||||||
/// An identifier used by the server to track client inventory desyncs. This
|
/// An identifier used by the server to track client inventory desyncs. This
|
||||||
/// is sent on every container click, and it's only ever updated when the
|
/// is sent on every container click, and it's only ever updated when the
|
||||||
/// server sends a new container update.
|
/// server sends a new container update.
|
||||||
|
@ -182,7 +182,7 @@ impl Inventory {
|
||||||
if let QuickCraftStatus::Add { slot } = quick_craft.status {
|
if let QuickCraftStatus::Add { slot } = quick_craft.status {
|
||||||
let slot_item = self.menu().slot(slot as usize);
|
let slot_item = self.menu().slot(slot as usize);
|
||||||
if let Some(slot_item) = slot_item {
|
if let Some(slot_item) = slot_item {
|
||||||
if let ItemSlot::Present(carried) = &self.carried {
|
if let ItemStack::Present(carried) = &self.carried {
|
||||||
// minecraft also checks slot.may_place(carried) and
|
// minecraft also checks slot.may_place(carried) and
|
||||||
// menu.can_drag_to(slot)
|
// menu.can_drag_to(slot)
|
||||||
// but they always return true so they're not relevant for us
|
// but they always return true so they're not relevant for us
|
||||||
|
@ -221,7 +221,7 @@ impl Inventory {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let ItemSlot::Present(mut carried) = self.carried.clone() else {
|
let ItemStack::Present(mut carried) = self.carried.clone() else {
|
||||||
// this should never happen
|
// this should never happen
|
||||||
return self.reset_quick_craft();
|
return self.reset_quick_craft();
|
||||||
};
|
};
|
||||||
|
@ -230,14 +230,14 @@ impl Inventory {
|
||||||
let mut quick_craft_slots_iter = self.quick_craft_slots.iter();
|
let mut quick_craft_slots_iter = self.quick_craft_slots.iter();
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
let mut slot: &ItemSlot;
|
let mut slot: &ItemStack;
|
||||||
let mut slot_index: u16;
|
let mut slot_index: u16;
|
||||||
let mut item_stack: &ItemSlot;
|
let mut item_stack: &ItemStack;
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
let Some(&next_slot) = quick_craft_slots_iter.next() else {
|
let Some(&next_slot) = quick_craft_slots_iter.next() else {
|
||||||
carried.count = carried_count;
|
carried.count = carried_count;
|
||||||
self.carried = ItemSlot::Present(carried);
|
self.carried = ItemStack::Present(carried);
|
||||||
return self.reset_quick_craft();
|
return self.reset_quick_craft();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -258,8 +258,8 @@ impl Inventory {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// get the ItemSlotData for the slot
|
// get the ItemStackData for the slot
|
||||||
let ItemSlot::Present(slot) = slot else {
|
let ItemStack::Present(slot) = slot else {
|
||||||
unreachable!("the loop above requires the slot to be present to break")
|
unreachable!("the loop above requires the slot to be present to break")
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -292,7 +292,7 @@ impl Inventory {
|
||||||
&mut self.inventory_menu
|
&mut self.inventory_menu
|
||||||
};
|
};
|
||||||
*menu.slot_mut(slot_index as usize).unwrap() =
|
*menu.slot_mut(slot_index as usize).unwrap() =
|
||||||
ItemSlot::Present(new_carried);
|
ItemStack::Present(new_carried);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -315,7 +315,7 @@ impl Inventory {
|
||||||
// implementation
|
// implementation
|
||||||
|
|
||||||
// player.drop(self.carried, true);
|
// player.drop(self.carried, true);
|
||||||
self.carried = ItemSlot::Empty;
|
self.carried = ItemStack::Empty;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ClickOperation::Pickup(PickupClick::Right { slot: None }) => {
|
ClickOperation::Pickup(PickupClick::Right { slot: None }) => {
|
||||||
|
@ -335,8 +335,8 @@ impl Inventory {
|
||||||
// here
|
// here
|
||||||
// i don't understand it so i didn't implement it
|
// i don't understand it so i didn't implement it
|
||||||
match slot_item {
|
match slot_item {
|
||||||
ItemSlot::Empty => if carried.is_present() {},
|
ItemStack::Empty => if carried.is_present() {},
|
||||||
ItemSlot::Present(_) => todo!(),
|
ItemStack::Present(_) => todo!(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ClickOperation::QuickMove(
|
ClickOperation::QuickMove(
|
||||||
|
@ -373,7 +373,7 @@ impl Inventory {
|
||||||
*target_slot = source_slot;
|
*target_slot = source_slot;
|
||||||
}
|
}
|
||||||
} else if source_slot.is_empty() {
|
} else if source_slot.is_empty() {
|
||||||
let ItemSlot::Present(target_item) = target_slot else {
|
let ItemStack::Present(target_item) = target_slot else {
|
||||||
unreachable!("target slot is not empty but is not present");
|
unreachable!("target slot is not empty but is not present");
|
||||||
};
|
};
|
||||||
if self.menu().may_place(source_slot_index, target_item) {
|
if self.menu().may_place(source_slot_index, target_item) {
|
||||||
|
@ -385,7 +385,7 @@ impl Inventory {
|
||||||
*self.menu_mut().slot_mut(source_slot_index).unwrap() = new_source_slot;
|
*self.menu_mut().slot_mut(source_slot_index).unwrap() = new_source_slot;
|
||||||
}
|
}
|
||||||
} else if self.menu().may_pickup(source_slot_index) {
|
} else if self.menu().may_pickup(source_slot_index) {
|
||||||
let ItemSlot::Present(target_item) = target_slot else {
|
let ItemStack::Present(target_item) = target_slot else {
|
||||||
unreachable!("target slot is not empty but is not present");
|
unreachable!("target slot is not empty but is not present");
|
||||||
};
|
};
|
||||||
if self.menu().may_place(source_slot_index, target_item) {
|
if self.menu().may_place(source_slot_index, target_item) {
|
||||||
|
@ -420,12 +420,12 @@ impl Inventory {
|
||||||
let Some(source_slot) = self.menu().slot(*slot as usize) else {
|
let Some(source_slot) = self.menu().slot(*slot as usize) else {
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
let ItemSlot::Present(source_item) = source_slot else {
|
let ItemStack::Present(source_item) = source_slot else {
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
let mut new_carried = source_item.clone();
|
let mut new_carried = source_item.clone();
|
||||||
new_carried.count = new_carried.kind.max_stack_size();
|
new_carried.count = new_carried.kind.max_stack_size();
|
||||||
self.carried = ItemSlot::Present(new_carried);
|
self.carried = ItemStack::Present(new_carried);
|
||||||
}
|
}
|
||||||
ClickOperation::Throw(c) => {
|
ClickOperation::Throw(c) => {
|
||||||
if self.carried.is_present() {
|
if self.carried.is_present() {
|
||||||
|
@ -439,7 +439,7 @@ impl Inventory {
|
||||||
let Some(slot) = self.menu_mut().slot_mut(slot_index) else {
|
let Some(slot) = self.menu_mut().slot_mut(slot_index) else {
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
let ItemSlot::Present(slot_item) = slot else {
|
let ItemStack::Present(slot_item) = slot else {
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -466,7 +466,7 @@ impl Inventory {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let ItemSlot::Present(target_slot_item) = &target_slot else {
|
let ItemStack::Present(target_slot_item) = &target_slot else {
|
||||||
unreachable!("target slot is not empty but is not present");
|
unreachable!("target slot is not empty but is not present");
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -480,7 +480,7 @@ impl Inventory {
|
||||||
for i in iterator {
|
for i in iterator {
|
||||||
if target_slot_item.count < target_slot_item.kind.max_stack_size() {
|
if target_slot_item.count < target_slot_item.kind.max_stack_size() {
|
||||||
let checking_slot = self.menu().slot(i).unwrap();
|
let checking_slot = self.menu().slot(i).unwrap();
|
||||||
if let ItemSlot::Present(checking_item) = checking_slot {
|
if let ItemStack::Present(checking_item) = checking_slot {
|
||||||
if can_item_quick_replace(checking_slot, &target_slot, true)
|
if can_item_quick_replace(checking_slot, &target_slot, true)
|
||||||
&& self.menu().may_pickup(i)
|
&& self.menu().may_pickup(i)
|
||||||
&& (round != 0
|
&& (round != 0
|
||||||
|
@ -495,7 +495,7 @@ impl Inventory {
|
||||||
|
|
||||||
// now extend the carried item
|
// now extend the carried item
|
||||||
let target_slot = &mut self.carried;
|
let target_slot = &mut self.carried;
|
||||||
let ItemSlot::Present(target_slot_item) = target_slot else {
|
let ItemStack::Present(target_slot_item) = target_slot else {
|
||||||
unreachable!("target slot is not empty but is not present");
|
unreachable!("target slot is not empty but is not present");
|
||||||
};
|
};
|
||||||
target_slot_item.count += taken_item.count();
|
target_slot_item.count += taken_item.count();
|
||||||
|
@ -515,7 +515,7 @@ impl Inventory {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get the item in the player's hotbar that is currently being held.
|
/// Get the item in the player's hotbar that is currently being held.
|
||||||
pub fn held_item(&self) -> ItemSlot {
|
pub fn held_item(&self) -> ItemStack {
|
||||||
let inventory = &self.inventory_menu;
|
let inventory = &self.inventory_menu;
|
||||||
let hotbar_items = &inventory.slots()[inventory.hotbar_slots_range()];
|
let hotbar_items = &inventory.slots()[inventory.hotbar_slots_range()];
|
||||||
hotbar_items[self.selected_hotbar_slot as usize].clone()
|
hotbar_items[self.selected_hotbar_slot as usize].clone()
|
||||||
|
@ -523,14 +523,14 @@ impl Inventory {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn can_item_quick_replace(
|
fn can_item_quick_replace(
|
||||||
target_slot: &ItemSlot,
|
target_slot: &ItemStack,
|
||||||
item: &ItemSlot,
|
item: &ItemStack,
|
||||||
ignore_item_count: bool,
|
ignore_item_count: bool,
|
||||||
) -> bool {
|
) -> bool {
|
||||||
let ItemSlot::Present(target_slot) = target_slot else {
|
let ItemStack::Present(target_slot) = target_slot else {
|
||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
let ItemSlot::Present(item) = item else {
|
let ItemStack::Present(item) = item else {
|
||||||
// i *think* this is what vanilla does
|
// i *think* this is what vanilla does
|
||||||
// not 100% sure lol probably doesn't matter though
|
// not 100% sure lol probably doesn't matter though
|
||||||
return false;
|
return false;
|
||||||
|
@ -551,7 +551,7 @@ fn can_item_quick_replace(
|
||||||
fn get_quick_craft_slot_count(
|
fn get_quick_craft_slot_count(
|
||||||
quick_craft_slots: &HashSet<u16>,
|
quick_craft_slots: &HashSet<u16>,
|
||||||
quick_craft_kind: &QuickCraftKind,
|
quick_craft_kind: &QuickCraftKind,
|
||||||
item: &mut ItemSlotData,
|
item: &mut ItemStackData,
|
||||||
slot_item_count: i32,
|
slot_item_count: i32,
|
||||||
) {
|
) {
|
||||||
item.count = match quick_craft_kind {
|
item.count = match quick_craft_kind {
|
||||||
|
@ -569,7 +569,7 @@ impl Default for Inventory {
|
||||||
id: 0,
|
id: 0,
|
||||||
container_menu: None,
|
container_menu: None,
|
||||||
container_menu_title: None,
|
container_menu_title: None,
|
||||||
carried: ItemSlot::Empty,
|
carried: ItemStack::Empty,
|
||||||
state_id: 0,
|
state_id: 0,
|
||||||
quick_craft_status: QuickCraftStatusKind::Start,
|
quick_craft_status: QuickCraftStatusKind::Start,
|
||||||
quick_craft_kind: QuickCraftKind::Middle,
|
quick_craft_kind: QuickCraftKind::Middle,
|
||||||
|
@ -687,7 +687,7 @@ pub fn handle_container_click_event(
|
||||||
|
|
||||||
// see which slots changed after clicking and put them in the hashmap
|
// see which slots changed after clicking and put them in the hashmap
|
||||||
// the server uses this to check if we desynced
|
// the server uses this to check if we desynced
|
||||||
let mut changed_slots: HashMap<u16, ItemSlot> = HashMap::new();
|
let mut changed_slots: HashMap<u16, ItemStack> = HashMap::new();
|
||||||
for (slot_index, old_slot) in old_slots.iter().enumerate() {
|
for (slot_index, old_slot) in old_slots.iter().enumerate() {
|
||||||
let new_slot = &menu.slots()[slot_index];
|
let new_slot = &menu.slots()[slot_index];
|
||||||
if old_slot != new_slot {
|
if old_slot != new_slot {
|
||||||
|
@ -716,7 +716,7 @@ pub fn handle_container_click_event(
|
||||||
#[derive(Event)]
|
#[derive(Event)]
|
||||||
pub struct SetContainerContentEvent {
|
pub struct SetContainerContentEvent {
|
||||||
pub entity: Entity,
|
pub entity: Entity,
|
||||||
pub slots: Vec<ItemSlot>,
|
pub slots: Vec<ItemStack>,
|
||||||
pub container_id: u8,
|
pub container_id: u8,
|
||||||
}
|
}
|
||||||
fn handle_set_container_content_event(
|
fn handle_set_container_content_event(
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use azalea_block::{Block, BlockState, FluidState};
|
use azalea_block::{Block, BlockState, FluidState};
|
||||||
use azalea_core::{direction::Direction, game_type::GameMode, position::BlockPos, tick::GameTick};
|
use azalea_core::{direction::Direction, game_type::GameMode, position::BlockPos, tick::GameTick};
|
||||||
use azalea_entity::{mining::get_mine_progress, FluidOnEyes, Physics};
|
use azalea_entity::{mining::get_mine_progress, FluidOnEyes, Physics};
|
||||||
use azalea_inventory::ItemSlot;
|
use azalea_inventory::ItemStack;
|
||||||
use azalea_physics::PhysicsSet;
|
use azalea_physics::PhysicsSet;
|
||||||
use azalea_protocol::packets::game::s_player_action::{self, ServerboundPlayerAction};
|
use azalea_protocol::packets::game::s_player_action::{self, ServerboundPlayerAction};
|
||||||
use azalea_world::{InstanceContainer, InstanceName};
|
use azalea_world::{InstanceContainer, InstanceName};
|
||||||
|
@ -405,9 +405,9 @@ pub struct MineTicks(pub f32);
|
||||||
pub struct MineBlockPos(pub Option<BlockPos>);
|
pub struct MineBlockPos(pub Option<BlockPos>);
|
||||||
|
|
||||||
/// A component that contains the item we're currently using to mine. If we're
|
/// A component that contains the item we're currently using to mine. If we're
|
||||||
/// not mining anything, it'll be [`ItemSlot::Empty`].
|
/// not mining anything, it'll be [`ItemStack::Empty`].
|
||||||
#[derive(Component, Clone, Debug, Default, Deref, DerefMut)]
|
#[derive(Component, Clone, Debug, Default, Deref, DerefMut)]
|
||||||
pub struct MineItem(pub ItemSlot);
|
pub struct MineItem(pub ItemStack);
|
||||||
|
|
||||||
/// Sent when we completed mining a block.
|
/// Sent when we completed mining a block.
|
||||||
#[derive(Event)]
|
#[derive(Event)]
|
||||||
|
|
|
@ -10,7 +10,7 @@ use azalea_core::{
|
||||||
direction::Direction,
|
direction::Direction,
|
||||||
position::{BlockPos, GlobalPos, Vec3},
|
position::{BlockPos, GlobalPos, Vec3},
|
||||||
};
|
};
|
||||||
use azalea_inventory::ItemSlot;
|
use azalea_inventory::ItemStack;
|
||||||
use bevy_ecs::component::Component;
|
use bevy_ecs::component::Component;
|
||||||
use derive_more::Deref;
|
use derive_more::Deref;
|
||||||
use enum_as_inner::EnumAsInner;
|
use enum_as_inner::EnumAsInner;
|
||||||
|
@ -73,7 +73,7 @@ pub enum EntityDataValue {
|
||||||
String(String),
|
String(String),
|
||||||
FormattedText(FormattedText),
|
FormattedText(FormattedText),
|
||||||
OptionalFormattedText(Option<FormattedText>),
|
OptionalFormattedText(Option<FormattedText>),
|
||||||
ItemStack(ItemSlot),
|
ItemStack(ItemStack),
|
||||||
Boolean(bool),
|
Boolean(bool),
|
||||||
Rotations(Rotations),
|
Rotations(Rotations),
|
||||||
BlockPos(BlockPos),
|
BlockPos(BlockPos),
|
||||||
|
|
|
@ -8,7 +8,7 @@ use azalea_core::{
|
||||||
direction::Direction,
|
direction::Direction,
|
||||||
position::{BlockPos, Vec3},
|
position::{BlockPos, Vec3},
|
||||||
};
|
};
|
||||||
use azalea_inventory::ItemSlot;
|
use azalea_inventory::ItemStack;
|
||||||
use bevy_ecs::{bundle::Bundle, component::Component};
|
use bevy_ecs::{bundle::Bundle, component::Component};
|
||||||
use derive_more::{Deref, DerefMut};
|
use derive_more::{Deref, DerefMut};
|
||||||
use thiserror::Error;
|
use thiserror::Error;
|
||||||
|
@ -3242,7 +3242,7 @@ impl Default for DrownedMetadataBundle {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Component, Deref, DerefMut, Clone)]
|
#[derive(Component, Deref, DerefMut, Clone)]
|
||||||
pub struct EggItemStack(pub ItemSlot);
|
pub struct EggItemStack(pub ItemStack);
|
||||||
#[derive(Component)]
|
#[derive(Component)]
|
||||||
pub struct Egg;
|
pub struct Egg;
|
||||||
impl Egg {
|
impl Egg {
|
||||||
|
@ -3499,7 +3499,7 @@ impl Default for EnderDragonMetadataBundle {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Component, Deref, DerefMut, Clone)]
|
#[derive(Component, Deref, DerefMut, Clone)]
|
||||||
pub struct EnderPearlItemStack(pub ItemSlot);
|
pub struct EnderPearlItemStack(pub ItemStack);
|
||||||
#[derive(Component)]
|
#[derive(Component)]
|
||||||
pub struct EnderPearl;
|
pub struct EnderPearl;
|
||||||
impl EnderPearl {
|
impl EnderPearl {
|
||||||
|
@ -3835,7 +3835,7 @@ impl Default for EvokerFangsMetadataBundle {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Component, Deref, DerefMut, Clone)]
|
#[derive(Component, Deref, DerefMut, Clone)]
|
||||||
pub struct ExperienceBottleItemStack(pub ItemSlot);
|
pub struct ExperienceBottleItemStack(pub ItemStack);
|
||||||
#[derive(Component)]
|
#[derive(Component)]
|
||||||
pub struct ExperienceBottle;
|
pub struct ExperienceBottle;
|
||||||
impl ExperienceBottle {
|
impl ExperienceBottle {
|
||||||
|
@ -3932,7 +3932,7 @@ impl Default for ExperienceOrbMetadataBundle {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Component, Deref, DerefMut, Clone)]
|
#[derive(Component, Deref, DerefMut, Clone)]
|
||||||
pub struct EyeOfEnderItemStack(pub ItemSlot);
|
pub struct EyeOfEnderItemStack(pub ItemStack);
|
||||||
#[derive(Component)]
|
#[derive(Component)]
|
||||||
pub struct EyeOfEnder;
|
pub struct EyeOfEnder;
|
||||||
impl EyeOfEnder {
|
impl EyeOfEnder {
|
||||||
|
@ -4036,7 +4036,7 @@ impl Default for FallingBlockMetadataBundle {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Component, Deref, DerefMut, Clone)]
|
#[derive(Component, Deref, DerefMut, Clone)]
|
||||||
pub struct FireballItemStack(pub ItemSlot);
|
pub struct FireballItemStack(pub ItemStack);
|
||||||
#[derive(Component)]
|
#[derive(Component)]
|
||||||
pub struct Fireball;
|
pub struct Fireball;
|
||||||
impl Fireball {
|
impl Fireball {
|
||||||
|
@ -4088,7 +4088,7 @@ impl Default for FireballMetadataBundle {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Component, Deref, DerefMut, Clone)]
|
#[derive(Component, Deref, DerefMut, Clone)]
|
||||||
pub struct FireworksItem(pub ItemSlot);
|
pub struct FireworksItem(pub ItemStack);
|
||||||
#[derive(Component, Deref, DerefMut, Clone)]
|
#[derive(Component, Deref, DerefMut, Clone)]
|
||||||
pub struct AttachedToTarget(pub OptionalUnsignedInt);
|
pub struct AttachedToTarget(pub OptionalUnsignedInt);
|
||||||
#[derive(Component, Deref, DerefMut, Clone)]
|
#[derive(Component, Deref, DerefMut, Clone)]
|
||||||
|
@ -4623,7 +4623,7 @@ impl Default for GiantMetadataBundle {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Component, Deref, DerefMut, Clone)]
|
#[derive(Component, Deref, DerefMut, Clone)]
|
||||||
pub struct ItemFrameItem(pub ItemSlot);
|
pub struct ItemFrameItem(pub ItemStack);
|
||||||
#[derive(Component, Deref, DerefMut, Clone)]
|
#[derive(Component, Deref, DerefMut, Clone)]
|
||||||
pub struct Rotation(pub i32);
|
pub struct Rotation(pub i32);
|
||||||
#[derive(Component)]
|
#[derive(Component)]
|
||||||
|
@ -4669,7 +4669,7 @@ impl Default for GlowItemFrameMetadataBundle {
|
||||||
pose: Pose::default(),
|
pose: Pose::default(),
|
||||||
ticks_frozen: TicksFrozen(Default::default()),
|
ticks_frozen: TicksFrozen(Default::default()),
|
||||||
},
|
},
|
||||||
item_frame_item: ItemFrameItem(ItemSlot::Empty),
|
item_frame_item: ItemFrameItem(ItemStack::Empty),
|
||||||
rotation: Rotation(0),
|
rotation: Rotation(0),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -5462,7 +5462,7 @@ impl Default for IronGolemMetadataBundle {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Component, Deref, DerefMut, Clone)]
|
#[derive(Component, Deref, DerefMut, Clone)]
|
||||||
pub struct ItemItem(pub ItemSlot);
|
pub struct ItemItem(pub ItemStack);
|
||||||
#[derive(Component)]
|
#[derive(Component)]
|
||||||
pub struct Item;
|
pub struct Item;
|
||||||
impl Item {
|
impl Item {
|
||||||
|
@ -5508,7 +5508,7 @@ impl Default for ItemMetadataBundle {
|
||||||
pose: Pose::default(),
|
pose: Pose::default(),
|
||||||
ticks_frozen: TicksFrozen(Default::default()),
|
ticks_frozen: TicksFrozen(Default::default()),
|
||||||
},
|
},
|
||||||
item_item: ItemItem(ItemSlot::Empty),
|
item_item: ItemItem(ItemStack::Empty),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5544,7 +5544,7 @@ pub struct ItemDisplayHeight(pub f32);
|
||||||
#[derive(Component, Deref, DerefMut, Clone)]
|
#[derive(Component, Deref, DerefMut, Clone)]
|
||||||
pub struct ItemDisplayGlowColorOverride(pub i32);
|
pub struct ItemDisplayGlowColorOverride(pub i32);
|
||||||
#[derive(Component, Deref, DerefMut, Clone)]
|
#[derive(Component, Deref, DerefMut, Clone)]
|
||||||
pub struct ItemDisplayItemStack(pub ItemSlot);
|
pub struct ItemDisplayItemStack(pub ItemStack);
|
||||||
#[derive(Component, Deref, DerefMut, Clone)]
|
#[derive(Component, Deref, DerefMut, Clone)]
|
||||||
pub struct ItemDisplayItemDisplay(pub u8);
|
pub struct ItemDisplayItemDisplay(pub u8);
|
||||||
#[derive(Component)]
|
#[derive(Component)]
|
||||||
|
@ -5699,7 +5699,7 @@ impl Default for ItemDisplayMetadataBundle {
|
||||||
item_display_width: ItemDisplayWidth(0.0),
|
item_display_width: ItemDisplayWidth(0.0),
|
||||||
item_display_height: ItemDisplayHeight(0.0),
|
item_display_height: ItemDisplayHeight(0.0),
|
||||||
item_display_glow_color_override: ItemDisplayGlowColorOverride(-1),
|
item_display_glow_color_override: ItemDisplayGlowColorOverride(-1),
|
||||||
item_display_item_stack: ItemDisplayItemStack(ItemSlot::Empty),
|
item_display_item_stack: ItemDisplayItemStack(ItemStack::Empty),
|
||||||
item_display_item_display: ItemDisplayItemDisplay(Default::default()),
|
item_display_item_display: ItemDisplayItemDisplay(Default::default()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5754,7 +5754,7 @@ impl Default for ItemFrameMetadataBundle {
|
||||||
pose: Pose::default(),
|
pose: Pose::default(),
|
||||||
ticks_frozen: TicksFrozen(Default::default()),
|
ticks_frozen: TicksFrozen(Default::default()),
|
||||||
},
|
},
|
||||||
item_frame_item: ItemFrameItem(ItemSlot::Empty),
|
item_frame_item: ItemFrameItem(ItemStack::Empty),
|
||||||
rotation: Rotation(0),
|
rotation: Rotation(0),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6974,7 +6974,7 @@ impl Default for OcelotMetadataBundle {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Component, Deref, DerefMut, Clone)]
|
#[derive(Component, Deref, DerefMut, Clone)]
|
||||||
pub struct OminousItemSpawnerItem(pub ItemSlot);
|
pub struct OminousItemSpawnerItem(pub ItemStack);
|
||||||
#[derive(Component)]
|
#[derive(Component)]
|
||||||
pub struct OminousItemSpawner;
|
pub struct OminousItemSpawner;
|
||||||
impl OminousItemSpawner {
|
impl OminousItemSpawner {
|
||||||
|
@ -7020,7 +7020,7 @@ impl Default for OminousItemSpawnerMetadataBundle {
|
||||||
pose: Pose::default(),
|
pose: Pose::default(),
|
||||||
ticks_frozen: TicksFrozen(Default::default()),
|
ticks_frozen: TicksFrozen(Default::default()),
|
||||||
},
|
},
|
||||||
ominous_item_spawner_item: OminousItemSpawnerItem(ItemSlot::Empty),
|
ominous_item_spawner_item: OminousItemSpawnerItem(ItemStack::Empty),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8052,7 +8052,7 @@ impl Default for PolarBearMetadataBundle {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Component, Deref, DerefMut, Clone)]
|
#[derive(Component, Deref, DerefMut, Clone)]
|
||||||
pub struct PotionItemStack(pub ItemSlot);
|
pub struct PotionItemStack(pub ItemStack);
|
||||||
#[derive(Component)]
|
#[derive(Component)]
|
||||||
pub struct Potion;
|
pub struct Potion;
|
||||||
impl Potion {
|
impl Potion {
|
||||||
|
@ -8937,7 +8937,7 @@ impl Default for SlimeMetadataBundle {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Component, Deref, DerefMut, Clone)]
|
#[derive(Component, Deref, DerefMut, Clone)]
|
||||||
pub struct SmallFireballItemStack(pub ItemSlot);
|
pub struct SmallFireballItemStack(pub ItemStack);
|
||||||
#[derive(Component)]
|
#[derive(Component)]
|
||||||
pub struct SmallFireball;
|
pub struct SmallFireball;
|
||||||
impl SmallFireball {
|
impl SmallFireball {
|
||||||
|
@ -9148,7 +9148,7 @@ impl Default for SnowGolemMetadataBundle {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Component, Deref, DerefMut, Clone)]
|
#[derive(Component, Deref, DerefMut, Clone)]
|
||||||
pub struct SnowballItemStack(pub ItemSlot);
|
pub struct SnowballItemStack(pub ItemStack);
|
||||||
#[derive(Component)]
|
#[derive(Component)]
|
||||||
pub struct Snowball;
|
pub struct Snowball;
|
||||||
impl Snowball {
|
impl Snowball {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
use azalea_buf::McBuf;
|
use azalea_buf::McBuf;
|
||||||
use azalea_core::position::BlockPos;
|
use azalea_core::position::BlockPos;
|
||||||
use azalea_inventory::ItemSlot;
|
use azalea_inventory::ItemStack;
|
||||||
use azalea_registry::ParticleKind;
|
use azalea_registry::ParticleKind;
|
||||||
use bevy_ecs::component::Component;
|
use bevy_ecs::component::Component;
|
||||||
|
|
||||||
|
@ -286,7 +286,7 @@ pub struct DustColorTransitionParticle {
|
||||||
|
|
||||||
#[derive(Debug, Clone, McBuf, Default)]
|
#[derive(Debug, Clone, McBuf, Default)]
|
||||||
pub struct ItemParticle {
|
pub struct ItemParticle {
|
||||||
pub item: ItemSlot,
|
pub item: ItemStack,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, McBuf, Default)]
|
#[derive(Debug, Clone, McBuf, Default)]
|
||||||
|
|
|
@ -34,11 +34,11 @@ pub fn generate(input: &DeclareMenus) -> TokenStream {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Player {
|
/// Player {
|
||||||
/// craft_result: ItemSlot,
|
/// craft_result: ItemStack,
|
||||||
/// craft: [ItemSlot; 4],
|
/// craft: [ItemStack; 4],
|
||||||
/// armor: [ItemSlot; 4],
|
/// armor: [ItemStack; 4],
|
||||||
/// inventory: [ItemSlot; 36],
|
/// inventory: [ItemStack; 36],
|
||||||
/// offhand: ItemSlot,
|
/// offhand: ItemStack,
|
||||||
/// },
|
/// },
|
||||||
fn generate_variant_for_menu(menu: &Menu) -> TokenStream {
|
fn generate_variant_for_menu(menu: &Menu) -> TokenStream {
|
||||||
let name = &menu.name;
|
let name = &menu.name;
|
||||||
|
@ -56,7 +56,7 @@ fn generate_fields(fields: &[Field], public: bool) -> TokenStream {
|
||||||
for field in fields {
|
for field in fields {
|
||||||
let field_length = field.length;
|
let field_length = field.length;
|
||||||
let field_type = if field.length == 1 {
|
let field_type = if field.length == 1 {
|
||||||
quote! { ItemSlot }
|
quote! { ItemStack }
|
||||||
} else {
|
} else {
|
||||||
quote! { SlotList<#field_length> }
|
quote! { SlotList<#field_length> }
|
||||||
};
|
};
|
||||||
|
|
|
@ -95,11 +95,11 @@ pub fn generate(input: &DeclareMenus) -> TokenStream {
|
||||||
impl Menu {
|
impl Menu {
|
||||||
#menu_consts
|
#menu_consts
|
||||||
|
|
||||||
/// Get a mutable reference to the [`ItemSlot`] at the given protocol index.
|
/// Get a mutable reference to the [`ItemStack`] at the given protocol index.
|
||||||
///
|
///
|
||||||
/// If you're trying to get an item in a menu without caring about
|
/// If you're trying to get an item in a menu without caring about
|
||||||
/// protocol indexes, you should just `match` it and index the
|
/// protocol indexes, you should just `match` it and index the
|
||||||
/// [`ItemSlot`] you get.
|
/// [`ItemStack`] you get.
|
||||||
///
|
///
|
||||||
/// Use [`Menu::slot`] if you don't need a mutable reference to the slot.
|
/// Use [`Menu::slot`] if you don't need a mutable reference to the slot.
|
||||||
///
|
///
|
||||||
|
@ -107,24 +107,24 @@ pub fn generate(input: &DeclareMenus) -> TokenStream {
|
||||||
///
|
///
|
||||||
/// Returns `None` if the index is out of bounds.
|
/// Returns `None` if the index is out of bounds.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn slot_mut(&mut self, i: usize) -> Option<&mut ItemSlot> {
|
pub fn slot_mut(&mut self, i: usize) -> Option<&mut ItemStack> {
|
||||||
Some(match self {
|
Some(match self {
|
||||||
#slot_mut_match_variants
|
#slot_mut_match_variants
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get a reference to the [`ItemSlot`] at the given protocol index.
|
/// Get a reference to the [`ItemStack`] at the given protocol index.
|
||||||
///
|
///
|
||||||
/// If you're trying to get an item in a menu without caring about
|
/// If you're trying to get an item in a menu without caring about
|
||||||
/// protocol indexes, you should just `match` it and index the
|
/// protocol indexes, you should just `match` it and index the
|
||||||
/// [`ItemSlot`] you get.
|
/// [`ItemStack`] you get.
|
||||||
///
|
///
|
||||||
/// Use [`Menu::slot_mut`] if you need a mutable reference to the slot.
|
/// Use [`Menu::slot_mut`] if you need a mutable reference to the slot.
|
||||||
///
|
///
|
||||||
/// # Errors
|
/// # Errors
|
||||||
///
|
///
|
||||||
/// Returns `None` if the index is out of bounds.
|
/// Returns `None` if the index is out of bounds.
|
||||||
pub fn slot(&self, i: usize) -> Option<&ItemSlot> {
|
pub fn slot(&self, i: usize) -> Option<&ItemStack> {
|
||||||
Some(match self {
|
Some(match self {
|
||||||
#slot_match_variants
|
#slot_match_variants
|
||||||
})
|
})
|
||||||
|
@ -153,7 +153,7 @@ pub fn generate(input: &DeclareMenus) -> TokenStream {
|
||||||
///
|
///
|
||||||
/// If you *only* want to include the players inventory, then you can filter by only
|
/// If you *only* want to include the players inventory, then you can filter by only
|
||||||
/// using the slots in [`Self::player_slots_range`].
|
/// using the slots in [`Self::player_slots_range`].
|
||||||
pub fn slots(&self) -> Vec<ItemSlot> {
|
pub fn slots(&self) -> Vec<ItemStack> {
|
||||||
match self {
|
match self {
|
||||||
#slots_match_variants
|
#slots_match_variants
|
||||||
}
|
}
|
||||||
|
@ -162,7 +162,7 @@ pub fn generate(input: &DeclareMenus) -> TokenStream {
|
||||||
/// Return the contents of the menu, not including the player's inventory.
|
/// Return the contents of the menu, not including the player's inventory.
|
||||||
///
|
///
|
||||||
/// If you want to include the player's inventory, use [`Menu::slots`] instead.
|
/// If you want to include the player's inventory, use [`Menu::slots`] instead.
|
||||||
pub fn contents(&self) -> Vec<ItemSlot> {
|
pub fn contents(&self) -> Vec<ItemStack> {
|
||||||
match self {
|
match self {
|
||||||
#contents_match_variants
|
#contents_match_variants
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,7 @@ use azalea_registry::{
|
||||||
use simdnbt::owned::{Nbt, NbtCompound};
|
use simdnbt::owned::{Nbt, NbtCompound};
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
|
|
||||||
use crate::ItemSlot;
|
use crate::ItemStack;
|
||||||
|
|
||||||
pub trait DataComponent: Send + Sync + Any {}
|
pub trait DataComponent: Send + Sync + Any {}
|
||||||
|
|
||||||
|
@ -427,13 +427,13 @@ impl DataComponent for MapPostProcessing {}
|
||||||
|
|
||||||
#[derive(Clone, PartialEq, McBuf)]
|
#[derive(Clone, PartialEq, McBuf)]
|
||||||
pub struct ChargedProjectiles {
|
pub struct ChargedProjectiles {
|
||||||
pub items: Vec<ItemSlot>,
|
pub items: Vec<ItemStack>,
|
||||||
}
|
}
|
||||||
impl DataComponent for ChargedProjectiles {}
|
impl DataComponent for ChargedProjectiles {}
|
||||||
|
|
||||||
#[derive(Clone, PartialEq, McBuf)]
|
#[derive(Clone, PartialEq, McBuf)]
|
||||||
pub struct BundleContents {
|
pub struct BundleContents {
|
||||||
pub items: Vec<ItemSlot>,
|
pub items: Vec<ItemStack>,
|
||||||
}
|
}
|
||||||
impl DataComponent for BundleContents {}
|
impl DataComponent for BundleContents {}
|
||||||
|
|
||||||
|
@ -629,7 +629,7 @@ impl DataComponent for PotDecorations {}
|
||||||
|
|
||||||
#[derive(Clone, PartialEq, McBuf)]
|
#[derive(Clone, PartialEq, McBuf)]
|
||||||
pub struct Container {
|
pub struct Container {
|
||||||
pub items: Vec<ItemSlot>,
|
pub items: Vec<ItemStack>,
|
||||||
}
|
}
|
||||||
impl DataComponent for Container {}
|
impl DataComponent for Container {}
|
||||||
|
|
||||||
|
@ -699,7 +699,7 @@ pub enum ItemUseAnimation {
|
||||||
|
|
||||||
#[derive(Clone, PartialEq, McBuf)]
|
#[derive(Clone, PartialEq, McBuf)]
|
||||||
pub struct UseRemainder {
|
pub struct UseRemainder {
|
||||||
pub convert_into: ItemSlot,
|
pub convert_into: ItemStack,
|
||||||
}
|
}
|
||||||
impl DataComponent for UseRemainder {}
|
impl DataComponent for UseRemainder {}
|
||||||
|
|
||||||
|
|
|
@ -2,9 +2,9 @@ pub trait MaxStackSizeExt {
|
||||||
/// Get the maximum stack size for this item.
|
/// Get the maximum stack size for this item.
|
||||||
///
|
///
|
||||||
/// This is a signed integer to be consistent with the `count` field of
|
/// This is a signed integer to be consistent with the `count` field of
|
||||||
/// [`ItemSlotData`].
|
/// [`ItemStackData`].
|
||||||
///
|
///
|
||||||
/// [`ItemSlotData`]: crate::ItemSlotData
|
/// [`ItemStackData`]: crate::ItemStackData
|
||||||
fn max_stack_size(&self) -> i32;
|
fn max_stack_size(&self) -> i32;
|
||||||
|
|
||||||
/// Whether this item can be stacked with other items.
|
/// Whether this item can be stacked with other items.
|
||||||
|
|
|
@ -9,17 +9,17 @@ mod slot;
|
||||||
use std::ops::{Deref, DerefMut, RangeInclusive};
|
use std::ops::{Deref, DerefMut, RangeInclusive};
|
||||||
|
|
||||||
use azalea_inventory_macros::declare_menus;
|
use azalea_inventory_macros::declare_menus;
|
||||||
pub use slot::{DataComponentPatch, ItemSlot, ItemSlotData};
|
pub use slot::{DataComponentPatch, ItemStack, ItemStackData};
|
||||||
|
|
||||||
// TODO: remove this here and in azalea-inventory-macros when rust makes
|
// TODO: remove this here and in azalea-inventory-macros when rust makes
|
||||||
// Default be implemented for all array sizes
|
// Default be implemented for all array sizes
|
||||||
// https://github.com/rust-lang/rust/issues/61415
|
// https://github.com/rust-lang/rust/issues/61415
|
||||||
|
|
||||||
/// A fixed-size list of [`ItemSlot`]s.
|
/// A fixed-size list of [`ItemStack`]s.
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct SlotList<const N: usize>([ItemSlot; N]);
|
pub struct SlotList<const N: usize>([ItemStack; N]);
|
||||||
impl<const N: usize> Deref for SlotList<N> {
|
impl<const N: usize> Deref for SlotList<N> {
|
||||||
type Target = [ItemSlot; N];
|
type Target = [ItemStack; N];
|
||||||
fn deref(&self) -> &Self::Target {
|
fn deref(&self) -> &Self::Target {
|
||||||
&self.0
|
&self.0
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,7 @@ impl<const N: usize> DerefMut for SlotList<N> {
|
||||||
}
|
}
|
||||||
impl<const N: usize> Default for SlotList<N> {
|
impl<const N: usize> Default for SlotList<N> {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
SlotList([(); N].map(|_| ItemSlot::Empty))
|
SlotList([(); N].map(|_| ItemStack::Empty))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@ use crate::{
|
||||||
CraftingMenuLocation, EnchantmentMenuLocation, FurnaceMenuLocation, Generic3x3MenuLocation,
|
CraftingMenuLocation, EnchantmentMenuLocation, FurnaceMenuLocation, Generic3x3MenuLocation,
|
||||||
Generic9x1MenuLocation, Generic9x2MenuLocation, Generic9x3MenuLocation, Generic9x4MenuLocation,
|
Generic9x1MenuLocation, Generic9x2MenuLocation, Generic9x3MenuLocation, Generic9x4MenuLocation,
|
||||||
Generic9x5MenuLocation, Generic9x6MenuLocation, GrindstoneMenuLocation, HopperMenuLocation,
|
Generic9x5MenuLocation, Generic9x6MenuLocation, GrindstoneMenuLocation, HopperMenuLocation,
|
||||||
ItemSlot, ItemSlotData, LecternMenuLocation, LoomMenuLocation, Menu, MenuLocation,
|
ItemStack, ItemStackData, LecternMenuLocation, LoomMenuLocation, Menu, MenuLocation,
|
||||||
MerchantMenuLocation, Player, PlayerMenuLocation, ShulkerBoxMenuLocation, SmithingMenuLocation,
|
MerchantMenuLocation, Player, PlayerMenuLocation, ShulkerBoxMenuLocation, SmithingMenuLocation,
|
||||||
SmokerMenuLocation, StonecutterMenuLocation,
|
SmokerMenuLocation, StonecutterMenuLocation,
|
||||||
};
|
};
|
||||||
|
@ -266,10 +266,10 @@ impl Menu {
|
||||||
///
|
///
|
||||||
/// Keep in mind that this doesn't send any packets to the server, it just
|
/// Keep in mind that this doesn't send any packets to the server, it just
|
||||||
/// mutates this specific `Menu`.
|
/// mutates this specific `Menu`.
|
||||||
pub fn quick_move_stack(&mut self, slot_index: usize) -> ItemSlot {
|
pub fn quick_move_stack(&mut self, slot_index: usize) -> ItemStack {
|
||||||
let slot = self.slot(slot_index);
|
let slot = self.slot(slot_index);
|
||||||
if slot.is_none() {
|
if slot.is_none() {
|
||||||
return ItemSlot::Empty;
|
return ItemStack::Empty;
|
||||||
};
|
};
|
||||||
|
|
||||||
let slot_location = self
|
let slot_location = self
|
||||||
|
@ -587,7 +587,7 @@ impl Menu {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
ItemSlot::Empty
|
ItemStack::Empty
|
||||||
}
|
}
|
||||||
|
|
||||||
fn try_move_item_to_slots_or_toggle_hotbar(
|
fn try_move_item_to_slots_or_toggle_hotbar(
|
||||||
|
@ -610,7 +610,7 @@ impl Menu {
|
||||||
/// Whether the given item could be placed in this menu.
|
/// Whether the given item could be placed in this menu.
|
||||||
///
|
///
|
||||||
/// TODO: right now this always returns true
|
/// TODO: right now this always returns true
|
||||||
pub fn may_place(&self, _target_slot_index: usize, _item: &ItemSlotData) -> bool {
|
pub fn may_place(&self, _target_slot_index: usize, _item: &ItemStackData) -> bool {
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -662,14 +662,14 @@ impl Menu {
|
||||||
/// slot is present and the same item.
|
/// slot is present and the same item.
|
||||||
fn move_item_to_slot_if_stackable(
|
fn move_item_to_slot_if_stackable(
|
||||||
&mut self,
|
&mut self,
|
||||||
item_slot: &mut ItemSlot,
|
item_slot: &mut ItemStack,
|
||||||
target_slot_index: usize,
|
target_slot_index: usize,
|
||||||
) {
|
) {
|
||||||
let ItemSlot::Present(item) = item_slot else {
|
let ItemStack::Present(item) = item_slot else {
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
let target_slot = self.slot(target_slot_index).unwrap();
|
let target_slot = self.slot(target_slot_index).unwrap();
|
||||||
if let ItemSlot::Present(target_item) = target_slot {
|
if let ItemStack::Present(target_item) = target_slot {
|
||||||
// the target slot is empty, so we can just move the item there
|
// the target slot is empty, so we can just move the item there
|
||||||
if self.may_place(target_slot_index, item)
|
if self.may_place(target_slot_index, item)
|
||||||
&& target_item.is_same_item_and_components(item)
|
&& target_item.is_same_item_and_components(item)
|
||||||
|
@ -679,15 +679,15 @@ impl Menu {
|
||||||
|
|
||||||
// get the target slot again but mut this time so we can update it
|
// get the target slot again but mut this time so we can update it
|
||||||
let target_slot = self.slot_mut(target_slot_index).unwrap();
|
let target_slot = self.slot_mut(target_slot_index).unwrap();
|
||||||
*target_slot = ItemSlot::Present(new_target_slot_data);
|
*target_slot = ItemStack::Present(new_target_slot_data);
|
||||||
|
|
||||||
item_slot.update_empty();
|
item_slot.update_empty();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn move_item_to_slot_if_empty(&mut self, item_slot: &mut ItemSlot, target_slot_index: usize) {
|
fn move_item_to_slot_if_empty(&mut self, item_slot: &mut ItemStack, target_slot_index: usize) {
|
||||||
let ItemSlot::Present(item) = item_slot else {
|
let ItemStack::Present(item) = item_slot else {
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
let target_slot = self.slot(target_slot_index).unwrap();
|
let target_slot = self.slot(target_slot_index).unwrap();
|
||||||
|
@ -696,7 +696,7 @@ impl Menu {
|
||||||
let new_target_slot_data = item.split(u32::min(slot_item_limit, item.count as u32));
|
let new_target_slot_data = item.split(u32::min(slot_item_limit, item.count as u32));
|
||||||
|
|
||||||
let target_slot = self.slot_mut(target_slot_index).unwrap();
|
let target_slot = self.slot_mut(target_slot_index).unwrap();
|
||||||
*target_slot = ItemSlot::Present(new_target_slot_data);
|
*target_slot = ItemStack::Present(new_target_slot_data);
|
||||||
item_slot.update_empty();
|
item_slot.update_empty();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,27 +11,27 @@ use crate::components::{self};
|
||||||
|
|
||||||
/// Either an item in an inventory or nothing.
|
/// Either an item in an inventory or nothing.
|
||||||
#[derive(Debug, Clone, Default, PartialEq)]
|
#[derive(Debug, Clone, Default, PartialEq)]
|
||||||
pub enum ItemSlot {
|
pub enum ItemStack {
|
||||||
#[default]
|
#[default]
|
||||||
Empty,
|
Empty,
|
||||||
Present(ItemSlotData),
|
Present(ItemStackData),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ItemSlot {
|
impl ItemStack {
|
||||||
/// Check if the slot is ItemSlot::Empty, if the count is <= 0, or if the
|
/// Check if the slot is ItemStack::Empty, if the count is <= 0, or if the
|
||||||
/// item is air.
|
/// item is air.
|
||||||
///
|
///
|
||||||
/// This is the opposite of [`ItemSlot::is_present`].
|
/// This is the opposite of [`ItemStack::is_present`].
|
||||||
pub fn is_empty(&self) -> bool {
|
pub fn is_empty(&self) -> bool {
|
||||||
match self {
|
match self {
|
||||||
ItemSlot::Empty => true,
|
ItemStack::Empty => true,
|
||||||
ItemSlot::Present(item) => item.is_empty(),
|
ItemStack::Present(item) => item.is_empty(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/// Check if the slot is not ItemSlot::Empty, if the count is > 0, and if
|
/// Check if the slot is not ItemStack::Empty, if the count is > 0, and if
|
||||||
/// the item is not air.
|
/// the item is not air.
|
||||||
///
|
///
|
||||||
/// This is the opposite of [`ItemSlot::is_empty`].
|
/// This is the opposite of [`ItemStack::is_empty`].
|
||||||
pub fn is_present(&self) -> bool {
|
pub fn is_present(&self) -> bool {
|
||||||
!self.is_empty()
|
!self.is_empty()
|
||||||
}
|
}
|
||||||
|
@ -42,21 +42,21 @@ impl ItemSlot {
|
||||||
/// slot is present.
|
/// slot is present.
|
||||||
pub fn count(&self) -> i32 {
|
pub fn count(&self) -> i32 {
|
||||||
match self {
|
match self {
|
||||||
ItemSlot::Empty => 0,
|
ItemStack::Empty => 0,
|
||||||
ItemSlot::Present(i) => i.count,
|
ItemStack::Present(i) => i.count,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Remove `count` items from this slot, returning the removed items.
|
/// Remove `count` items from this slot, returning the removed items.
|
||||||
pub fn split(&mut self, count: u32) -> ItemSlot {
|
pub fn split(&mut self, count: u32) -> ItemStack {
|
||||||
match self {
|
match self {
|
||||||
ItemSlot::Empty => ItemSlot::Empty,
|
ItemStack::Empty => ItemStack::Empty,
|
||||||
ItemSlot::Present(i) => {
|
ItemStack::Present(i) => {
|
||||||
let returning = i.split(count);
|
let returning = i.split(count);
|
||||||
if i.is_empty() {
|
if i.is_empty() {
|
||||||
*self = ItemSlot::Empty;
|
*self = ItemStack::Empty;
|
||||||
}
|
}
|
||||||
ItemSlot::Present(returning)
|
ItemStack::Present(returning)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -65,33 +65,33 @@ impl ItemSlot {
|
||||||
/// [`azalea_registry::Item::Air`]
|
/// [`azalea_registry::Item::Air`]
|
||||||
pub fn kind(&self) -> azalea_registry::Item {
|
pub fn kind(&self) -> azalea_registry::Item {
|
||||||
match self {
|
match self {
|
||||||
ItemSlot::Empty => azalea_registry::Item::Air,
|
ItemStack::Empty => azalea_registry::Item::Air,
|
||||||
ItemSlot::Present(i) => i.kind,
|
ItemStack::Present(i) => i.kind,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Update whether this slot is empty, based on the count.
|
/// Update whether this slot is empty, based on the count.
|
||||||
pub fn update_empty(&mut self) {
|
pub fn update_empty(&mut self) {
|
||||||
if let ItemSlot::Present(i) = self {
|
if let ItemStack::Present(i) = self {
|
||||||
if i.is_empty() {
|
if i.is_empty() {
|
||||||
*self = ItemSlot::Empty;
|
*self = ItemStack::Empty;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Convert this slot into an [`ItemSlotData`], if it's present.
|
/// Convert this slot into an [`ItemStackData`], if it's present.
|
||||||
pub fn as_present(&self) -> Option<&ItemSlotData> {
|
pub fn as_present(&self) -> Option<&ItemStackData> {
|
||||||
match self {
|
match self {
|
||||||
ItemSlot::Empty => None,
|
ItemStack::Empty => None,
|
||||||
ItemSlot::Present(i) => Some(i),
|
ItemStack::Present(i) => Some(i),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// An item in an inventory, with a count and NBT. Usually you want [`ItemSlot`]
|
/// An item in an inventory, with a count and NBT. Usually you want
|
||||||
/// or [`azalea_registry::Item`] instead.
|
/// [`ItemStack`] or [`azalea_registry::Item`] instead.
|
||||||
#[derive(Debug, Clone, PartialEq)]
|
#[derive(Debug, Clone, PartialEq)]
|
||||||
pub struct ItemSlotData {
|
pub struct ItemStackData {
|
||||||
/// The amount of the item in this slot.
|
/// The amount of the item in this slot.
|
||||||
///
|
///
|
||||||
/// The count can be zero or negative, but this is rare.
|
/// The count can be zero or negative, but this is rare.
|
||||||
|
@ -100,9 +100,9 @@ pub struct ItemSlotData {
|
||||||
pub components: DataComponentPatch,
|
pub components: DataComponentPatch,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ItemSlotData {
|
impl ItemStackData {
|
||||||
/// Remove `count` items from this slot, returning the removed items.
|
/// Remove `count` items from this slot, returning the removed items.
|
||||||
pub fn split(&mut self, count: u32) -> ItemSlotData {
|
pub fn split(&mut self, count: u32) -> ItemStackData {
|
||||||
let returning_count = i32::min(count as i32, self.count);
|
let returning_count = i32::min(count as i32, self.count);
|
||||||
let mut returning = self.clone();
|
let mut returning = self.clone();
|
||||||
returning.count = returning_count;
|
returning.count = returning_count;
|
||||||
|
@ -118,14 +118,14 @@ impl ItemSlotData {
|
||||||
/// Whether this item is the same as another item, ignoring the count.
|
/// Whether this item is the same as another item, ignoring the count.
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// # use azalea_inventory::ItemSlotData;
|
/// # use azalea_inventory::ItemStackData;
|
||||||
/// # use azalea_registry::Item;
|
/// # use azalea_registry::Item;
|
||||||
/// let mut a = ItemSlotData {
|
/// let mut a = ItemStackData {
|
||||||
/// kind: Item::Stone,
|
/// kind: Item::Stone,
|
||||||
/// count: 1,
|
/// count: 1,
|
||||||
/// components: Default::default(),
|
/// components: Default::default(),
|
||||||
/// };
|
/// };
|
||||||
/// let mut b = ItemSlotData {
|
/// let mut b = ItemStackData {
|
||||||
/// kind: Item::Stone,
|
/// kind: Item::Stone,
|
||||||
/// count: 2,
|
/// count: 2,
|
||||||
/// components: Default::default(),
|
/// components: Default::default(),
|
||||||
|
@ -135,20 +135,20 @@ impl ItemSlotData {
|
||||||
/// b.kind = Item::Dirt;
|
/// b.kind = Item::Dirt;
|
||||||
/// assert!(!a.is_same_item_and_components(&b));
|
/// assert!(!a.is_same_item_and_components(&b));
|
||||||
/// ```
|
/// ```
|
||||||
pub fn is_same_item_and_components(&self, other: &ItemSlotData) -> bool {
|
pub fn is_same_item_and_components(&self, other: &ItemStackData) -> bool {
|
||||||
self.kind == other.kind && self.components == other.components
|
self.kind == other.kind && self.components == other.components
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl McBufReadable for ItemSlot {
|
impl McBufReadable for ItemStack {
|
||||||
fn read_from(buf: &mut Cursor<&[u8]>) -> Result<Self, BufReadError> {
|
fn read_from(buf: &mut Cursor<&[u8]>) -> Result<Self, BufReadError> {
|
||||||
let count = i32::var_read_from(buf)?;
|
let count = i32::var_read_from(buf)?;
|
||||||
if count <= 0 {
|
if count <= 0 {
|
||||||
Ok(ItemSlot::Empty)
|
Ok(ItemStack::Empty)
|
||||||
} else {
|
} else {
|
||||||
let kind = azalea_registry::Item::read_from(buf)?;
|
let kind = azalea_registry::Item::read_from(buf)?;
|
||||||
let components = DataComponentPatch::read_from(buf)?;
|
let components = DataComponentPatch::read_from(buf)?;
|
||||||
Ok(ItemSlot::Present(ItemSlotData {
|
Ok(ItemStack::Present(ItemStackData {
|
||||||
count,
|
count,
|
||||||
kind,
|
kind,
|
||||||
components,
|
components,
|
||||||
|
@ -157,11 +157,11 @@ impl McBufReadable for ItemSlot {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl McBufWritable for ItemSlot {
|
impl McBufWritable for ItemStack {
|
||||||
fn write_into(&self, buf: &mut impl Write) -> Result<(), std::io::Error> {
|
fn write_into(&self, buf: &mut impl Write) -> Result<(), std::io::Error> {
|
||||||
match self {
|
match self {
|
||||||
ItemSlot::Empty => 0.var_write_into(buf)?,
|
ItemStack::Empty => 0.var_write_into(buf)?,
|
||||||
ItemSlot::Present(i) => {
|
ItemStack::Present(i) => {
|
||||||
i.count.var_write_into(buf)?;
|
i.count.var_write_into(buf)?;
|
||||||
i.kind.write_into(buf)?;
|
i.kind.write_into(buf)?;
|
||||||
i.components.write_into(buf)?;
|
i.components.write_into(buf)?;
|
||||||
|
|
|
@ -5,7 +5,7 @@ use azalea_core::{
|
||||||
math::{self, lerp, EPSILON},
|
math::{self, lerp, EPSILON},
|
||||||
position::{BlockPos, Vec3},
|
position::{BlockPos, Vec3},
|
||||||
};
|
};
|
||||||
use azalea_inventory::ItemSlot;
|
use azalea_inventory::ItemStack;
|
||||||
use azalea_world::ChunkStorage;
|
use azalea_world::ChunkStorage;
|
||||||
use bevy_ecs::entity::Entity;
|
use bevy_ecs::entity::Entity;
|
||||||
|
|
||||||
|
@ -52,7 +52,7 @@ pub enum FluidPickType {
|
||||||
pub struct EntityCollisionContext {
|
pub struct EntityCollisionContext {
|
||||||
pub descending: bool,
|
pub descending: bool,
|
||||||
pub entity_bottom: f64,
|
pub entity_bottom: f64,
|
||||||
pub held_item: ItemSlot,
|
pub held_item: ItemStack,
|
||||||
// pub can_stand_on_fluid: Box<dyn Fn(&FluidState) -> bool>,
|
// pub can_stand_on_fluid: Box<dyn Fn(&FluidState) -> bool>,
|
||||||
pub entity: Entity,
|
pub entity: Entity,
|
||||||
}
|
}
|
||||||
|
|
|
@ -128,8 +128,8 @@ pub enum BrigadierParser {
|
||||||
ScoreHolder { allows_multiple: bool },
|
ScoreHolder { allows_multiple: bool },
|
||||||
Swizzle,
|
Swizzle,
|
||||||
Team,
|
Team,
|
||||||
ItemSlot,
|
ItemStack,
|
||||||
ItemSlots,
|
ItemStacks,
|
||||||
ResourceLocation,
|
ResourceLocation,
|
||||||
Function,
|
Function,
|
||||||
EntityAnchor,
|
EntityAnchor,
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use azalea_buf::McBuf;
|
use azalea_buf::McBuf;
|
||||||
use azalea_inventory::ItemSlot;
|
use azalea_inventory::ItemStack;
|
||||||
use azalea_protocol_macros::ClientboundGamePacket;
|
use azalea_protocol_macros::ClientboundGamePacket;
|
||||||
|
|
||||||
#[derive(Clone, Debug, McBuf, ClientboundGamePacket)]
|
#[derive(Clone, Debug, McBuf, ClientboundGamePacket)]
|
||||||
|
@ -7,6 +7,6 @@ pub struct ClientboundContainerSetContent {
|
||||||
pub container_id: i8,
|
pub container_id: i8,
|
||||||
#[var]
|
#[var]
|
||||||
pub state_id: u32,
|
pub state_id: u32,
|
||||||
pub items: Vec<ItemSlot>,
|
pub items: Vec<ItemStack>,
|
||||||
pub carried_item: ItemSlot,
|
pub carried_item: ItemStack,
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use azalea_buf::McBuf;
|
use azalea_buf::McBuf;
|
||||||
use azalea_inventory::ItemSlot;
|
use azalea_inventory::ItemStack;
|
||||||
use azalea_protocol_macros::ClientboundGamePacket;
|
use azalea_protocol_macros::ClientboundGamePacket;
|
||||||
|
|
||||||
#[derive(Clone, Debug, McBuf, ClientboundGamePacket)]
|
#[derive(Clone, Debug, McBuf, ClientboundGamePacket)]
|
||||||
|
@ -8,5 +8,5 @@ pub struct ClientboundContainerSetSlot {
|
||||||
#[var]
|
#[var]
|
||||||
pub state_id: u32,
|
pub state_id: u32,
|
||||||
pub slot: u16,
|
pub slot: u16,
|
||||||
pub item_stack: ItemSlot,
|
pub item_stack: ItemStack,
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use azalea_buf::McBuf;
|
use azalea_buf::McBuf;
|
||||||
use azalea_inventory::ItemSlot;
|
use azalea_inventory::ItemStack;
|
||||||
use azalea_protocol_macros::ClientboundGamePacket;
|
use azalea_protocol_macros::ClientboundGamePacket;
|
||||||
|
|
||||||
#[derive(Clone, Debug, McBuf, ClientboundGamePacket)]
|
#[derive(Clone, Debug, McBuf, ClientboundGamePacket)]
|
||||||
|
@ -17,9 +17,9 @@ pub struct ClientboundMerchantOffers {
|
||||||
|
|
||||||
#[derive(Clone, Debug, McBuf)]
|
#[derive(Clone, Debug, McBuf)]
|
||||||
pub struct MerchantOffer {
|
pub struct MerchantOffer {
|
||||||
pub base_cost_a: ItemSlot,
|
pub base_cost_a: ItemStack,
|
||||||
pub result: ItemSlot,
|
pub result: ItemStack,
|
||||||
pub cost_b: ItemSlot,
|
pub cost_b: ItemStack,
|
||||||
pub out_of_stock: bool,
|
pub out_of_stock: bool,
|
||||||
pub uses: u32,
|
pub uses: u32,
|
||||||
pub max_uses: u32,
|
pub max_uses: u32,
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
use azalea_buf::McBuf;
|
use azalea_buf::McBuf;
|
||||||
use azalea_inventory::ItemSlot;
|
use azalea_inventory::ItemStack;
|
||||||
use azalea_protocol_macros::ClientboundGamePacket;
|
use azalea_protocol_macros::ClientboundGamePacket;
|
||||||
|
|
||||||
#[derive(Clone, Debug, McBuf, ClientboundGamePacket)]
|
#[derive(Clone, Debug, McBuf, ClientboundGamePacket)]
|
||||||
pub struct ClientboundSetCursorItem {
|
pub struct ClientboundSetCursorItem {
|
||||||
pub contents: Option<ItemSlot>,
|
pub contents: Option<ItemStack>,
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,7 @@ use std::io::Cursor;
|
||||||
|
|
||||||
use azalea_buf::{BufReadError, McBuf};
|
use azalea_buf::{BufReadError, McBuf};
|
||||||
use azalea_buf::{McBufReadable, McBufWritable};
|
use azalea_buf::{McBufReadable, McBufWritable};
|
||||||
use azalea_inventory::ItemSlot;
|
use azalea_inventory::ItemStack;
|
||||||
use azalea_protocol_macros::ClientboundGamePacket;
|
use azalea_protocol_macros::ClientboundGamePacket;
|
||||||
|
|
||||||
#[derive(Clone, Debug, McBuf, ClientboundGamePacket)]
|
#[derive(Clone, Debug, McBuf, ClientboundGamePacket)]
|
||||||
|
@ -14,7 +14,7 @@ pub struct ClientboundSetEquipment {
|
||||||
|
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
pub struct EquipmentSlots {
|
pub struct EquipmentSlots {
|
||||||
pub slots: Vec<(EquipmentSlot, ItemSlot)>,
|
pub slots: Vec<(EquipmentSlot, ItemStack)>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl McBufReadable for EquipmentSlots {
|
impl McBufReadable for EquipmentSlots {
|
||||||
|
@ -29,7 +29,7 @@ impl McBufReadable for EquipmentSlots {
|
||||||
id: equipment_byte.into(),
|
id: equipment_byte.into(),
|
||||||
}
|
}
|
||||||
})?;
|
})?;
|
||||||
let item = ItemSlot::read_from(buf)?;
|
let item = ItemStack::read_from(buf)?;
|
||||||
slots.push((equipment_slot, item));
|
slots.push((equipment_slot, item));
|
||||||
if equipment_byte & 128 == 0 {
|
if equipment_byte & 128 == 0 {
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
use azalea_buf::McBuf;
|
use azalea_buf::McBuf;
|
||||||
use azalea_inventory::ItemSlot;
|
use azalea_inventory::ItemStack;
|
||||||
use azalea_protocol_macros::ClientboundGamePacket;
|
use azalea_protocol_macros::ClientboundGamePacket;
|
||||||
|
|
||||||
#[derive(Clone, Debug, McBuf, ClientboundGamePacket)]
|
#[derive(Clone, Debug, McBuf, ClientboundGamePacket)]
|
||||||
pub struct ClientboundSetPlayerInventory {
|
pub struct ClientboundSetPlayerInventory {
|
||||||
#[var]
|
#[var]
|
||||||
pub slot: i32,
|
pub slot: i32,
|
||||||
pub contents: Option<ItemSlot>,
|
pub contents: Option<ItemStack>,
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,7 @@ use std::io::Cursor;
|
||||||
use azalea_buf::McBuf;
|
use azalea_buf::McBuf;
|
||||||
use azalea_chat::FormattedText;
|
use azalea_chat::FormattedText;
|
||||||
use azalea_core::resource_location::ResourceLocation;
|
use azalea_core::resource_location::ResourceLocation;
|
||||||
use azalea_inventory::ItemSlot;
|
use azalea_inventory::ItemStack;
|
||||||
use azalea_protocol_macros::ClientboundGamePacket;
|
use azalea_protocol_macros::ClientboundGamePacket;
|
||||||
|
|
||||||
#[derive(Clone, Debug, McBuf, ClientboundGamePacket)]
|
#[derive(Clone, Debug, McBuf, ClientboundGamePacket)]
|
||||||
|
@ -27,7 +27,7 @@ pub struct Advancement {
|
||||||
pub struct DisplayInfo {
|
pub struct DisplayInfo {
|
||||||
pub title: FormattedText,
|
pub title: FormattedText,
|
||||||
pub description: FormattedText,
|
pub description: FormattedText,
|
||||||
pub icon: ItemSlot,
|
pub icon: ItemStack,
|
||||||
pub frame: FrameType,
|
pub frame: FrameType,
|
||||||
pub show_toast: bool,
|
pub show_toast: bool,
|
||||||
pub hidden: bool,
|
pub hidden: bool,
|
||||||
|
@ -133,7 +133,7 @@ mod tests {
|
||||||
display: Some(DisplayInfo {
|
display: Some(DisplayInfo {
|
||||||
title: FormattedText::from("title".to_string()),
|
title: FormattedText::from("title".to_string()),
|
||||||
description: FormattedText::from("description".to_string()),
|
description: FormattedText::from("description".to_string()),
|
||||||
icon: ItemSlot::Empty,
|
icon: ItemStack::Empty,
|
||||||
frame: FrameType::Task,
|
frame: FrameType::Task,
|
||||||
show_toast: true,
|
show_toast: true,
|
||||||
hidden: false,
|
hidden: false,
|
||||||
|
|
|
@ -2,7 +2,7 @@ use std::collections::HashMap;
|
||||||
|
|
||||||
use azalea_buf::McBuf;
|
use azalea_buf::McBuf;
|
||||||
use azalea_core::resource_location::ResourceLocation;
|
use azalea_core::resource_location::ResourceLocation;
|
||||||
use azalea_inventory::ItemSlot;
|
use azalea_inventory::ItemStack;
|
||||||
use azalea_protocol_macros::ClientboundGamePacket;
|
use azalea_protocol_macros::ClientboundGamePacket;
|
||||||
use azalea_registry::HolderSet;
|
use azalea_registry::HolderSet;
|
||||||
|
|
||||||
|
@ -27,7 +27,7 @@ pub struct SelectableRecipe {
|
||||||
pub enum SlotDisplayData {
|
pub enum SlotDisplayData {
|
||||||
Empty,
|
Empty,
|
||||||
AnyFuel,
|
AnyFuel,
|
||||||
Item(ItemSlotDisplay),
|
Item(ItemStackDisplay),
|
||||||
ItemStack(ItemStackSlotDisplay),
|
ItemStack(ItemStackSlotDisplay),
|
||||||
Tag(ResourceLocation),
|
Tag(ResourceLocation),
|
||||||
SmithingTrim(Box<SmithingTrimDemoSlotDisplay>),
|
SmithingTrim(Box<SmithingTrimDemoSlotDisplay>),
|
||||||
|
@ -36,12 +36,12 @@ pub enum SlotDisplayData {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, PartialEq, McBuf)]
|
#[derive(Clone, Debug, PartialEq, McBuf)]
|
||||||
pub struct ItemSlotDisplay {
|
pub struct ItemStackDisplay {
|
||||||
pub item: azalea_registry::Item,
|
pub item: azalea_registry::Item,
|
||||||
}
|
}
|
||||||
#[derive(Clone, Debug, PartialEq, McBuf)]
|
#[derive(Clone, Debug, PartialEq, McBuf)]
|
||||||
pub struct ItemStackSlotDisplay {
|
pub struct ItemStackSlotDisplay {
|
||||||
pub stack: ItemSlot,
|
pub stack: ItemStack,
|
||||||
}
|
}
|
||||||
#[derive(Clone, Debug, PartialEq, McBuf)]
|
#[derive(Clone, Debug, PartialEq, McBuf)]
|
||||||
pub struct TagSlotDisplay {
|
pub struct TagSlotDisplay {
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
|
||||||
use azalea_buf::McBuf;
|
use azalea_buf::McBuf;
|
||||||
use azalea_inventory::{operations::ClickType, ItemSlot};
|
use azalea_inventory::{operations::ClickType, ItemStack};
|
||||||
use azalea_protocol_macros::ServerboundGamePacket;
|
use azalea_protocol_macros::ServerboundGamePacket;
|
||||||
|
|
||||||
#[derive(Clone, Debug, McBuf, ServerboundGamePacket)]
|
#[derive(Clone, Debug, McBuf, ServerboundGamePacket)]
|
||||||
|
@ -12,6 +12,6 @@ pub struct ServerboundContainerClick {
|
||||||
pub slot_num: i16,
|
pub slot_num: i16,
|
||||||
pub button_num: u8,
|
pub button_num: u8,
|
||||||
pub click_type: ClickType,
|
pub click_type: ClickType,
|
||||||
pub changed_slots: HashMap<u16, ItemSlot>,
|
pub changed_slots: HashMap<u16, ItemStack>,
|
||||||
pub carried_item: ItemSlot,
|
pub carried_item: ItemStack,
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
use azalea_buf::McBuf;
|
use azalea_buf::McBuf;
|
||||||
use azalea_inventory::ItemSlot;
|
use azalea_inventory::ItemStack;
|
||||||
use azalea_protocol_macros::ServerboundGamePacket;
|
use azalea_protocol_macros::ServerboundGamePacket;
|
||||||
|
|
||||||
#[derive(Clone, Debug, McBuf, ServerboundGamePacket)]
|
#[derive(Clone, Debug, McBuf, ServerboundGamePacket)]
|
||||||
pub struct ServerboundSetCreativeModeSlot {
|
pub struct ServerboundSetCreativeModeSlot {
|
||||||
pub slot_num: u16,
|
pub slot_num: u16,
|
||||||
pub item_stack: ItemSlot,
|
pub item_stack: ItemStack,
|
||||||
}
|
}
|
||||||
|
|
|
@ -1504,8 +1504,8 @@ enum CommandArgumentKind {
|
||||||
ScoreHolder => "minecraft:score_holder",
|
ScoreHolder => "minecraft:score_holder",
|
||||||
Swizzle => "minecraft:swizzle",
|
Swizzle => "minecraft:swizzle",
|
||||||
Team => "minecraft:team",
|
Team => "minecraft:team",
|
||||||
ItemSlot => "minecraft:item_slot",
|
ItemStack => "minecraft:item_slot",
|
||||||
ItemSlots => "minecraft:item_slots",
|
ItemStacks => "minecraft:item_slots",
|
||||||
ResourceLocation => "minecraft:resource_location",
|
ResourceLocation => "minecraft:resource_location",
|
||||||
Function => "minecraft:function",
|
Function => "minecraft:function",
|
||||||
EntityAnchor => "minecraft:entity_anchor",
|
EntityAnchor => "minecraft:entity_anchor",
|
||||||
|
|
|
@ -4,7 +4,7 @@ use std::sync::Arc;
|
||||||
|
|
||||||
use azalea::{prelude::*, BlockPos};
|
use azalea::{prelude::*, BlockPos};
|
||||||
use azalea_inventory::operations::QuickMoveClick;
|
use azalea_inventory::operations::QuickMoveClick;
|
||||||
use azalea_inventory::ItemSlot;
|
use azalea_inventory::ItemStack;
|
||||||
use parking_lot::Mutex;
|
use parking_lot::Mutex;
|
||||||
|
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
|
@ -59,7 +59,7 @@ async fn handle(mut bot: Client, event: Event, state: State) -> anyhow::Result<(
|
||||||
.enumerate()
|
.enumerate()
|
||||||
{
|
{
|
||||||
println!("Checking slot {index}: {slot:?}");
|
println!("Checking slot {index}: {slot:?}");
|
||||||
if let ItemSlot::Present(item) = slot {
|
if let ItemStack::Present(item) = slot {
|
||||||
if item.kind == azalea::registry::Item::Diamond {
|
if item.kind == azalea::registry::Item::Diamond {
|
||||||
println!("clicking slot ^");
|
println!("clicking slot ^");
|
||||||
chest.click(QuickMoveClick::Left { slot: index as u16 });
|
chest.click(QuickMoveClick::Left { slot: index as u16 });
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use azalea_block::{Block, BlockState};
|
use azalea_block::{Block, BlockState};
|
||||||
use azalea_client::{inventory::Inventory, Client};
|
use azalea_client::{inventory::Inventory, Client};
|
||||||
use azalea_entity::{FluidOnEyes, Physics};
|
use azalea_entity::{FluidOnEyes, Physics};
|
||||||
use azalea_inventory::{ItemSlot, Menu};
|
use azalea_inventory::{ItemStack, Menu};
|
||||||
use azalea_registry::{DataComponentKind, Fluid};
|
use azalea_registry::{DataComponentKind, Fluid};
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
|
@ -80,7 +80,7 @@ pub fn accurate_best_tool_in_hotbar_for_block(
|
||||||
for (i, item_slot) in hotbar_slots.iter().enumerate() {
|
for (i, item_slot) in hotbar_slots.iter().enumerate() {
|
||||||
let this_item_speed;
|
let this_item_speed;
|
||||||
match item_slot {
|
match item_slot {
|
||||||
ItemSlot::Empty => {
|
ItemStack::Empty => {
|
||||||
this_item_speed = Some(azalea_entity::mining::get_mine_progress(
|
this_item_speed = Some(azalea_entity::mining::get_mine_progress(
|
||||||
block.as_ref(),
|
block.as_ref(),
|
||||||
azalea_registry::Item::Air,
|
azalea_registry::Item::Air,
|
||||||
|
@ -89,7 +89,7 @@ pub fn accurate_best_tool_in_hotbar_for_block(
|
||||||
physics,
|
physics,
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
ItemSlot::Present(item_slot) => {
|
ItemStack::Present(item_slot) => {
|
||||||
// lazy way to avoid checking durability since azalea doesn't have durability
|
// lazy way to avoid checking durability since azalea doesn't have durability
|
||||||
// data yet
|
// data yet
|
||||||
if item_slot
|
if item_slot
|
||||||
|
@ -119,7 +119,7 @@ pub fn accurate_best_tool_in_hotbar_for_block(
|
||||||
|
|
||||||
// now check every item
|
// now check every item
|
||||||
for (i, item_slot) in hotbar_slots.iter().enumerate() {
|
for (i, item_slot) in hotbar_slots.iter().enumerate() {
|
||||||
if let ItemSlot::Present(item_slot) = item_slot {
|
if let ItemStack::Present(item_slot) = item_slot {
|
||||||
let this_item_speed = azalea_entity::mining::get_mine_progress(
|
let this_item_speed = azalea_entity::mining::get_mine_progress(
|
||||||
block.as_ref(),
|
block.as_ref(),
|
||||||
item_slot.kind,
|
item_slot.kind,
|
||||||
|
|
|
@ -7,7 +7,7 @@ use azalea_client::{
|
||||||
Client,
|
Client,
|
||||||
};
|
};
|
||||||
use azalea_core::position::BlockPos;
|
use azalea_core::position::BlockPos;
|
||||||
use azalea_inventory::{operations::ClickOperation, ItemSlot, Menu};
|
use azalea_inventory::{operations::ClickOperation, ItemStack, Menu};
|
||||||
use azalea_protocol::packets::game::ClientboundGamePacket;
|
use azalea_protocol::packets::game::ClientboundGamePacket;
|
||||||
use bevy_app::{App, Plugin, Update};
|
use bevy_app::{App, Plugin, Update};
|
||||||
use bevy_ecs::{component::Component, prelude::EventReader, system::Commands};
|
use bevy_ecs::{component::Component, prelude::EventReader, system::Commands};
|
||||||
|
@ -168,7 +168,7 @@ impl ContainerHandleRef {
|
||||||
|
|
||||||
/// Returns the item slots in the container, not including the player's
|
/// Returns the item slots in the container, not including the player's
|
||||||
/// inventory. If the container is closed, this will return `None`.
|
/// inventory. If the container is closed, this will return `None`.
|
||||||
pub fn contents(&self) -> Option<Vec<ItemSlot>> {
|
pub fn contents(&self) -> Option<Vec<ItemStack>> {
|
||||||
self.menu().map(|menu| menu.contents())
|
self.menu().map(|menu| menu.contents())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -222,7 +222,7 @@ impl ContainerHandle {
|
||||||
|
|
||||||
/// Returns the item slots in the container, not including the player's
|
/// Returns the item slots in the container, not including the player's
|
||||||
/// inventory. If the container is closed, this will return `None`.
|
/// inventory. If the container is closed, this will return `None`.
|
||||||
pub fn contents(&self) -> Option<Vec<ItemSlot>> {
|
pub fn contents(&self) -> Option<Vec<ItemStack>> {
|
||||||
self.0.contents()
|
self.0.contents()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -111,7 +111,7 @@ use azalea_core::{
|
||||||
direction::Direction,
|
direction::Direction,
|
||||||
position::{BlockPos, Vec3},
|
position::{BlockPos, Vec3},
|
||||||
};
|
};
|
||||||
use azalea_inventory::ItemSlot;
|
use azalea_inventory::ItemStack;
|
||||||
use bevy_ecs::{bundle::Bundle, component::Component};
|
use bevy_ecs::{bundle::Bundle, component::Component};
|
||||||
use derive_more::{Deref, DerefMut};
|
use derive_more::{Deref, DerefMut};
|
||||||
use thiserror::Error;
|
use thiserror::Error;
|
||||||
|
@ -428,7 +428,7 @@ impl From<EntityDataValue> for UpdateMetadataError {
|
||||||
elif type_name == 'OptionalUnsignedInt':
|
elif type_name == 'OptionalUnsignedInt':
|
||||||
default = f'OptionalUnsignedInt(Some({default}))' if default != 'Empty' else 'OptionalUnsignedInt(None)'
|
default = f'OptionalUnsignedInt(Some({default}))' if default != 'Empty' else 'OptionalUnsignedInt(None)'
|
||||||
elif type_name == 'ItemStack':
|
elif type_name == 'ItemStack':
|
||||||
default = f'ItemSlot::Present({default})' if default != 'Empty' else 'ItemSlot::Empty'
|
default = f'ItemStack::Present({default})' if default != 'Empty' else 'ItemStack::Empty'
|
||||||
elif type_name == 'BlockState':
|
elif type_name == 'BlockState':
|
||||||
default = f'{default}' if default != 'Empty' else 'azalea_block::BlockState::AIR'
|
default = f'{default}' if default != 'Empty' else 'azalea_block::BlockState::AIR'
|
||||||
elif type_name == 'OptionalBlockState':
|
elif type_name == 'OptionalBlockState':
|
||||||
|
|
Loading…
Add table
Reference in a new issue