This update implements slot filtering for the Android entity's inventory system, ensuring that items can only be placed in appropriate slots.
- Purpose: Only accepts armor items matching the specific equipment slot type
- Location: Slots 1-4 (boots=1, leggings=2, chestplate=3, helmet=4)
- Filtering: Uses component-based armor detection that works with vanilla and modded armor
- Visual: Uses vanilla armor slot background sprites (helmet, chestplate, leggings, boots)
- Purpose: Only accepts chip items from ModItems.CHIP
- Location: Slots 6-8 (first 3 general slots converted to chip slots)
- Filtering: Only allows ModItems.CHIP items
- Visual: Currently uses default slot background (can be enhanced with custom texture)
- Purpose: Accepts weapons, tools, and general items but excludes armor
- Location: Slot 0 (main hand)
- Filtering: Rejects armor items using component detection, allows everything else
- Visual: Uses vanilla sword icon for empty slot
- Purpose: Accepts shields and secondary items but excludes armor
- Location: Slot 5 (offhand)
- Filtering: Rejects armor items using component detection, allows everything else
- Visual: Uses vanilla shield icon for empty slot
- Purpose: Accepts general items but excludes armor and chips
- Location: Slots 9-11 (remaining general inventory)
- Filtering: Rejects armor items and chip items using component detection
- Visual: Uses default slot background
- Imports: Added custom slot imports and EquipmentSlot
- Slot Creation: Replaced generic Slot instances with appropriate filtered slots
- Armor Slot Mapping: Fixed slot indices to match EquipmentSlot.getIndex() values
- QuickMove: Simplified to rely on Slot.canInsert() filtering
Slot Index | Type | Purpose | Position
-----------|-------------|-------------------|----------
0 | MainHand | Weapons/Tools | (81, 8)
1 | ArmorSlot | Boots | (8, 62)
2 | ArmorSlot | Leggings | (8, 44)
3 | ArmorSlot | Chestplate | (8, 26)
4 | ArmorSlot | Helmet | (8, 8)
5 | OffHand | Shields/Secondary | (81, 26)
6-8 | ChipSlot | Chips Only | Top right row
9-11 | GeneralSlot | General Items | Bottom right row
The armor detection system uses Minecraft's component system for robust compatibility:
- Component-Based: Uses
DataComponentTypes.EQUIPPABLEandEquippableComponent - Modded Compatibility: Works with any armor that properly implements the equippable component
- Vanilla Support: Full support for all vanilla armor types
- Equipment Slot Matching: Precise slot type detection for armor filtering
isArmor(ItemStack): Detects any armor item using component dataisArmorOfType(ItemStack, EquipmentSlot): Matches armor to specific equipment slots
A test class SlotFilteringTest has been created to verify filtering behavior:
- Armor slots only accept matching armor types
- Chip slots only accept chip items
- Main hand rejects armor but accepts other items
- General slots reject both armor and chips
- Empty stacks are properly rejected by all slots
- Armor slots show appropriate empty slot icons (helmet, chestplate, leggings, boots)
- Main hand shows sword icon when empty
- Offhand shows shield icon when empty
- Icons only display when slots are empty (like vanilla player inventory)
- Maintains backward compatibility with existing inventory structure
- Respects Minecraft's EquipmentSlot system for armor items
- Full modded armor support through component-based detection
- Works with shift-click (quickMove) operations
- Follows vanilla UI patterns for empty slot icons