55import com .cleanroommc .modularui .api .IGuiHolder ;
66import com .cleanroommc .modularui .factory .GuiFactories ;
77import com .cleanroommc .modularui .factory .PlayerInventoryGuiData ;
8+ import com .cleanroommc .modularui .factory .inventory .InventoryTypes ;
89import com .cleanroommc .modularui .screen .ModularPanel ;
910import com .cleanroommc .modularui .screen .UISettings ;
1011import com .cleanroommc .modularui .utils .Alignment ;
1718import com .cleanroommc .modularui .widgets .SlotGroupWidget ;
1819import com .cleanroommc .modularui .widgets .layout .Column ;
1920import com .cleanroommc .modularui .widgets .slot .ItemSlot ;
21+ import com .cleanroommc .modularui .widgets .slot .ModularSlot ;
2022
2123import net .minecraft .client .util .ITooltipFlag ;
2224import net .minecraft .entity .player .EntityPlayer ;
@@ -52,6 +54,14 @@ public ModularPanel buildUI(PlayerInventoryGuiData guiData, PanelSyncManager gui
5254 IItemHandlerModifiable itemHandler = (IItemHandlerModifiable ) guiData .getUsedItemStack ().getCapability (CapabilityItemHandler .ITEM_HANDLER_CAPABILITY , null );
5355 guiSyncManager .registerSlotGroup ("mixer_items" , 2 );
5456
57+ // if the player slot is the slot with this item, then disallow any interaction
58+ // if the item is not in the player inventory (bauble for example), then this items slot is not on the screen, and we don't need to
59+ // accessibility
60+ if (guiData .getInventoryType () == InventoryTypes .PLAYER ) {
61+ guiSyncManager .bindPlayerInventory (guiData .getPlayer (), (inv , index ) -> index == guiData .getSlotIndex () ?
62+ new ModularSlot (inv , index ).accessibility (false , false ) :
63+ new ModularSlot (inv , index ));
64+ }
5565 ModularPanel panel = ModularPanel .defaultPanel ("knapping_gui" ).resizeableOnDrag (true );
5666 panel .child (new Column ().margin (7 )
5767 .child (new ParentWidget <>().widthRel (1f ).expanded ()
@@ -61,6 +71,8 @@ public ModularPanel buildUI(PlayerInventoryGuiData guiData, PanelSyncManager gui
6171 .key ('I' , index -> new ItemSlot ().slot (SyncHandlers .itemSlot (itemHandler , index )
6272 .ignoreMaxStackSize (true )
6373 .slotGroup ("mixer_items" )
74+ // do not allow putting items which can hold other items into the item
75+ // some mods don't do this on their backpacks, so it won't catch those cases
6476 .filter (stack -> !stack .hasCapability (CapabilityItemHandler .ITEM_HANDLER_CAPABILITY , null ))))
6577 .build ()
6678 .align (Alignment .Center )))
0 commit comments