@@ -4,6 +4,7 @@ use std::{cell::Cell, cmp::min, num::Wrapping};
44use derive_more:: { Deref , DerefMut } ;
55use flecs_ecs:: { core:: Entity , macros:: Component } ;
66use tracing:: debug;
7+ use valence_generated:: item:: EquipmentSlot ;
78use valence_protocol:: {
89 ItemKind , ItemStack ,
910 nbt:: Compound ,
@@ -544,56 +545,22 @@ pub trait ItemKindExt {
544545
545546impl ItemKindExt for ItemKind {
546547 fn is_helmet ( & self ) -> bool {
547- matches ! (
548- self ,
549- Self :: LeatherHelmet
550- | Self :: ChainmailHelmet
551- | Self :: IronHelmet
552- | Self :: GoldenHelmet
553- | Self :: DiamondHelmet
554- | Self :: NetheriteHelmet
555- | Self :: TurtleHelmet
556- | Self :: PlayerHead
557- )
548+ matches ! ( self . equippable( ) , Some ( EquipmentSlot :: Helmet ) )
558549 }
559550
560551 fn is_chestplate ( & self ) -> bool {
561- matches ! (
562- self ,
563- Self :: LeatherChestplate
564- | Self :: ChainmailChestplate
565- | Self :: IronChestplate
566- | Self :: GoldenChestplate
567- | Self :: DiamondChestplate
568- | Self :: NetheriteChestplate
569- )
552+ matches ! ( self . equippable( ) , Some ( EquipmentSlot :: Chestplate ) )
570553 }
571554
572555 fn is_leggings ( & self ) -> bool {
573- matches ! (
574- self ,
575- Self :: LeatherLeggings
576- | Self :: ChainmailLeggings
577- | Self :: IronLeggings
578- | Self :: GoldenLeggings
579- | Self :: DiamondLeggings
580- | Self :: NetheriteLeggings
581- )
556+ matches ! ( self . equippable( ) , Some ( EquipmentSlot :: Leggings ) )
582557 }
583558
584559 fn is_boots ( & self ) -> bool {
585- matches ! (
586- self ,
587- Self :: LeatherBoots
588- | Self :: ChainmailBoots
589- | Self :: IronBoots
590- | Self :: GoldenBoots
591- | Self :: DiamondBoots
592- | Self :: NetheriteBoots
593- )
560+ matches ! ( self . equippable( ) , Some ( EquipmentSlot :: Boots ) )
594561 }
595562
596563 fn is_armor ( & self ) -> bool {
597- self . is_helmet ( ) || self . is_chestplate ( ) || self . is_leggings ( ) || self . is_boots ( )
564+ self . equippable ( ) . is_some ( )
598565 }
599566}
0 commit comments