1919import java .util .Deque ;
2020import java .util .List ;
2121import java .util .Locale ;
22+ import java .util .Set ;
2223import java .util .UUID ;
2324import net .minecraft .client .gui .screens .Screen ;
2425import net .minecraft .client .player .LocalPlayer ;
@@ -62,6 +63,30 @@ public class ItemHandlerHack extends Hack
6263 // and avoids pathological behavior.
6364 private static final double INFINITE_SCAN_RADIUS = 1024.0 ;
6465 private static final int WHITELIST_TICKS = 3 ;
66+ private static final Set <String > DEFAULT_MOB_EQUIPMENT_IDS =
67+ Set .of ("minecraft:bow" , "minecraft:crossbow" , "minecraft:trident" ,
68+ "minecraft:wooden_sword" , "minecraft:stone_sword" ,
69+ "minecraft:iron_sword" , "minecraft:golden_sword" ,
70+ "minecraft:wooden_axe" , "minecraft:stone_axe" , "minecraft:iron_axe" ,
71+ "minecraft:golden_axe" , "minecraft:wooden_pickaxe" ,
72+ "minecraft:stone_pickaxe" , "minecraft:iron_pickaxe" ,
73+ "minecraft:golden_pickaxe" , "minecraft:wooden_shovel" ,
74+ "minecraft:stone_shovel" , "minecraft:iron_shovel" ,
75+ "minecraft:golden_shovel" , "minecraft:wooden_hoe" ,
76+ "minecraft:stone_hoe" , "minecraft:iron_hoe" , "minecraft:golden_hoe" ,
77+ "minecraft:leather_helmet" , "minecraft:leather_chestplate" ,
78+ "minecraft:leather_leggings" , "minecraft:leather_boots" ,
79+ "minecraft:chainmail_helmet" , "minecraft:chainmail_chestplate" ,
80+ "minecraft:chainmail_leggings" , "minecraft:chainmail_boots" ,
81+ "minecraft:iron_helmet" , "minecraft:iron_chestplate" ,
82+ "minecraft:iron_leggings" , "minecraft:iron_boots" ,
83+ "minecraft:golden_helmet" , "minecraft:golden_chestplate" ,
84+ "minecraft:golden_leggings" , "minecraft:golden_boots" );
85+ private static final String [] DEFAULT_MOB_EQUIPMENT_MATERIALS =
86+ {"copper" , "steel" , "gold" , "golden" };
87+ private static final String [] DEFAULT_MOB_EQUIPMENT_SUFFIXES =
88+ {"_helmet" , "_chestplate" , "_leggings" , "_boots" , "_sword" , "_axe" ,
89+ "_pickaxe" , "_shovel" , "_hoe" , "_spear" };
6590
6691 private final List <GroundItem > trackedItems = new ArrayList <>();
6792 private final Int2IntOpenHashMap pickupWhitelist = new Int2IntOpenHashMap ();
@@ -105,9 +130,13 @@ public class ItemHandlerHack extends Hack
105130
106131 // Include items held or worn by mobs
107132 private final CheckboxSetting includeMobEquipment =
108- new CheckboxSetting ("Detect mob equipment " ,
133+ new CheckboxSetting ("Detect held/worn mob items " ,
109134 "Also detect items held or worn by mobs." , false );
110135
136+ private final CheckboxSetting filterDefaultMobEquipment =
137+ new CheckboxSetting ("Filter default mob items" ,
138+ "Hide common mob gear (gold/iron/stone/chain/etc)." , false );
139+
111140 // Reduce extremes so offsets cannot go off-screen entirely.
112141 private final SliderSetting hudOffsetX = new SliderSetting (
113142 "Popup HUD offset X" , -105 , -300 , 300 , 1 , ValueDisplay .INTEGER );
@@ -125,6 +154,7 @@ public ItemHandlerHack()
125154 addSetting (hudEnabled );
126155 addSetting (showRegistryName );
127156 addSetting (includeMobEquipment );
157+ addSetting (filterDefaultMobEquipment );
128158 addSetting (respectItemEspIgnores );
129159 addSetting (itemEspIgnoredListSetting );
130160 addSetting (rejectRadius );
@@ -502,6 +532,39 @@ private boolean shouldTrack(ItemEntity entity)
502532 && !entity .getItem ().isEmpty ();
503533 }
504534
535+ private boolean shouldTrackMobEquipment (ItemStack stack )
536+ {
537+ if (stack == null || stack .isEmpty ())
538+ return false ;
539+ if (isIgnoredByItemEsp (stack ))
540+ return false ;
541+ return !filterDefaultMobEquipment .isChecked ()
542+ || !isDefaultMobEquipment (stack );
543+ }
544+
545+ private boolean isDefaultMobEquipment (ItemStack stack )
546+ {
547+ if (stack == null || stack .isEmpty ())
548+ return false ;
549+ String id = net .minecraft .core .registries .BuiltInRegistries .ITEM
550+ .getKey (stack .getItem ()).toString ();
551+ if (DEFAULT_MOB_EQUIPMENT_IDS .contains (id ))
552+ return true ;
553+ String path = net .minecraft .core .registries .BuiltInRegistries .ITEM
554+ .getKey (stack .getItem ()).getPath ();
555+ for (String material : DEFAULT_MOB_EQUIPMENT_MATERIALS )
556+ {
557+ if (!path .contains (material ))
558+ continue ;
559+ for (String suffix : DEFAULT_MOB_EQUIPMENT_SUFFIXES )
560+ {
561+ if (path .endsWith (suffix ))
562+ return true ;
563+ }
564+ }
565+ return false ;
566+ }
567+
505568 private void addMobEquipmentItems (LocalPlayer player , double scanRadius )
506569 {
507570 if (player == null || MC .level == null )
@@ -522,14 +585,14 @@ private void addMobEquipmentItems(LocalPlayer player, double scanRadius)
522585 String mobName = le .getName ().getString ();
523586
524587 ItemStack main = le .getMainHandItem ();
525- if (main != null && ! main . isEmpty () && ! isIgnoredByItemEsp (main ))
588+ if (shouldTrackMobEquipment (main ))
526589 {
527590 Vec3 pos = getHeldItemPos (le , InteractionHand .MAIN_HAND );
528591 addMobTrackedItem (le , main , pos , SourceType .MOB_HELD , mobName );
529592 }
530593
531594 ItemStack off = le .getOffhandItem ();
532- if (off != null && ! off . isEmpty () && ! isIgnoredByItemEsp (off ))
595+ if (shouldTrackMobEquipment (off ))
533596 {
534597 Vec3 pos = getHeldItemPos (le , InteractionHand .OFF_HAND );
535598 addMobTrackedItem (le , off , pos , SourceType .MOB_HELD , mobName );
@@ -539,8 +602,7 @@ private void addMobEquipmentItems(LocalPlayer player, double scanRadius)
539602 EquipmentSlot .CHEST , EquipmentSlot .LEGS , EquipmentSlot .FEET })
540603 {
541604 ItemStack armor = le .getItemBySlot (slot );
542- if (armor == null || armor .isEmpty ()
543- || isIgnoredByItemEsp (armor ))
605+ if (!shouldTrackMobEquipment (armor ))
544606 continue ;
545607 Vec3 pos = getArmorPos (le , slot );
546608 addMobTrackedItem (le , armor , pos , SourceType .MOB_WORN , mobName );
0 commit comments