@@ -19,15 +19,13 @@ public partial class BagItem : SlotItem
1919{
2020 // Controls
2121 private readonly Label _quantityLabel ;
22- private readonly BagWindow _bagWindow ;
2322
2423 // Context Menu Handling
2524 private readonly MenuItem _withdrawContextItem ;
2625
27- public BagItem ( BagWindow bagWindow , Base parent , int index , ContextMenu contextMenu )
26+ public BagItem ( Base parent , int index , ContextMenu contextMenu )
2827 : base ( parent , nameof ( BagItem ) , index , contextMenu )
2928 {
30- _bagWindow = bagWindow ;
3129 TextureFilename = "bagitem.png" ;
3230
3331 Icon . HoverEnter += Icon_HoverEnter ;
@@ -145,6 +143,16 @@ private void Icon_DoubleClicked(Base sender, MouseButtonState arguments)
145143
146144 public override bool DragAndDrop_HandleDrop ( Package package , int x , int y )
147145 {
146+ if ( Globals . Me is not { } player )
147+ {
148+ return false ;
149+ }
150+
151+ if ( Globals . BagSlots is not { Length : > 0 } bagSlots )
152+ {
153+ return false ;
154+ }
155+
148156 var targetNode = Interface . FindComponentUnderCursor ( ) ;
149157
150158 // Find the first parent acceptable in that tree that can accept the package
@@ -154,11 +162,11 @@ public override bool DragAndDrop_HandleDrop(Package package, int x, int y)
154162 {
155163 case BagItem bagItem :
156164 PacketSender . SendMoveBagItems ( SlotIndex , bagItem . SlotIndex ) ;
157- return true ;
165+ return bagSlots [ bagItem . SlotIndex ] is not { Quantity : > 0 } ;
158166
159167 case InventoryItem inventoryItem :
160- Globals . Me ? . TryRetrieveItemFromBag ( SlotIndex , inventoryItem . SlotIndex ) ;
161- return true ;
168+ player . TryRetrieveItemFromBag ( SlotIndex , inventoryItem . SlotIndex ) ;
169+ return bagSlots [ inventoryItem . SlotIndex ] is not { Quantity : > 0 } ;
162170
163171 default :
164172 targetNode = targetNode . Parent ;
0 commit comments