Skip to content

Commit

Permalink
Recipe Outputs in GUI
Browse files Browse the repository at this point in the history
  • Loading branch information
Rundas01 committed Nov 29, 2024
1 parent 7141fcf commit 581391e
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,17 @@

import gregtech.api.GTValues;
import gregtech.api.capability.IEnergyContainer;
import gregtech.api.recipes.Recipe;
import gregtech.api.util.GTUtility;
import gregtech.api.util.TextComponentUtil;
import gregtech.api.util.TextFormattingUtil;
import gregtech.common.ConfigHolder;

import net.minecraft.item.ItemStack;
import net.minecraft.util.text.*;
import net.minecraftforge.fluids.FluidStack;

import org.jetbrains.annotations.Nullable;

import java.util.List;
import java.util.function.Consumer;
Expand Down Expand Up @@ -478,5 +483,42 @@ public Builder addCustom(Consumer<List<ITextComponent>> customConsumer) {
customConsumer.accept(textList);
return this;
}

/** While the Multiblock is active, add lines which display the outputs of the currently run recipe. */
public Builder addRecipeOutputsLine(@Nullable Recipe recipe) {
if (!isStructureFormed || !isActive) {
return this;
}
if (recipe == null) {
return this;
}
if (!recipe.getAllItemOutputs().isEmpty()) {
textList.add(TextComponentUtil.translationWithColor(TextFormatting.GRAY,
"gregtech.multiblock.recipe_outputs", itemOutputsToString(recipe.getAllItemOutputs())));
}
if (!recipe.getAllFluidOutputs().isEmpty()) {
textList.add(TextComponentUtil.translationWithColor(TextFormatting.GRAY,
"gregtech.multiblock.recipe_outputs", fluidOutputsToString(recipe.getAllFluidOutputs())));
}
return this;
}

private String fluidOutputsToString(List<FluidStack> stacks) {
StringBuilder output = new StringBuilder();
for (FluidStack stack : stacks) {
output.append(stack.amount).append("L of ").append(stack.getLocalizedName()).append(", ");
}
String str = output.toString();
return str.substring(0, str.length() - 2);
}

private String itemOutputsToString(List<ItemStack> stacks) {
StringBuilder output = new StringBuilder();
for (ItemStack stack : stacks) {
output.append(stack.getCount()).append("x ").append(stack.getDisplayName()).append(", ");
}
String str = output.toString();
return str.substring(0, str.length() - 2);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,8 @@ protected void addDisplayText(List<ITextComponent> textList) {
.addEnergyTierLine(GTUtility.getTierByVoltage(recipeMapWorkable.getMaxVoltage()))
.addParallelsLine(recipeMapWorkable.getParallelLimit())
.addWorkingStatusLine()
.addProgressLine(recipeMapWorkable.getProgressPercent());
.addProgressLine(recipeMapWorkable.getProgressPercent())
.addRecipeOutputsLine(recipeMapWorkable.getPreviousRecipe());
}

@Override
Expand Down
2 changes: 2 additions & 0 deletions src/main/resources/assets/gregtech/lang/en_us.lang
Original file line number Diff line number Diff line change
Expand Up @@ -5817,6 +5817,8 @@ gregtech.multiblock.hpca.info_coolant_name=PCB Coolant
gregtech.multiblock.hpca.info_bridging_enabled=Bridging Enabled
gregtech.multiblock.hpca.info_bridging_disabled=Bridging Disabled

gregtech.multiblock.recipe_outputs=Crafting: %s

gregtech.command.usage=Usage: /gregtech <worldgen/hand/recipecheck/datafix>
gregtech.command.worldgen.usage=Usage: /gregtech worldgen <reload>
gregtech.command.worldgen.reload.usage=Usage: /gregtech worldgen reload
Expand Down

0 comments on commit 581391e

Please sign in to comment.