Skip to content

Commit 6086da9

Browse files
committed
Don't use anonymous class to hide tooltip in Machine Hatches
1 parent abffbac commit 6086da9

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

src/main/java/gregtech/common/metatileentities/multi/multiblockpart/MetaTileEntityMachineHatch.java

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
import com.cleanroommc.modularui.drawable.GuiDraw;
2727
import com.cleanroommc.modularui.factory.PosGuiData;
2828
import com.cleanroommc.modularui.screen.ModularPanel;
29-
import com.cleanroommc.modularui.screen.viewport.ModularGuiContext;
29+
import com.cleanroommc.modularui.screen.RichTooltip;
3030
import com.cleanroommc.modularui.value.sync.PanelSyncManager;
3131
import com.cleanroommc.modularui.value.sync.SyncHandlers;
3232
import com.cleanroommc.modularui.widgets.ItemSlot;
@@ -80,16 +80,19 @@ public ModularPanel buildUI(PosGuiData guiData, PanelSyncManager guiSyncManager)
8080
return GTGuis.createPanel(this, 176, 18 + 18 + 94)
8181
.child(IKey.lang(getMetaFullName()).asWidget().pos(5, 5))
8282
.child(SlotGroupWidget.playerInventory().left(7).bottom(7))
83-
.child(new ItemSlot() {
84-
85-
// Don't draw tooltip if the slot is blocked
86-
@Override
87-
public void drawForeground(ModularGuiContext context) {
88-
if (!isSlotBlocked()) super.drawForeground(context);
89-
}
90-
}
83+
.child(new ItemSlot()
9184
.slot(SyncHandlers.itemSlot(machineHandler, 0)
9285
.slotGroup("item_inv"))
86+
.tooltip(t -> t.setAutoUpdate(false))
87+
.onUpdateListener(itemSlot -> {
88+
RichTooltip tooltip = itemSlot.tooltip();
89+
if (isSlotBlocked()) {
90+
tooltip.buildTooltip();
91+
tooltip.clearText();
92+
} else if (tooltip.isEmpty()) {
93+
tooltip.markDirty();
94+
}
95+
})
9396
.overlay((context, x, y, width, height, widgetTheme) -> GuiDraw.drawRect(x, y, width, height,
9497
0x80404040))
9598
.left(79).top(18));

0 commit comments

Comments
 (0)