Skip to content

Commit 26ff967

Browse files
committed
Fluid Drill multiblock
1 parent e8b8bcc commit 26ff967

File tree

3 files changed

+48
-38
lines changed

3 files changed

+48
-38
lines changed

src/main/java/gregtech/api/fluids/GTFluid.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package gregtech.api.fluids;
22

3+
import com.cleanroommc.modularui.api.drawable.IKey;
4+
35
import gregtech.api.fluids.attribute.AttributedFluid;
46
import gregtech.api.fluids.attribute.FluidAttribute;
57
import gregtech.api.unification.material.Material;
@@ -78,6 +80,23 @@ public GTMaterialFluid(@NotNull String fluidName, ResourceLocation still, Resour
7880
return localizedName;
7981
}
8082

83+
public @NotNull IKey toIKey() {
84+
IKey localizedName;
85+
String customMaterialTranslation = "fluid." + material.getUnlocalizedName();
86+
87+
if (net.minecraft.util.text.translation.I18n.canTranslate(customMaterialTranslation)) {
88+
localizedName = IKey.lang(customMaterialTranslation);
89+
} else {
90+
localizedName = IKey.lang(material.getUnlocalizedName());
91+
}
92+
93+
if (translationKey != null) {
94+
return IKey.lang(translationKey, localizedName);
95+
}
96+
97+
return localizedName;
98+
}
99+
81100
@Override
82101
@SideOnly(Side.CLIENT)
83102
public String getLocalizedName(FluidStack stack) {

src/main/java/gregtech/api/util/GTUtility.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package gregtech.api.util;
22

3+
import com.cleanroommc.modularui.api.drawable.IKey;
4+
35
import gregtech.api.GTValues;
46
import gregtech.api.GregTechAPI;
57
import gregtech.api.block.machines.MachineItemBlock;
@@ -894,6 +896,15 @@ public static TextComponentTranslation getFluidTranslation(@Nullable Fluid fluid
894896
return new TextComponentTranslation(fluid.getUnlocalizedName());
895897
}
896898

899+
@Contract("null -> null")
900+
public static IKey getFluidIKey(@Nullable Fluid fluid) {
901+
if (fluid == null) return null;
902+
if (fluid instanceof GTFluid.GTMaterialFluid materialFluid) {
903+
return materialFluid.toIKey();
904+
}
905+
return IKey.lang(fluid.getUnlocalizedName());
906+
}
907+
897908
public static @NotNull Pair<DoubleSupplier, DoubleSupplier> createPairedSupplier(int ticksPerCycle, int width,
898909
double splitPoint) {
899910
AtomicDouble tracker = new AtomicDouble(0.0);

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

Lines changed: 18 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -164,60 +164,40 @@ public ICubeRenderer getBaseTexture(IMultiblockPart sourcePart) {
164164
}
165165

166166
@Override
167-
protected void addDisplayText(List<ITextComponent> textList) {
168-
MultiblockDisplayText.builder(textList, isStructureFormed())
169-
.setWorkingStatus(minerLogic.isWorkingEnabled(), minerLogic.isActive())
167+
protected void configureDisplayText(MultiblockUIFactory.Builder builder) {
168+
builder.setWorkingStatus(minerLogic.isWorkingEnabled(), minerLogic.isActive())
170169
.setWorkingStatusKeys(
171170
"gregtech.multiblock.idling",
172171
"gregtech.multiblock.work_paused",
173172
"gregtech.multiblock.miner.drilling")
174173
.addEnergyUsageLine(energyContainer)
175-
.addCustom(tl -> {
174+
.addCustom(list -> {
176175
if (isStructureFormed()) {
177176
if (minerLogic.getDrilledFluid() != null) {
178177
// Fluid name
179178
Fluid drilledFluid = minerLogic.getDrilledFluid();
180-
ITextComponent fluidInfo = TextComponentUtil
181-
.setColor(GTUtility.getFluidTranslation(drilledFluid), TextFormatting.GREEN);
182-
tl.add(TextComponentUtil.translationWithColor(
183-
TextFormatting.GRAY,
184-
"gregtech.multiblock.fluid_rig.drilled_fluid",
185-
fluidInfo));
186-
187-
// Fluid amount
188-
ITextComponent amountInfo = TextComponentUtil.stringWithColor(
189-
TextFormatting.BLUE,
190-
TextFormattingUtil.formatNumbers(
191-
minerLogic.getFluidToProduce() * 20L / FluidDrillLogic.MAX_PROGRESS) +
192-
" L/s");
193-
tl.add(TextComponentUtil.translationWithColor(
194-
TextFormatting.GRAY,
195-
"gregtech.multiblock.fluid_rig.fluid_amount",
196-
amountInfo));
179+
IKey fluidInfo = GTUtility.getFluidIKey(drilledFluid).style(TextFormatting.GREEN);
180+
list.add(KeyUtil.lang(TextFormatting.GRAY, "gregtech.multiblock.fluid_rig.drilled_fluid", fluidInfo));
181+
182+
IKey amountInfo = KeyUtil.lang(TextFormatting.BLUE, TextFormattingUtil.formatNumbers(minerLogic.getFluidToProduce() * 20L / FluidDrillLogic.MAX_PROGRESS) + " L/s");
183+
list.add(KeyUtil.lang(TextFormatting.GRAY, "gregtech.multiblock.fluid_rig.fluid_amount", amountInfo));
197184
} else {
198-
ITextComponent noFluid = TextComponentUtil.translationWithColor(TextFormatting.RED,
199-
"gregtech.multiblock.fluid_rig.no_fluid_in_area");
200-
tl.add(TextComponentUtil.translationWithColor(
201-
TextFormatting.GRAY,
202-
"gregtech.multiblock.fluid_rig.drilled_fluid",
203-
noFluid));
185+
IKey noFluid = KeyUtil.lang(TextFormatting.RED, "gregtech.multiblock.fluid_rig.no_fluid_in_area");
186+
list.add(KeyUtil.lang(TextFormatting.GRAY, "gregtech.multiblock.fluid_rig.drilled_fluid", noFluid));
204187
}
205188
}
206189
})
207-
.addWorkingStatusLine()
208-
.addProgressLine(minerLogic.getProgressPercent());
190+
.addProgressLine(minerLogic.getProgressPercent())
191+
.addWorkingStatusLine();
209192
}
210193

211194
@Override
212-
protected void addWarningText(List<ITextComponent> textList) {
213-
MultiblockDisplayText.builder(textList, isStructureFormed(), false)
214-
.addLowPowerLine(isStructureFormed() && !drainEnergy(true))
215-
.addCustom(tl -> {
216-
if (isStructureFormed() && minerLogic.isInventoryFull()) {
217-
tl.add(TextComponentUtil.translationWithColor(
218-
TextFormatting.YELLOW,
219-
"gregtech.machine.miner.invfull"));
220-
}
195+
protected void configureWarningText(MultiblockUIFactory.Builder builder) {
196+
builder.addLowPowerLine(isStructureFormed() && !drainEnergy(true))
197+
.addCustom(list -> {
198+
if (isStructureFormed() && minerLogic.isInventoryFull()) {
199+
list.add(KeyUtil.lang(TextFormatting.YELLOW, "gregtech.machine.miner.invfull"));
200+
}
221201
});
222202
}
223203

0 commit comments

Comments
 (0)