Skip to content

Commit 581391e

Browse files
committed
Recipe Outputs in GUI
1 parent 7141fcf commit 581391e

File tree

3 files changed

+46
-1
lines changed

3 files changed

+46
-1
lines changed

src/main/java/gregtech/api/metatileentity/multiblock/MultiblockDisplayText.java

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,17 @@
22

33
import gregtech.api.GTValues;
44
import gregtech.api.capability.IEnergyContainer;
5+
import gregtech.api.recipes.Recipe;
56
import gregtech.api.util.GTUtility;
67
import gregtech.api.util.TextComponentUtil;
78
import gregtech.api.util.TextFormattingUtil;
89
import gregtech.common.ConfigHolder;
910

11+
import net.minecraft.item.ItemStack;
1012
import net.minecraft.util.text.*;
13+
import net.minecraftforge.fluids.FluidStack;
14+
15+
import org.jetbrains.annotations.Nullable;
1116

1217
import java.util.List;
1318
import java.util.function.Consumer;
@@ -478,5 +483,42 @@ public Builder addCustom(Consumer<List<ITextComponent>> customConsumer) {
478483
customConsumer.accept(textList);
479484
return this;
480485
}
486+
487+
/** While the Multiblock is active, add lines which display the outputs of the currently run recipe. */
488+
public Builder addRecipeOutputsLine(@Nullable Recipe recipe) {
489+
if (!isStructureFormed || !isActive) {
490+
return this;
491+
}
492+
if (recipe == null) {
493+
return this;
494+
}
495+
if (!recipe.getAllItemOutputs().isEmpty()) {
496+
textList.add(TextComponentUtil.translationWithColor(TextFormatting.GRAY,
497+
"gregtech.multiblock.recipe_outputs", itemOutputsToString(recipe.getAllItemOutputs())));
498+
}
499+
if (!recipe.getAllFluidOutputs().isEmpty()) {
500+
textList.add(TextComponentUtil.translationWithColor(TextFormatting.GRAY,
501+
"gregtech.multiblock.recipe_outputs", fluidOutputsToString(recipe.getAllFluidOutputs())));
502+
}
503+
return this;
504+
}
505+
506+
private String fluidOutputsToString(List<FluidStack> stacks) {
507+
StringBuilder output = new StringBuilder();
508+
for (FluidStack stack : stacks) {
509+
output.append(stack.amount).append("L of ").append(stack.getLocalizedName()).append(", ");
510+
}
511+
String str = output.toString();
512+
return str.substring(0, str.length() - 2);
513+
}
514+
515+
private String itemOutputsToString(List<ItemStack> stacks) {
516+
StringBuilder output = new StringBuilder();
517+
for (ItemStack stack : stacks) {
518+
output.append(stack.getCount()).append("x ").append(stack.getDisplayName()).append(", ");
519+
}
520+
String str = output.toString();
521+
return str.substring(0, str.length() - 2);
522+
}
481523
}
482524
}

src/main/java/gregtech/api/metatileentity/multiblock/RecipeMapMultiblockController.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,8 @@ protected void addDisplayText(List<ITextComponent> textList) {
151151
.addEnergyTierLine(GTUtility.getTierByVoltage(recipeMapWorkable.getMaxVoltage()))
152152
.addParallelsLine(recipeMapWorkable.getParallelLimit())
153153
.addWorkingStatusLine()
154-
.addProgressLine(recipeMapWorkable.getProgressPercent());
154+
.addProgressLine(recipeMapWorkable.getProgressPercent())
155+
.addRecipeOutputsLine(recipeMapWorkable.getPreviousRecipe());
155156
}
156157

157158
@Override

src/main/resources/assets/gregtech/lang/en_us.lang

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5817,6 +5817,8 @@ gregtech.multiblock.hpca.info_coolant_name=PCB Coolant
58175817
gregtech.multiblock.hpca.info_bridging_enabled=Bridging Enabled
58185818
gregtech.multiblock.hpca.info_bridging_disabled=Bridging Disabled
58195819

5820+
gregtech.multiblock.recipe_outputs=Crafting: %s
5821+
58205822
gregtech.command.usage=Usage: /gregtech <worldgen/hand/recipecheck/datafix>
58215823
gregtech.command.worldgen.usage=Usage: /gregtech worldgen <reload>
58225824
gregtech.command.worldgen.reload.usage=Usage: /gregtech worldgen reload

0 commit comments

Comments
 (0)