Skip to content

Commit 7bf7c3c

Browse files
committed
port HPCA, research station, cracking unit
1 parent 1a6cab4 commit 7bf7c3c

File tree

3 files changed

+175
-0
lines changed

3 files changed

+175
-0
lines changed

src/main/java/gregtech/common/metatileentities/multi/electric/MetaTileEntityCrackingUnit.java

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,15 @@
77
import gregtech.api.metatileentity.multiblock.IMultiblockPart;
88
import gregtech.api.metatileentity.multiblock.MultiblockDisplayText;
99
import gregtech.api.metatileentity.multiblock.RecipeMapMultiblockController;
10+
import gregtech.api.metatileentity.multiblock.ui.MultiblockUIFactory;
1011
import gregtech.api.pattern.BlockPattern;
1112
import gregtech.api.pattern.FactoryBlockPattern;
1213
import gregtech.api.pattern.PatternMatchContext;
1314
import gregtech.api.recipes.RecipeMaps;
1415
import gregtech.api.recipes.logic.OCResult;
1516
import gregtech.api.recipes.properties.RecipePropertyStorage;
1617
import gregtech.api.util.GTUtility;
18+
import gregtech.api.util.KeyUtil;
1719
import gregtech.api.util.TextComponentUtil;
1820
import gregtech.client.renderer.ICubeRenderer;
1921
import gregtech.client.renderer.texture.Textures;
@@ -32,6 +34,9 @@
3234
import net.minecraftforge.fml.relauncher.Side;
3335
import net.minecraftforge.fml.relauncher.SideOnly;
3436

37+
import com.cleanroommc.modularui.api.drawable.IKey;
38+
import com.cleanroommc.modularui.value.sync.DoubleSyncValue;
39+
import com.cleanroommc.modularui.value.sync.IntSyncValue;
3540
import org.jetbrains.annotations.NotNull;
3641
import org.jetbrains.annotations.Nullable;
3742

@@ -108,6 +113,41 @@ protected void addDisplayText(List<ITextComponent> textList) {
108113
.addProgressLine(recipeMapWorkable.getProgressPercent());
109114
}
110115

116+
@Override
117+
protected MultiblockUIFactory createUIFactory() {
118+
DoubleSyncValue progress = new DoubleSyncValue(recipeMapWorkable::getProgressPercent, null);
119+
IntSyncValue tier = new IntSyncValue(() -> GTUtility.getTierByVoltage(recipeMapWorkable.getMaxVoltage()), null);
120+
return new MultiblockUIFactory(this)
121+
.syncValue("progress", progress)
122+
.syncValue("tier", tier)
123+
.configureDisplayText(builder -> builder
124+
.setWorkingStatus(recipeMapWorkable::isWorkingEnabled, recipeMapWorkable::isActive)
125+
.addEnergyUsageLine(this::getEnergyContainer)
126+
.addEnergyTierLine(tier.getIntValue())
127+
.addCustom(richText -> {
128+
if (!isStructureFormed()) return;
129+
130+
// Coil energy discount line
131+
IKey energyDiscount = KeyUtil.number(TextFormatting.AQUA,
132+
100 - 10L * coilTier, "%");
133+
134+
IKey base = KeyUtil.lang(TextFormatting.GRAY,
135+
"gregtech.multiblock.cracking_unit.energy",
136+
energyDiscount);
137+
138+
IKey hover = KeyUtil.lang(
139+
TextFormatting.GRAY,
140+
"gregtech.multiblock.cracking_unit.energy_hover");
141+
142+
richText.addLine(KeyUtil.setHover(base, hover));
143+
})
144+
.addParallelsLine(recipeMapWorkable.getParallelLimit())
145+
.addWorkingStatusLine()
146+
.addProgressLine(progress::getDoubleValue))
147+
.configureWarningText(builder -> builder
148+
.addLowPowerLine(recipeMapWorkable.isHasNotEnoughEnergy()));
149+
}
150+
111151
@Override
112152
public void addInformation(ItemStack stack, @Nullable World player, List<String> tooltip, boolean advanced) {
113153
super.addInformation(stack, player, tooltip, advanced);

src/main/java/gregtech/common/metatileentities/multi/electric/MetaTileEntityHPCA.java

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import gregtech.api.pattern.PatternMatchContext;
2121
import gregtech.api.unification.material.Materials;
2222
import gregtech.api.util.GTUtility;
23+
import gregtech.api.util.KeyUtil;
2324
import gregtech.api.util.RelativeDirection;
2425
import gregtech.api.util.TextComponentUtil;
2526
import gregtech.api.util.TextFormattingUtil;
@@ -55,6 +56,8 @@
5556
import codechicken.lib.render.pipeline.IVertexOperation;
5657
import codechicken.lib.vec.Matrix4;
5758
import com.cleanroommc.modularui.api.drawable.IKey;
59+
import com.cleanroommc.modularui.api.drawable.IRichTextBuilder;
60+
import com.cleanroommc.modularui.value.sync.BooleanSyncValue;
5861
import com.cleanroommc.modularui.value.sync.DoubleSyncValue;
5962
import com.cleanroommc.modularui.value.sync.IntSyncValue;
6063
import com.cleanroommc.modularui.value.sync.PanelSyncManager;
@@ -453,6 +456,79 @@ protected void addErrorText(List<ITextComponent> textList) {
453456
}
454457
}
455458

459+
@Override
460+
protected MultiblockUIFactory createUIFactory() {
461+
IntSyncValue curCWUt = new IntSyncValue(() -> hpcaHandler.cachedCWUt, null);
462+
IntSyncValue maxCWUt = new IntSyncValue(hpcaHandler::getMaxCWUt, null);
463+
BooleanSyncValue hasNoEnergy = new BooleanSyncValue(() -> hasNotEnoughEnergy, null);
464+
DoubleSyncValue temp = new DoubleSyncValue(() -> temperature, null);
465+
466+
return new MultiblockUIFactory(this)
467+
.syncValue("cur_cwut", curCWUt)
468+
.syncValue("max_cwut", maxCWUt)
469+
.syncValue("no_energy", hasNoEnergy)
470+
.syncValue("temp", temp)
471+
.configureDisplayText(builder -> builder
472+
.setWorkingStatus(() -> true, () -> hpcaHandler.getAllocatedCWUt() > 0)
473+
.setWorkingStatusKeys(
474+
"gregtech.multiblock.idling",
475+
"gregtech.multiblock.idling",
476+
"gregtech.multiblock.data_bank.providing")
477+
.addCustom(richText -> {
478+
if (!isStructureFormed()) return;
479+
480+
// Energy Usage
481+
String voltageName = GTValues.VNF[GTUtility.getTierByVoltage(hpcaHandler.getMaxEUt())];
482+
richText.addLine(KeyUtil.lang(TextFormatting.GRAY,
483+
"gregtech.multiblock.hpca.energy",
484+
TextFormattingUtil.formatNumbers(curCWUt.getIntValue()),
485+
TextFormattingUtil.formatNumbers(maxCWUt.getIntValue()),
486+
voltageName));
487+
488+
// Provided Computation
489+
IKey cwutInfo = KeyUtil.string(TextFormatting.AQUA,
490+
curCWUt.getIntValue() + " / " + maxCWUt.getIntValue() + " CWU/t");
491+
492+
richText.addLine(KeyUtil.lang(TextFormatting.GRAY,
493+
"gregtech.multiblock.hpca.computation",
494+
cwutInfo));
495+
})
496+
.addWorkingStatusLine())
497+
.configureWarningText(builder -> builder
498+
.addLowPowerLine(hasNoEnergy.getBoolValue())
499+
.addCustom(richText -> {
500+
if (!isStructureFormed()) return;
501+
502+
if (temp.getDoubleValue() > 500) {
503+
// Temperature warning
504+
richText.add(KeyUtil.lang(
505+
TextFormatting.YELLOW,
506+
"gregtech.multiblock.hpca.warning_temperature"));
507+
508+
// Active cooler overdrive warning
509+
richText.add(KeyUtil.lang(
510+
TextFormatting.GRAY,
511+
"gregtech.multiblock.hpca.warning_temperature_active_cool"));
512+
}
513+
514+
// Structure warnings
515+
// hpcaHandler.addWarnings(richText);
516+
hpcaHandler.addWarnings2(richText);
517+
})
518+
.addMaintenanceProblemLines(getMaintenanceProblems()))
519+
.configureErrorText(builder -> builder
520+
.addCustom(richText -> {
521+
if (!isStructureFormed()) return;
522+
523+
if (temp.getDoubleValue() > 1000) {
524+
richText.addLine(KeyUtil.lang(TextFormatting.RED,
525+
"gregtech.multiblock.hpca.error_temperature"));
526+
}
527+
// hpcaHandler.addErrors(textList);
528+
hpcaHandler.addErrors2(richText);
529+
}));
530+
}
531+
456532
@Override
457533
public void addInformation(ItemStack stack, @Nullable World world, @NotNull List<String> tooltip,
458534
boolean advanced) {
@@ -923,6 +999,37 @@ public void addErrors(List<ITextComponent> textList) {
923999
}
9241000
}
9251001

1002+
public void addWarnings2(IRichTextBuilder<?> richText) {
1003+
List<IKey> warnings = new ArrayList<>();
1004+
if (numBridges > 1) {
1005+
warnings.add(KeyUtil.lang(TextFormatting.GRAY,
1006+
"gregtech.multiblock.hpca.warning_multiple_bridges"));
1007+
}
1008+
if (computationProviders.isEmpty()) {
1009+
warnings.add(KeyUtil.lang(TextFormatting.GRAY,
1010+
"gregtech.multiblock.hpca.warning_no_computation"));
1011+
}
1012+
if (getMaxCoolingDemand() > getMaxCoolingAmount()) {
1013+
warnings.add(KeyUtil.lang(TextFormatting.GRAY,
1014+
"gregtech.multiblock.hpca.warning_low_cooling"));
1015+
}
1016+
if (!warnings.isEmpty()) {
1017+
richText.addLine(KeyUtil.lang(TextFormatting.YELLOW,
1018+
"gregtech.multiblock.hpca.warning_structure_header"));
1019+
warnings.forEach(richText::addLine);
1020+
}
1021+
}
1022+
1023+
public void addErrors2(IRichTextBuilder<?> richText) {
1024+
for (IHPCAComponentHatch component : components) {
1025+
if (component.isDamaged()) {
1026+
richText.addLine(KeyUtil.lang(TextFormatting.RED,
1027+
"gregtech.multiblock.hpca.error_damaged"));
1028+
return;
1029+
}
1030+
}
1031+
}
1032+
9261033
public TextureArea getComponentTexture(int index) {
9271034
if (components.size() <= index) {
9281035
return GuiTextures.BLANK_TRANSPARENT;

src/main/java/gregtech/common/metatileentities/multi/electric/MetaTileEntityResearchStation.java

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import gregtech.api.metatileentity.multiblock.MultiblockAbility;
1414
import gregtech.api.metatileentity.multiblock.MultiblockDisplayText;
1515
import gregtech.api.metatileentity.multiblock.RecipeMapMultiblockController;
16+
import gregtech.api.metatileentity.multiblock.ui.MultiblockUIFactory;
1617
import gregtech.api.pattern.BlockPattern;
1718
import gregtech.api.pattern.FactoryBlockPattern;
1819
import gregtech.api.pattern.MultiblockShapeInfo;
@@ -39,6 +40,8 @@
3940
import net.minecraftforge.fml.relauncher.SideOnly;
4041
import net.minecraftforge.items.IItemHandlerModifiable;
4142

43+
import com.cleanroommc.modularui.value.sync.DoubleSyncValue;
44+
import com.cleanroommc.modularui.value.sync.IntSyncValue;
4245
import org.jetbrains.annotations.NotNull;
4346
import org.jetbrains.annotations.Nullable;
4447

@@ -246,6 +249,31 @@ protected void addWarningText(List<ITextComponent> textList) {
246249
.addMaintenanceProblemLines(getMaintenanceProblems());
247250
}
248251

252+
@Override
253+
protected MultiblockUIFactory createUIFactory() {
254+
DoubleSyncValue progress = new DoubleSyncValue(recipeMapWorkable::getProgressPercent, null);
255+
IntSyncValue tier = new IntSyncValue(() -> GTUtility.getTierByVoltage(recipeMapWorkable.getMaxVoltage()), null);
256+
return new MultiblockUIFactory(this)
257+
.syncValue("progress", progress)
258+
.syncValue("tier", tier)
259+
.configureDisplayText(builder -> builder
260+
.setWorkingStatus(recipeMapWorkable::isWorkingEnabled, recipeMapWorkable::isActive)
261+
.setWorkingStatusKeys(
262+
"gregtech.multiblock.idling",
263+
"gregtech.multiblock.work_paused",
264+
"gregtech.machine.research_station.researching")
265+
.addEnergyUsageLine(recipeMapWorkable::getEnergyContainer)
266+
.addEnergyTierLine(tier.getIntValue())
267+
.addComputationUsageExactLine(getRecipeMapWorkable().getCurrentDrawnCWUt())
268+
.addParallelsLine(recipeMapWorkable.getParallelLimit())
269+
.addWorkingStatusLine()
270+
.addProgressLine(progress::getDoubleValue))
271+
.configureWarningText(builder -> builder
272+
.addLowPowerLine(recipeMapWorkable.isHasNotEnoughEnergy())
273+
.addLowComputationLine(getRecipeMapWorkable().isHasNotEnoughComputation())
274+
.addMaintenanceProblemLines(getMaintenanceProblems()));
275+
}
276+
249277
private static class ResearchStationRecipeLogic extends ComputationRecipeLogic {
250278

251279
public ResearchStationRecipeLogic(MetaTileEntityResearchStation metaTileEntity) {

0 commit comments

Comments
 (0)