|
16 | 16 | import gregtech.api.metatileentity.multiblock.MultiblockAbility; |
17 | 17 | import gregtech.api.metatileentity.multiblock.MultiblockDisplayText; |
18 | 18 | import gregtech.api.metatileentity.multiblock.RecipeMapMultiblockController; |
| 19 | +import gregtech.api.metatileentity.multiblock.ui.MultiblockUIFactory; |
19 | 20 | import gregtech.api.pattern.BlockPattern; |
20 | 21 | import gregtech.api.pattern.FactoryBlockPattern; |
21 | 22 | import gregtech.api.pattern.PatternMatchContext; |
|
26 | 27 | import gregtech.api.recipes.logic.OCResult; |
27 | 28 | import gregtech.api.recipes.properties.RecipePropertyStorage; |
28 | 29 | import gregtech.api.util.GTUtility; |
| 30 | +import gregtech.api.util.KeyUtil; |
29 | 31 | import gregtech.api.util.TextComponentUtil; |
30 | 32 | import gregtech.api.util.TextFormattingUtil; |
31 | 33 | import gregtech.client.renderer.ICubeRenderer; |
|
49 | 51 | import net.minecraftforge.fml.relauncher.SideOnly; |
50 | 52 | import net.minecraftforge.items.IItemHandlerModifiable; |
51 | 53 |
|
| 54 | +import com.cleanroommc.modularui.api.drawable.IKey; |
| 55 | +import com.cleanroommc.modularui.value.sync.DoubleSyncValue; |
| 56 | +import com.cleanroommc.modularui.value.sync.IntSyncValue; |
52 | 57 | import org.apache.commons.lang3.ArrayUtils; |
53 | 58 | import org.jetbrains.annotations.NotNull; |
54 | 59 | import org.jetbrains.annotations.Nullable; |
@@ -174,6 +179,73 @@ protected void addDisplayText(List<ITextComponent> textList) { |
174 | 179 | .addProgressLine(recipeMapWorkable.getProgressPercent()); |
175 | 180 | } |
176 | 181 |
|
| 182 | + @Override |
| 183 | + protected MultiblockUIFactory createUIFactory() { |
| 184 | + ProcessingArrayWorkable logic = (ProcessingArrayWorkable) recipeMapWorkable; |
| 185 | + |
| 186 | + DoubleSyncValue progress = new DoubleSyncValue(recipeMapWorkable::getProgressPercent, null); |
| 187 | + IntSyncValue tier = new IntSyncValue(() -> logic.currentMachineStack.isEmpty() ? -1 : logic.machineTier, null); |
| 188 | + return new MultiblockUIFactory(this) |
| 189 | + .syncValue("progress", progress) |
| 190 | + .syncValue("tier", tier) |
| 191 | + .configureDisplayText(builder -> builder |
| 192 | + .setWorkingStatus(recipeMapWorkable::isWorkingEnabled, recipeMapWorkable::isActive) |
| 193 | + .addEnergyUsageLine(this::getEnergyContainer) |
| 194 | + .addEnergyTierLine(tier.getIntValue()) |
| 195 | + .addCustom(richText -> { |
| 196 | + if (!isStructureFormed()) return; |
| 197 | + |
| 198 | + // Machine mode text |
| 199 | + // Shared text components for both states |
| 200 | + IKey maxMachinesText = KeyUtil.string(TextFormatting.DARK_PURPLE, |
| 201 | + Integer.toString(getMachineLimit())); |
| 202 | + maxMachinesText = KeyUtil.lang(TextFormatting.GRAY, |
| 203 | + "gregtech.machine.machine_hatch.machines_max", maxMachinesText); |
| 204 | + |
| 205 | + if (logic.activeRecipeMap == null) { |
| 206 | + // No machines in hatch |
| 207 | + IKey noneText = KeyUtil.lang(TextFormatting.YELLOW, |
| 208 | + "gregtech.machine.machine_hatch.machines_none"); |
| 209 | + IKey bodyText = KeyUtil.lang(TextFormatting.GRAY, |
| 210 | + "gregtech.machine.machine_hatch.machines", noneText); |
| 211 | + IKey hoverText1 = KeyUtil.lang(TextFormatting.GRAY, |
| 212 | + "gregtech.machine.machine_hatch.machines_none_hover"); |
| 213 | + richText.addLine(KeyUtil.setHover(bodyText, hoverText1, maxMachinesText)); |
| 214 | + } else { |
| 215 | + // Some amount of machines in hatch |
| 216 | + String key = logic.getMachineStack().getTranslationKey(); |
| 217 | + IKey mapText = KeyUtil.lang(TextFormatting.DARK_PURPLE, |
| 218 | + key + ".name"); |
| 219 | + mapText = KeyUtil.lang( |
| 220 | + TextFormatting.DARK_PURPLE, |
| 221 | + "%sx %s", |
| 222 | + logic.getParallelLimit(), mapText); |
| 223 | + IKey bodyText = KeyUtil.lang(TextFormatting.GRAY, |
| 224 | + "gregtech.machine.machine_hatch.machines", mapText); |
| 225 | + String voltageName = GTValues.VNF[logic.machineTier]; |
| 226 | + int amps = logic.getMachineStack().getCount(); |
| 227 | + String energyFormatted = TextFormattingUtil |
| 228 | + .formatNumbers(GTValues.V[logic.machineTier] * amps); |
| 229 | + IKey hoverText = KeyUtil.lang( |
| 230 | + TextFormatting.GRAY, |
| 231 | + "gregtech.machine.machine_hatch.machines_max_eut", |
| 232 | + energyFormatted, amps, voltageName); |
| 233 | + richText.addLine(KeyUtil.setHover(bodyText, hoverText, maxMachinesText)); |
| 234 | + } |
| 235 | + |
| 236 | + // Hatch locked status |
| 237 | + if (isActive()) { |
| 238 | + richText.addLine(KeyUtil.lang(TextFormatting.DARK_RED, |
| 239 | + "gregtech.machine.machine_hatch.locked")); |
| 240 | + } |
| 241 | + }) |
| 242 | + .addParallelsLine(recipeMapWorkable.getParallelLimit()) |
| 243 | + .addWorkingStatusLine() |
| 244 | + .addProgressLine(progress::getDoubleValue)) |
| 245 | + .configureWarningText(builder -> builder |
| 246 | + .addLowPowerLine(recipeMapWorkable.isHasNotEnoughEnergy())); |
| 247 | + } |
| 248 | + |
177 | 249 | @SideOnly(Side.CLIENT) |
178 | 250 | @NotNull |
179 | 251 | @Override |
|
0 commit comments