|
32 | 32 | import com.cleanroommc.modularui.widgets.layout.Grid; |
33 | 33 | import org.jetbrains.annotations.ApiStatus; |
34 | 34 | import org.jetbrains.annotations.NotNull; |
| 35 | +import org.jetbrains.annotations.Nullable; |
35 | 36 |
|
36 | 37 | import java.util.ArrayList; |
37 | 38 | import java.util.List; |
@@ -88,24 +89,24 @@ public boolean usesMui2() { |
88 | 89 | } |
89 | 90 |
|
90 | 91 | @Override |
91 | | - public ModularPanel buildUI(SidedPosGuiData guiData, PanelSyncManager guiSyncManager) { |
92 | | - guiSyncManager.registerSlotGroup("item_inv", this.storageHandler.getSlots()); |
| 92 | + public int getHeight() { |
| 93 | + return MAX_HEIGHT; |
| 94 | + } |
| 95 | + |
| 96 | + @Override |
| 97 | + public @Nullable IWidget createUI(ModularPanel mainPanel, PanelSyncManager manager) { |
| 98 | + manager.registerSlotGroup("item_inv", this.storageHandler.getSlots()); |
93 | 99 |
|
94 | 100 | int rowSize = this.storageHandler.getSlots(); |
95 | | - List<List<IWidget>> widgets = new ArrayList<>(); |
96 | | - widgets.add(new ArrayList<>()); |
| 101 | + List<IWidget> widgets = new ArrayList<>(); |
97 | 102 | for (int i = 0; i < rowSize; i++) { |
98 | | - widgets.get(0) |
99 | | - .add(new ItemSlot().slot(SyncHandlers.itemSlot(this.storageHandler, i).slotGroup("item_inv"))); |
| 103 | + widgets.add(new ItemSlot().slot(SyncHandlers.itemSlot(this.storageHandler, i).slotGroup("item_inv"))); |
100 | 104 | } |
101 | | - return GTGuis.createPanel(this, MAX_WIDTH, MAX_HEIGHT) |
102 | | - .child(IKey.lang("cover.storage.title").asWidget().pos(5, 5)) |
103 | | - .bindPlayerInventory() |
104 | | - .child(new Grid() |
105 | | - .top((MAX_HEIGHT - SLOT_SIZE * 5) / 2).left(7).right(7).height(18) |
106 | | - .minElementMargin(0, 0) |
107 | | - .minColWidth(18).minRowHeight(18) |
108 | | - .matrix(widgets)); |
| 105 | + return new Grid() |
| 106 | + .top((MAX_HEIGHT - SLOT_SIZE * 5) / 2).left(7).right(7).height(18) |
| 107 | + .minElementMargin(0, 0) |
| 108 | + .minColWidth(18).minRowHeight(18) |
| 109 | + .mapTo(rowSize, widgets, (index, value) -> value); |
109 | 110 | } |
110 | 111 |
|
111 | 112 | /** |
|
0 commit comments