Skip to content

Commit

Permalink
More Tweaker Information in JEI Recipe Display (#2638)
Browse files Browse the repository at this point in the history
  • Loading branch information
IntegerLimit authored Oct 11, 2024
1 parent 869be2a commit 63518f9
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 5 deletions.
27 changes: 22 additions & 5 deletions src/main/java/gregtech/integration/jei/recipe/GTRecipeWrapper.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import gregtech.api.util.AssemblyLineManager;
import gregtech.api.util.ClipboardUtil;
import gregtech.api.util.GTUtility;
import gregtech.api.util.LocalizationUtils;
import gregtech.api.util.TextFormattingUtil;
import gregtech.client.utils.TooltipHelper;
import gregtech.integration.RecipeCompatUtil;
Expand Down Expand Up @@ -309,15 +310,22 @@ public List<String> getTooltipStrings(int mouseX, int mouseY) {

@Override
public void initExtras() {
// do not add the X button if no tweaker mod is present
// do not add the info or X button if no tweaker mod is present
if (!RecipeCompatUtil.isTweakerLoaded()) return;

BooleanSupplier creativePlayerCtPredicate = () -> Minecraft.getMinecraft().player != null &&
BooleanSupplier creativePlayerPredicate = () -> Minecraft.getMinecraft().player != null &&
Minecraft.getMinecraft().player.isCreative();
BooleanSupplier creativeTweaker = () -> creativePlayerPredicate.getAsBoolean() &&
(recipe.getIsCTRecipe() || recipe.isGroovyRecipe());
BooleanSupplier creativeDefault = () -> creativePlayerPredicate.getAsBoolean() && !recipe.getIsCTRecipe() &&
!recipe.isGroovyRecipe();

// X Button
buttons.add(new JeiButton(166, 2, 10, 10)
.setTextures(GuiTextures.BUTTON_CLEAR_GRID)
.setTooltipBuilder(lines -> lines.add("Copies a " + RecipeCompatUtil.getTweakerName() +
" script, to remove this recipe, to the clipboard"))
.setTooltipBuilder(lines -> lines.add(
LocalizationUtils.format("gregtech.jei.remove_recipe.tooltip",
RecipeCompatUtil.getTweakerName())))
.setClickAction((minecraft, mouseX, mouseY, mouseButton) -> {
String recipeLine = RecipeCompatUtil.getRecipeRemoveLine(recipeMap, recipe);
String output = RecipeCompatUtil.getFirstOutputString(recipe);
Expand All @@ -330,7 +338,16 @@ public void initExtras() {
new TextComponentString("Copied [\u00A76" + recipeLine + "\u00A7r] to the clipboard"));
return true;
})
.setActiveSupplier(creativePlayerCtPredicate));
.setActiveSupplier(creativeDefault));

// CT/GS Info
buttons.add(new JeiButton(166, 2, 10, 10)
.setTextures(GuiTextures.INFO_ICON)
.setTooltipBuilder(lines -> lines.add(recipe.isGroovyRecipe() ?
LocalizationUtils.format("gregtech.jei.gs_recipe.tooltip") :
LocalizationUtils.format("gregtech.jei.ct_recipe.tooltip")))
.setClickAction((mc, x, y, button) -> false)
.setActiveSupplier(creativeTweaker));
}

public ChancedItemOutput getOutputChance(int slot) {
Expand Down
4 changes: 4 additions & 0 deletions src/main/resources/assets/gregtech/lang/en_us.lang
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ death.attack.screwdriver_lv=%s had their screws removed by %s

enchantment.disjunction=Disjunction

gregtech.jei.remove_recipe.tooltip=Copies a %s Snippet to Remove this Recipe
gregtech.jei.ct_recipe.tooltip=CraftTweaker Recipe
gregtech.jei.gs_recipe.tooltip=GroovyScript Recipe

gregtech.machine.steam_grinder.name=Steam Grinder
gregtech.multiblock.steam_grinder.description=A Multiblock Macerator at the Steam Age. Requires at least 14 Bronze Casings to form. Cannot use normal Input/Output busses, nor Fluid Hatches other than the Steam Hatch.
gregtech.multiblock.steam.low_steam=Not enough Steam to run!
Expand Down

0 comments on commit 63518f9

Please sign in to comment.