Fixed Window not being set for Items of nested GUIs

This commit is contained in:
NichtStudioCode 2021-05-03 19:48:52 +02:00
parent dd80927b46
commit 01cff674f0

@ -77,14 +77,19 @@ public abstract class BaseWindow implements Window {
} }
} }
// tell the Item or VirtualInventory that it is being displayed in this Window if (element != null) {
if (element instanceof ItemSlotElement) { // tell the Item or VirtualInventory that it is being displayed in this Window
((ItemSlotElement) element).getItem().addWindow(this); SlotElement holdingElement = element.getHoldingElement();
} else if (element instanceof VISlotElement) { if (holdingElement instanceof ItemSlotElement) {
((VISlotElement) element).getVirtualInventory().addWindow(this); ((ItemSlotElement) holdingElement).getItem().addWindow(this);
} } else if (holdingElement instanceof VISlotElement) {
((VISlotElement) holdingElement).getVirtualInventory().addWindow(this);
}
elementsDisplayed[index] = element; elementsDisplayed[index] = holdingElement;
} else {
elementsDisplayed[index] = null;
}
} }
} }