Skip to content

Commit 2d2c600

Browse files
committed
Circuit slot in input hatches
1 parent 9b3e7fc commit 2d2c600

File tree

3 files changed

+39
-3
lines changed

3 files changed

+39
-3
lines changed

src/main/java/gregtech/common/metatileentities/multi/multiblockpart/appeng/MetaTileEntityMEInputBase.java

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import gregtech.api.mui.GTGuiTextures;
1010
import gregtech.api.mui.GTGuis;
1111
import gregtech.api.mui.sync.appeng.AEFluidSyncHandler;
12+
import gregtech.api.mui.sync.appeng.AESyncHandler;
1213
import gregtech.api.mui.widget.GhostCircuitSlotWidget;
1314
import gregtech.api.util.GTUtility;
1415
import gregtech.common.ConfigHolder;
@@ -146,11 +147,15 @@ public boolean usesMui2() {
146147
return true;
147148
}
148149

150+
protected abstract @NotNull AESyncHandler<AEStackType> createAESyncHandler();
151+
149152
@Override
150153
public ModularPanel buildUI(PosGuiData guiData, PanelSyncManager panelSyncManager) {
151154
ModularPanel mainPanel = GTGuis.createPanel(this, 176, 18 + 18 * 4 + 94);
152155
final boolean isStocking = getAEHandler().isStocking();
153156

157+
panelSyncManager.syncValue(SYNC_HANDLER_NAME, 0, createAESyncHandler());
158+
154159
return mainPanel.child(IKey.lang(getMetaFullName())
155160
.asWidget()
156161
.pos(5, 5))
@@ -191,14 +196,19 @@ public ModularPanel buildUI(PosGuiData guiData, PanelSyncManager panelSyncManage
191196
@NotNull PanelSyncManager panelSyncManager) {
192197
return switch (index) {
193198
case 1 -> GTGuiTextures.ARROW_DOUBLE.asWidget();
194-
case 2 -> new GhostCircuitSlotWidget()
195-
.slot(SyncHandlers.itemSlot(circuitInventory, 0))
196-
.background(GTGuiTextures.SLOT, GTGuiTextures.INT_CIRCUIT_OVERLAY);
199+
case 2 -> createGhostCircuitWidget();
197200
default -> new Widget<>()
198201
.size(18);
199202
};
200203
}
201204

205+
protected @NotNull GhostCircuitSlotWidget createGhostCircuitWidget() {
206+
// Grrr generics .background only returns ItemSlot
207+
return (GhostCircuitSlotWidget) new GhostCircuitSlotWidget()
208+
.slot(SyncHandlers.itemSlot(circuitInventory, 0))
209+
.background(GTGuiTextures.SLOT, GTGuiTextures.INT_CIRCUIT_OVERLAY);
210+
}
211+
202212
protected Widget<?> getSettingWidget(@NotNull PosGuiData guiData, @NotNull PanelSyncManager guiSyncManager) {
203213
IPanelHandler settingPopup = guiSyncManager.panel("settings_panel", this::buildSettingsPopup, true);
204214

src/main/java/gregtech/common/metatileentities/multi/multiblockpart/appeng/MetaTileEntityMEInputBus.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
import gregtech.api.metatileentity.multiblock.MultiblockAbility;
1212
import gregtech.api.metatileentity.multiblock.MultiblockControllerBase;
1313
import gregtech.api.mui.GTGuiTextures;
14+
import gregtech.api.mui.sync.appeng.AEItemSyncHandler;
15+
import gregtech.api.mui.sync.appeng.AESyncHandler;
1416
import gregtech.api.mui.widget.appeng.item.AEItemConfigSlot;
1517
import gregtech.api.mui.widget.appeng.item.AEItemDisplaySlot;
1618
import gregtech.api.util.GTUtility;
@@ -115,6 +117,11 @@ public void removeFromMultiBlock(MultiblockControllerBase controllerBase) {
115117
}
116118
}
117119

120+
@Override
121+
protected @NotNull AESyncHandler<IAEItemStack> createAESyncHandler() {
122+
return new AEItemSyncHandler(getAEHandler(), this::markDirty, circuitInventory::setCircuitValue);
123+
}
124+
118125
@Override
119126
protected @NotNull Widget<?> createMainColumnWidget(@Range(from = 0, to = 3) int index, @NotNull PosGuiData guiData,
120127
@NotNull PanelSyncManager panelSyncManager) {

src/main/java/gregtech/common/metatileentities/multi/multiblockpart/appeng/MetaTileEntityMEInputHatch.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
import gregtech.api.metatileentity.multiblock.IMultiblockAbilityPart;
99
import gregtech.api.metatileentity.multiblock.MultiblockAbility;
1010
import gregtech.api.mui.GTGuiTextures;
11+
import gregtech.api.mui.sync.appeng.AEFluidSyncHandler;
12+
import gregtech.api.mui.sync.appeng.AESyncHandler;
1113
import gregtech.api.mui.widget.appeng.fluid.AEFluidConfigSlot;
1214
import gregtech.api.mui.widget.appeng.fluid.AEFluidDisplaySlot;
1315
import gregtech.client.renderer.texture.Textures;
@@ -39,6 +41,7 @@
3941
import com.cleanroommc.modularui.widgets.layout.Grid;
4042
import org.jetbrains.annotations.NotNull;
4143
import org.jetbrains.annotations.Nullable;
44+
import org.jetbrains.annotations.Range;
4245

4346
import java.util.Arrays;
4447
import java.util.List;
@@ -73,6 +76,22 @@ protected void initializeInventory() {
7376
return (ExportOnlyAEFluidList) aeHandler;
7477
}
7578

79+
@Override
80+
protected @NotNull AESyncHandler<IAEFluidStack> createAESyncHandler() {
81+
return new AEFluidSyncHandler(getAEHandler(), this::markDirty, circuitInventory::setCircuitValue);
82+
}
83+
84+
@Override
85+
protected @NotNull Widget<?> createMainColumnWidget(@Range(from = 0, to = 3) int index, @NotNull PosGuiData guiData,
86+
@NotNull PanelSyncManager panelSyncManager) {
87+
return switch (index) {
88+
case 2 -> new Widget<>()
89+
.size(18);
90+
case 3 -> createGhostCircuitWidget();
91+
default -> super.createMainColumnWidget(index, guiData, panelSyncManager);
92+
};
93+
}
94+
7695
@Override
7796
protected @NotNull Widget<?> createConfigGrid(@NotNull PosGuiData guiData,
7897
@NotNull PanelSyncManager panelSyncManager) {

0 commit comments

Comments
 (0)