Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Recipe Outputs in GUI of Multiblocks with RecipeMap #2673

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -5821,6 +5821,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
Loading