Skip to content

Commit

Permalink
change DataComponentPatch::get to take in a generic (and add get_kind…
Browse files Browse the repository at this point in the history
…, has, and has_kind)
  • Loading branch information
mat-1 committed Nov 28, 2024
1 parent 08958c2 commit c36201c
Show file tree
Hide file tree
Showing 6 changed files with 262 additions and 87 deletions.
5 changes: 2 additions & 3 deletions azalea-client/src/interact.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,13 @@ use azalea_core::{
use azalea_entity::{
clamp_look_direction, view_vector, Attributes, EyeHeight, LocalEntity, LookDirection, Position,
};
use azalea_inventory::{ItemStack, ItemStackData};
use azalea_inventory::{components, ItemStack, ItemStackData};
use azalea_physics::clip::{BlockShapeType, ClipContext, FluidPickType};
use azalea_protocol::packets::game::{
s_interact::InteractionHand,
s_swing::ServerboundSwing,
s_use_item_on::{BlockHit, ServerboundUseItemOn},
};
use azalea_registry::DataComponentKind;
use azalea_world::{Instance, InstanceContainer, InstanceName};
use bevy_app::{App, Plugin, Update};
use bevy_ecs::{
Expand Down Expand Up @@ -268,7 +267,7 @@ pub fn check_block_can_be_broken_by_item_in_adventure_mode(
// minecraft caches the last checked block but that's kind of an unnecessary
// optimization and makes the code too complicated

let Some(_can_destroy) = item.components.get(DataComponentKind::CanBreak) else {
if !item.components.has::<components::CanBreak>() {
// no CanDestroy tag
return false;
};
Expand Down
5 changes: 2 additions & 3 deletions azalea-core/src/position.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ use std::{
};

use azalea_buf::{AzBuf, AzaleaRead, AzaleaWrite, BufReadError};
use serde::{Deserialize, Serialize};

use crate::resource_location::ResourceLocation;

Expand Down Expand Up @@ -213,7 +212,7 @@ macro_rules! vec3_impl {
/// Used to represent an exact position in the world where an entity could be.
/// For blocks, [`BlockPos`] is used instead.
#[derive(Clone, Copy, Debug, Default, PartialEq, AzBuf)]
#[cfg_attr(feature = "serde", derive(Deserialize, Serialize))]
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
pub struct Vec3 {
pub x: f64,
pub y: f64,
Expand All @@ -238,7 +237,7 @@ impl Vec3 {
/// The coordinates of a block in the world. For entities (if the coordinate
/// with decimals), use [`Vec3`] instead.
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
#[cfg_attr(feature = "serde", derive(Deserialize, Serialize))]
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
pub struct BlockPos {
pub x: i32,
pub y: i32,
Expand Down
Loading

0 comments on commit c36201c

Please sign in to comment.