mirror of
https://github.com/mat-1/azalea.git
synced 2025-08-02 14:26:04 +00:00
handle set_held_slot packet and add more Into BlockStates impls
This commit is contained in:
parent
123c15a293
commit
93a96786a8
2 changed files with 31 additions and 5 deletions
|
@ -3,6 +3,8 @@ use std::{
|
||||||
ops::{Add, RangeInclusive},
|
ops::{Add, RangeInclusive},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
use azalea_registry::Block;
|
||||||
|
|
||||||
use crate::{BlockState, block_state::BlockStateIntegerRepr};
|
use crate::{BlockState, block_state::BlockStateIntegerRepr};
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
|
@ -45,14 +47,14 @@ impl Add for BlockStates {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<HashSet<azalea_registry::Block>> for BlockStates {
|
impl From<HashSet<Block>> for BlockStates {
|
||||||
fn from(set: HashSet<azalea_registry::Block>) -> Self {
|
fn from(set: HashSet<Block>) -> Self {
|
||||||
Self::from(&set)
|
Self::from(&set)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<&HashSet<azalea_registry::Block>> for BlockStates {
|
impl From<&HashSet<Block>> for BlockStates {
|
||||||
fn from(set: &HashSet<azalea_registry::Block>) -> Self {
|
fn from(set: &HashSet<Block>) -> Self {
|
||||||
let mut block_states = HashSet::with_capacity(set.len());
|
let mut block_states = HashSet::with_capacity(set.len());
|
||||||
for &block in set {
|
for &block in set {
|
||||||
block_states.extend(BlockStates::from(block));
|
block_states.extend(BlockStates::from(block));
|
||||||
|
@ -60,3 +62,18 @@ impl From<&HashSet<azalea_registry::Block>> for BlockStates {
|
||||||
Self { set: block_states }
|
Self { set: block_states }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<const N: usize> From<[Block; N]> for BlockStates {
|
||||||
|
fn from(arr: [Block; N]) -> Self {
|
||||||
|
Self::from(&arr[..])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
impl From<&[Block]> for BlockStates {
|
||||||
|
fn from(arr: &[Block]) -> Self {
|
||||||
|
let mut block_states = HashSet::with_capacity(arr.len());
|
||||||
|
for &block in arr {
|
||||||
|
block_states.extend(BlockStates::from(block));
|
||||||
|
}
|
||||||
|
Self { set: block_states }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -1608,7 +1608,16 @@ impl GamePacketHandler<'_> {
|
||||||
pub fn store_cookie(&mut self, _p: &ClientboundStoreCookie) {}
|
pub fn store_cookie(&mut self, _p: &ClientboundStoreCookie) {}
|
||||||
pub fn transfer(&mut self, _p: &ClientboundTransfer) {}
|
pub fn transfer(&mut self, _p: &ClientboundTransfer) {}
|
||||||
pub fn move_minecart_along_track(&mut self, _p: &ClientboundMoveMinecartAlongTrack) {}
|
pub fn move_minecart_along_track(&mut self, _p: &ClientboundMoveMinecartAlongTrack) {}
|
||||||
pub fn set_held_slot(&mut self, _p: &ClientboundSetHeldSlot) {}
|
pub fn set_held_slot(&mut self, p: &ClientboundSetHeldSlot) {
|
||||||
|
debug!("Got set held slot packet {p:?}");
|
||||||
|
|
||||||
|
as_system::<Query<&mut Inventory>>(self.ecs, |mut query| {
|
||||||
|
let mut inventory = query.get_mut(self.player).unwrap();
|
||||||
|
if p.slot <= 8 {
|
||||||
|
inventory.selected_hotbar_slot = p.slot as u8;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
pub fn set_player_inventory(&mut self, _p: &ClientboundSetPlayerInventory) {}
|
pub fn set_player_inventory(&mut self, _p: &ClientboundSetPlayerInventory) {}
|
||||||
pub fn projectile_power(&mut self, _p: &ClientboundProjectilePower) {}
|
pub fn projectile_power(&mut self, _p: &ClientboundProjectilePower) {}
|
||||||
pub fn custom_report_details(&mut self, _p: &ClientboundCustomReportDetails) {}
|
pub fn custom_report_details(&mut self, _p: &ClientboundCustomReportDetails) {}
|
||||||
|
|
Loading…
Add table
Reference in a new issue