|
11 | 11 | import com.gregtechceu.gtceu.api.machine.feature.multiblock.*; |
12 | 12 | import com.gregtechceu.gtceu.api.machine.multiblock.part.TieredPartMachine; |
13 | 13 | import com.gregtechceu.gtceu.api.machine.trait.NotifiableItemStackHandler; |
| 14 | +import com.gregtechceu.gtceu.api.mui.factory.PosGuiData; |
| 15 | +import com.gregtechceu.gtceu.api.mui.utils.Alignment; |
| 16 | +import com.gregtechceu.gtceu.api.mui.value.sync.BooleanSyncValue; |
| 17 | +import com.gregtechceu.gtceu.api.mui.value.sync.IntSyncValue; |
| 18 | +import com.gregtechceu.gtceu.api.mui.value.sync.PanelSyncManager; |
| 19 | +import com.gregtechceu.gtceu.api.mui.widget.ParentWidget; |
| 20 | +import com.gregtechceu.gtceu.api.mui.widgets.SlotGroupWidget; |
| 21 | +import com.gregtechceu.gtceu.api.mui.widgets.layout.Flow; |
| 22 | +import com.gregtechceu.gtceu.api.mui.widgets.slot.ItemSlot; |
| 23 | +import com.gregtechceu.gtceu.api.mui.widgets.slot.ModularSlot; |
| 24 | +import com.gregtechceu.gtceu.api.mui.widgets.slot.SlotGroup; |
| 25 | +import com.gregtechceu.gtceu.client.mui.screen.ModularPanel; |
| 26 | +import com.gregtechceu.gtceu.client.mui.screen.UISettings; |
14 | 27 | import com.gregtechceu.gtceu.common.data.GTDamageTypes; |
15 | 28 | import com.gregtechceu.gtceu.common.data.GTMaterials; |
| 29 | +import com.gregtechceu.gtceu.common.data.mui.GTMuiWidgets; |
16 | 30 | import com.gregtechceu.gtceu.common.item.TurbineRotorBehaviour; |
17 | 31 |
|
| 32 | +import com.gregtechceu.gtceu.common.mui.GTGuiTextures; |
18 | 33 | import com.lowdragmc.lowdraglib.syncdata.ISubscription; |
19 | 34 | import com.lowdragmc.lowdraglib.syncdata.annotation.DescSynced; |
20 | 35 | import com.lowdragmc.lowdraglib.syncdata.annotation.Persisted; |
@@ -167,7 +182,7 @@ private void updateRotorSpeed() { |
167 | 182 | if (isFormed() && getControllers().first() instanceof IWorkableMultiController workable) { |
168 | 183 | if (workable.getRecipeLogic().isWorking()) return; |
169 | 184 | } |
170 | | - if (!hasRotor()) { |
| 185 | + if (!hasRotor() || !isFormed()) { |
171 | 186 | setRotorSpeed(0); |
172 | 187 | } else if (getRotorSpeed() > 0) { |
173 | 188 | setRotorSpeed(Math.max(0, getRotorSpeed() - SPEED_DECREMENT)); |
@@ -229,6 +244,46 @@ public InteractionResult onUse(BlockState state, Level level, BlockPos pos, Play |
229 | 244 | ////////////////////////////////////// |
230 | 245 | // ********** GUI ***********// |
231 | 246 | ////////////////////////////////////// |
| 247 | + |
| 248 | + // TODO MUI: Might need EIO widget? Not sure |
| 249 | + @Override |
| 250 | + public @NotNull ModularPanel buildUI(@NotNull PosGuiData data, @NotNull PanelSyncManager syncManager, |
| 251 | + @NotNull UISettings settings) { |
| 252 | + SlotGroup rotorSlotGroup = new SlotGroup("rotor", 1); |
| 253 | + |
| 254 | + |
| 255 | + |
| 256 | + var slot = new ItemSlot() |
| 257 | + .slot(new ModularSlot(inventory, 0) |
| 258 | + .slotGroup(rotorSlotGroup)) |
| 259 | + .background(GTGuiTextures.SLOT, GTGuiTextures.TURBINE_OVERLAY) |
| 260 | + .marginLeft(30) |
| 261 | + .marginRight(30) |
| 262 | + .verticalCenter(); |
| 263 | + |
| 264 | + var rotorSync = new IntSyncValue(this::getRotorSpeed, (speed) -> {}); |
| 265 | + rotorSync.setChangeListener(() -> { |
| 266 | + boolean canEdit = rotorSync.getIntValue() == 0; |
| 267 | + slot.getSlot().accessibility(canEdit, canEdit); |
| 268 | + }); |
| 269 | + |
| 270 | + |
| 271 | + syncManager.syncValue("rotor_speed", rotorSync); |
| 272 | + |
| 273 | + return new ModularPanel(this.getDefinition().getName()) |
| 274 | + .size(176, 100 + (18 * 4)) |
| 275 | + .child(GTMuiWidgets.createTitleBar(this.getDefinition(), 176)) |
| 276 | + .child(new ParentWidget<>() |
| 277 | + .widthRel(1) |
| 278 | + .height(20 + 18 * 4) |
| 279 | + .child(Flow.row() |
| 280 | + .crossAxisAlignment(Alignment.CrossAxis.CENTER) |
| 281 | + .align(Alignment.CENTER) |
| 282 | + .coverChildren() |
| 283 | + .child(slot))) |
| 284 | + .child(SlotGroupWidget.playerInventory(false).left(7).bottom(7)); |
| 285 | + } |
| 286 | + |
232 | 287 | /* |
233 | 288 | * @Override |
234 | 289 | * public Widget createUIWidget() { |
|
0 commit comments