From 7ce98ebbb4fa2f4ad5d707a881b699a68779107d Mon Sep 17 00:00:00 2001 From: vrejhead Date: Wed, 1 May 2024 23:24:56 -0700 Subject: [PATCH 01/23] yeah i forgot to commit again --- .../jei/recipe/GTRecipeWrapper.java | 44 ++++++++-- .../jei/utils/AdvancedRecipeWrapper.java | 20 +++++ .../jei/utils/JeiInteractableText.java | 83 +++++++++++++++++++ 3 files changed, 141 insertions(+), 6 deletions(-) create mode 100644 src/main/java/gregtech/integration/jei/utils/JeiInteractableText.java diff --git a/src/main/java/gregtech/integration/jei/recipe/GTRecipeWrapper.java b/src/main/java/gregtech/integration/jei/recipe/GTRecipeWrapper.java index 9c1382a453d..6496328c138 100644 --- a/src/main/java/gregtech/integration/jei/recipe/GTRecipeWrapper.java +++ b/src/main/java/gregtech/integration/jei/recipe/GTRecipeWrapper.java @@ -1,6 +1,7 @@ package gregtech.integration.jei.recipe; import gregtech.api.GTValues; +import gregtech.api.GregTechAPI; import gregtech.api.gui.GuiTextures; import gregtech.api.gui.widgets.TankWidget; import gregtech.api.items.metaitem.MetaItem; @@ -29,6 +30,8 @@ import gregtech.integration.jei.utils.AdvancedRecipeWrapper; import gregtech.integration.jei.utils.JeiButton; +import gregtech.integration.jei.utils.JeiInteractableText; + import net.minecraft.client.Minecraft; import net.minecraft.client.resources.I18n; import net.minecraft.item.ItemStack; @@ -247,6 +250,16 @@ public void drawInfo(@NotNull Minecraft minecraft, int recipeWidth, int recipeHe int yPosition = recipeHeight - ((recipe.getUnhiddenPropertyCount() + defaultLines) * 10 - 3); + int recipeTier = GTUtility.getFloorTierByVoltage(recipe.getEUt()); + // tier difference can be negative here + int tierDifference = getDisplayOCTier() - recipeTier; + // if tier difference is negative, the color is red since the recipe can't be run + int color = getTieredColor(tierDifference); + tierDifference = Math.max(0, tierDifference); + // if duration is less than 0.25, that means even with one less overclock, the recipe would still 1 tick + // so add the yellow warning + int duration = (int) (Math.floor(recipe.getDuration() / Math.pow(2, tierDifference)) / 20D); + color = duration <= 0.025 ? 0xFFFF55 : color; // Default entries if (drawTotalEU) { long eu = Math.abs((long) recipe.getEUt()) * recipe.getDuration(); @@ -257,22 +270,21 @@ public void drawInfo(@NotNull Minecraft minecraft, int recipeWidth, int recipeHe minecraft.fontRenderer.drawString(I18n.format("gregtech.recipe.max_eu", eu / minimumCWUt), 0, yPosition, 0x111111); } else { - minecraft.fontRenderer.drawString(I18n.format("gregtech.recipe.total", eu), 0, yPosition, 0x111111); + minecraft.fontRenderer.drawString(I18n.format("gregtech.recipe.total", (int) (eu * Math.pow(2, tierDifference))), 0, yPosition, color); } } if (drawEUt) { minecraft.fontRenderer.drawString( I18n.format(recipe.getEUt() >= 0 ? "gregtech.recipe.eu" : "gregtech.recipe.eu_inverted", - Math.abs(recipe.getEUt()), GTValues.VN[GTUtility.getTierByVoltage(recipe.getEUt())]), - 0, yPosition += LINE_HEIGHT, 0x111111); + (int) (Math.abs(recipe.getEUt()) * Math.pow(4, tierDifference)), GTValues.VN[tierDifference + recipeTier]), + 0, yPosition += LINE_HEIGHT, color); } if (drawDuration) { minecraft.fontRenderer.drawString( I18n.format("gregtech.recipe.duration", - TextFormattingUtil.formatNumbers(recipe.getDuration() / 20d)), - 0, yPosition += LINE_HEIGHT, 0x111111); + TextFormattingUtil.formatNumbers(Math.max(0.05, duration))), + 0, yPosition += LINE_HEIGHT, color); } - // Property custom entries for (Map.Entry, Object> propertyEntry : recipe.getPropertyValues()) { if (!propertyEntry.getKey().isHidden()) { @@ -322,6 +334,17 @@ public void initExtras() { return true; }) .setActiveSupplier(creativePlayerCtPredicate)); + + jeiTexts.add(new JeiInteractableText(0, 0, GTValues.VN[GTValues.ULV], 0x111111) + .setClickAction((minecraft, text, mouseX, mouseY, mouseButton) -> { + final int maxTier = GregTechAPI.isHighTier() ? GTValues.UIV + 1: GTValues.OpV + 1; + final int state = (text.getState() + 1) % maxTier; + text.setColor(GTValues.VC[state]); + text.setCurrentText(GTValues.VN[state]); + text.setState(state); + return true; + }) + ); } public ChancedItemOutput getOutputChance(int slot) { @@ -349,4 +372,13 @@ public boolean isNotConsumedItem(int slot) { public boolean isNotConsumedFluid(int slot) { return slot < this.sortedFluidInputs.size() && this.sortedFluidInputs.get(slot).isNonConsumable(); } + + public int getDisplayOCTier() { + return jeiTexts.get(0).getState(); + } + + public int getTieredColor(int tierDifference) { + if (tierDifference < 0) return 0xAA0000; + return 0x111111; + } } diff --git a/src/main/java/gregtech/integration/jei/utils/AdvancedRecipeWrapper.java b/src/main/java/gregtech/integration/jei/utils/AdvancedRecipeWrapper.java index 4cdf86c5c75..6d714e6778a 100644 --- a/src/main/java/gregtech/integration/jei/utils/AdvancedRecipeWrapper.java +++ b/src/main/java/gregtech/integration/jei/utils/AdvancedRecipeWrapper.java @@ -16,6 +16,7 @@ public abstract class AdvancedRecipeWrapper implements IRecipeWrapper { protected final List buttons = new ArrayList<>(); + protected final List jeiTexts = new ArrayList<>(); public AdvancedRecipeWrapper() { initExtras(); @@ -41,6 +42,18 @@ public void drawInfo(@NotNull Minecraft minecraft, int recipeWidth, int recipeHe GlStateManager.disableLighting(); } } + + for (JeiInteractableText text : jeiTexts) { + text.render(minecraft, recipeWidth, recipeHeight, mouseX, mouseY); + if (text.isHovering(mouseX, mouseY)) { + List tooltip = new ArrayList<>(); + text.buildTooltip(tooltip); + if (tooltip.isEmpty()) continue; + int width = (int) (minecraft.displayWidth / 2f + recipeWidth / 2f); + GuiUtils.drawHoveringText(tooltip, mouseX, mouseY, width, minecraft.displayHeight, Math.min(200, width - mouseX - 5), minecraft.fontRenderer); + GlStateManager.disableLighting(); + } + } } @Override @@ -53,6 +66,13 @@ public boolean handleClick(@NotNull Minecraft minecraft, int mouseX, int mouseY, return true; } } + for (JeiInteractableText text : jeiTexts) { + if (text.isHovering(mouseX, mouseY) && text.getTextClickAction().click(minecraft, text, mouseX, mouseY, mouseButton)) { + Minecraft.getMinecraft().getSoundHandler() + .playSound(PositionedSoundRecord.getMasterRecord(SoundEvents.UI_BUTTON_CLICK, 1.0F)); + return true; + } + } return false; } } diff --git a/src/main/java/gregtech/integration/jei/utils/JeiInteractableText.java b/src/main/java/gregtech/integration/jei/utils/JeiInteractableText.java new file mode 100644 index 00000000000..725e11d5034 --- /dev/null +++ b/src/main/java/gregtech/integration/jei/utils/JeiInteractableText.java @@ -0,0 +1,83 @@ +package gregtech.integration.jei.utils; + +import net.minecraft.client.Minecraft; + +import java.util.List; +import java.util.function.BiConsumer; +import java.util.function.Consumer; + +public class JeiInteractableText { + private final int x; + private final int y; + private int color; + private String currentText = "null"; + private int textWidth; + private TextClickAction textClickAction; + private BiConsumer> tooltipBuilder; + private int state; + public JeiInteractableText(int x, int y, String defaultText, int color) { + this.x = x; + this.y = y; + this.currentText = defaultText; + this.textWidth = Minecraft.getMinecraft().fontRenderer.getStringWidth(defaultText); + this.color = color; + } + + public void render(Minecraft minecraft, int recipeWidth, int recipeHeight, int mouseX, int mouseY) { + minecraft.fontRenderer.drawString(currentText, x, y, color); + } + + + public JeiInteractableText setTooltipBuilder(BiConsumer> builder) { + this.tooltipBuilder = builder; + return this; + } + + + public boolean isHovering(int mouseX, int mouseY) { + return mouseX >= x && mouseY >= y && mouseX <= x + textWidth && mouseY <= y + 10; + } + + public void setCurrentText(String text) { + this.currentText = text; + this.textWidth = Minecraft.getMinecraft().fontRenderer.getStringWidth(currentText); + } + + public String getCurrentText() { + return this.currentText; + } + + public void setColor(int color) { + this.color = color; + } + + public int getColor() { + return this.color; + } + + public JeiInteractableText setClickAction(TextClickAction action) { + this.textClickAction = action; + return this; + } + + public TextClickAction getTextClickAction() { + return this.textClickAction; + } + + public void setState(int state) { + this.state = state; + } + + public int getState() { + return this.state; + } + + public void buildTooltip(List baseTooltip) { + if (tooltipBuilder == null) return; + tooltipBuilder.accept(currentText, baseTooltip); + } + @FunctionalInterface + public interface TextClickAction { + boolean click(Minecraft minecraft, JeiInteractableText text, int mouseX, int mouseY, int mouseButton); + } +} From 0f5ee03d238f6a4a504880ec868ee5c99da600b2 Mon Sep 17 00:00:00 2001 From: vrejhead Date: Wed, 1 May 2024 23:25:59 -0700 Subject: [PATCH 02/23] cool (spotless) --- .../integration/jei/recipe/GTRecipeWrapper.java | 13 +++++++------ .../jei/utils/AdvancedRecipeWrapper.java | 6 ++++-- .../integration/jei/utils/JeiInteractableText.java | 9 +++++---- 3 files changed, 16 insertions(+), 12 deletions(-) diff --git a/src/main/java/gregtech/integration/jei/recipe/GTRecipeWrapper.java b/src/main/java/gregtech/integration/jei/recipe/GTRecipeWrapper.java index 6496328c138..8ac70541bb4 100644 --- a/src/main/java/gregtech/integration/jei/recipe/GTRecipeWrapper.java +++ b/src/main/java/gregtech/integration/jei/recipe/GTRecipeWrapper.java @@ -29,7 +29,6 @@ import gregtech.integration.RecipeCompatUtil; import gregtech.integration.jei.utils.AdvancedRecipeWrapper; import gregtech.integration.jei.utils.JeiButton; - import gregtech.integration.jei.utils.JeiInteractableText; import net.minecraft.client.Minecraft; @@ -270,13 +269,16 @@ public void drawInfo(@NotNull Minecraft minecraft, int recipeWidth, int recipeHe minecraft.fontRenderer.drawString(I18n.format("gregtech.recipe.max_eu", eu / minimumCWUt), 0, yPosition, 0x111111); } else { - minecraft.fontRenderer.drawString(I18n.format("gregtech.recipe.total", (int) (eu * Math.pow(2, tierDifference))), 0, yPosition, color); + minecraft.fontRenderer.drawString( + I18n.format("gregtech.recipe.total", (int) (eu * Math.pow(2, tierDifference))), 0, yPosition, + color); } } if (drawEUt) { minecraft.fontRenderer.drawString( I18n.format(recipe.getEUt() >= 0 ? "gregtech.recipe.eu" : "gregtech.recipe.eu_inverted", - (int) (Math.abs(recipe.getEUt()) * Math.pow(4, tierDifference)), GTValues.VN[tierDifference + recipeTier]), + (int) (Math.abs(recipe.getEUt()) * Math.pow(4, tierDifference)), + GTValues.VN[tierDifference + recipeTier]), 0, yPosition += LINE_HEIGHT, color); } if (drawDuration) { @@ -337,14 +339,13 @@ public void initExtras() { jeiTexts.add(new JeiInteractableText(0, 0, GTValues.VN[GTValues.ULV], 0x111111) .setClickAction((minecraft, text, mouseX, mouseY, mouseButton) -> { - final int maxTier = GregTechAPI.isHighTier() ? GTValues.UIV + 1: GTValues.OpV + 1; + final int maxTier = GregTechAPI.isHighTier() ? GTValues.UIV + 1 : GTValues.OpV + 1; final int state = (text.getState() + 1) % maxTier; text.setColor(GTValues.VC[state]); text.setCurrentText(GTValues.VN[state]); text.setState(state); return true; - }) - ); + })); } public ChancedItemOutput getOutputChance(int slot) { diff --git a/src/main/java/gregtech/integration/jei/utils/AdvancedRecipeWrapper.java b/src/main/java/gregtech/integration/jei/utils/AdvancedRecipeWrapper.java index 6d714e6778a..e54edd65b0d 100644 --- a/src/main/java/gregtech/integration/jei/utils/AdvancedRecipeWrapper.java +++ b/src/main/java/gregtech/integration/jei/utils/AdvancedRecipeWrapper.java @@ -50,7 +50,8 @@ public void drawInfo(@NotNull Minecraft minecraft, int recipeWidth, int recipeHe text.buildTooltip(tooltip); if (tooltip.isEmpty()) continue; int width = (int) (minecraft.displayWidth / 2f + recipeWidth / 2f); - GuiUtils.drawHoveringText(tooltip, mouseX, mouseY, width, minecraft.displayHeight, Math.min(200, width - mouseX - 5), minecraft.fontRenderer); + GuiUtils.drawHoveringText(tooltip, mouseX, mouseY, width, minecraft.displayHeight, + Math.min(200, width - mouseX - 5), minecraft.fontRenderer); GlStateManager.disableLighting(); } } @@ -67,7 +68,8 @@ public boolean handleClick(@NotNull Minecraft minecraft, int mouseX, int mouseY, } } for (JeiInteractableText text : jeiTexts) { - if (text.isHovering(mouseX, mouseY) && text.getTextClickAction().click(minecraft, text, mouseX, mouseY, mouseButton)) { + if (text.isHovering(mouseX, mouseY) && + text.getTextClickAction().click(minecraft, text, mouseX, mouseY, mouseButton)) { Minecraft.getMinecraft().getSoundHandler() .playSound(PositionedSoundRecord.getMasterRecord(SoundEvents.UI_BUTTON_CLICK, 1.0F)); return true; diff --git a/src/main/java/gregtech/integration/jei/utils/JeiInteractableText.java b/src/main/java/gregtech/integration/jei/utils/JeiInteractableText.java index 725e11d5034..21b35288030 100644 --- a/src/main/java/gregtech/integration/jei/utils/JeiInteractableText.java +++ b/src/main/java/gregtech/integration/jei/utils/JeiInteractableText.java @@ -4,17 +4,18 @@ import java.util.List; import java.util.function.BiConsumer; -import java.util.function.Consumer; public class JeiInteractableText { + private final int x; private final int y; private int color; - private String currentText = "null"; + private String currentText; private int textWidth; private TextClickAction textClickAction; private BiConsumer> tooltipBuilder; private int state; + public JeiInteractableText(int x, int y, String defaultText, int color) { this.x = x; this.y = y; @@ -27,13 +28,11 @@ public void render(Minecraft minecraft, int recipeWidth, int recipeHeight, int m minecraft.fontRenderer.drawString(currentText, x, y, color); } - public JeiInteractableText setTooltipBuilder(BiConsumer> builder) { this.tooltipBuilder = builder; return this; } - public boolean isHovering(int mouseX, int mouseY) { return mouseX >= x && mouseY >= y && mouseX <= x + textWidth && mouseY <= y + 10; } @@ -76,8 +75,10 @@ public void buildTooltip(List baseTooltip) { if (tooltipBuilder == null) return; tooltipBuilder.accept(currentText, baseTooltip); } + @FunctionalInterface public interface TextClickAction { + boolean click(Minecraft minecraft, JeiInteractableText text, int mouseX, int mouseY, int mouseButton); } } From ceb906ebad3da8654a232cd1e650a369e2eb888e Mon Sep 17 00:00:00 2001 From: vrejhead Date: Thu, 2 May 2024 17:23:56 -0700 Subject: [PATCH 03/23] don't allow tiers below min tier --- .../jei/recipe/GTRecipeWrapper.java | 62 +++++++++++-------- .../jei/utils/JeiInteractableText.java | 3 +- 2 files changed, 37 insertions(+), 28 deletions(-) diff --git a/src/main/java/gregtech/integration/jei/recipe/GTRecipeWrapper.java b/src/main/java/gregtech/integration/jei/recipe/GTRecipeWrapper.java index 8ac70541bb4..20d270acde6 100644 --- a/src/main/java/gregtech/integration/jei/recipe/GTRecipeWrapper.java +++ b/src/main/java/gregtech/integration/jei/recipe/GTRecipeWrapper.java @@ -64,6 +64,8 @@ public GTRecipeWrapper(RecipeMap recipeMap, Recipe recipe) { this.sortedInputs.sort(GTRecipeInput.RECIPE_INPUT_COMPARATOR); this.sortedFluidInputs = new ArrayList<>(recipe.getFluidInputs()); this.sortedFluidInputs.sort(GTRecipeInput.RECIPE_INPUT_COMPARATOR); + + initExtras(); } public Recipe getRecipe() { @@ -249,42 +251,45 @@ public void drawInfo(@NotNull Minecraft minecraft, int recipeWidth, int recipeHe int yPosition = recipeHeight - ((recipe.getUnhiddenPropertyCount() + defaultLines) * 10 - 3); - int recipeTier = GTUtility.getFloorTierByVoltage(recipe.getEUt()); + int recipeTier = GTUtility.getTierByVoltage(recipe.getEUt()); // tier difference can be negative here int tierDifference = getDisplayOCTier() - recipeTier; // if tier difference is negative, the color is red since the recipe can't be run - int color = getTieredColor(tierDifference); tierDifference = Math.max(0, tierDifference); - // if duration is less than 0.25, that means even with one less overclock, the recipe would still 1 tick + // if duration is less than 0.5, that means even with one less overclock, the recipe would still 1 tick // so add the yellow warning - int duration = (int) (Math.floor(recipe.getDuration() / Math.pow(2, tierDifference)) / 20D); - color = duration <= 0.025 ? 0xFFFF55 : color; + double duration = (Math.floor(recipe.getDuration() / Math.pow(2, tierDifference))); + int color = duration <= 0.5 ? 0xFFFF55 : 0x111111; + long eut = (long) Math.abs(recipe.getEUt()) * (int) Math.pow(4, tierDifference); + duration = Math.max(1, duration); // Default entries if (drawTotalEU) { - long eu = Math.abs((long) recipe.getEUt()) * recipe.getDuration(); + // sadly we still need a custom override here, since computation uses duration and EU/t very differently if (recipe.hasProperty(TotalComputationProperty.getInstance()) && recipe.hasProperty(ComputationProperty.getInstance())) { + long eu = Math.abs((long) recipe.getEUt()) * recipe.getDuration(); int minimumCWUt = recipe.getProperty(ComputationProperty.getInstance(), 1); minecraft.fontRenderer.drawString(I18n.format("gregtech.recipe.max_eu", eu / minimumCWUt), 0, yPosition, 0x111111); } else { + // duration is in sec minecraft.fontRenderer.drawString( - I18n.format("gregtech.recipe.total", (int) (eu * Math.pow(2, tierDifference))), 0, yPosition, + I18n.format("gregtech.recipe.total", (int) (eut * duration)), 0, yPosition, color); } } if (drawEUt) { minecraft.fontRenderer.drawString( I18n.format(recipe.getEUt() >= 0 ? "gregtech.recipe.eu" : "gregtech.recipe.eu_inverted", - (int) (Math.abs(recipe.getEUt()) * Math.pow(4, tierDifference)), + (int) (eut), GTValues.VN[tierDifference + recipeTier]), 0, yPosition += LINE_HEIGHT, color); } if (drawDuration) { minecraft.fontRenderer.drawString( I18n.format("gregtech.recipe.duration", - TextFormattingUtil.formatNumbers(Math.max(0.05, duration))), + TextFormattingUtil.formatNumbers(duration / 20)), 0, yPosition += LINE_HEIGHT, color); } // Property custom entries @@ -314,8 +319,26 @@ public List getTooltipStrings(int mouseX, int mouseY) { @Override public void initExtras() { - // do not add the X button if no tweaker mod is present - if (!RecipeCompatUtil.isTweakerLoaded()) return; + // initExtras is called in the super before this.recipe is set, so this has to be called twice + if (recipe == null) return; + + jeiTexts.add(new JeiInteractableText(0, 0, GTValues.VN[GTUtility.getTierByVoltage(recipe.getEUt())], 0x111111, + GTUtility.getTierByVoltage(recipe.getEUt())) + .setClickAction((minecraft, text, mouseX, mouseY, mouseButton) -> { + int maxTier = GregTechAPI.isHighTier() ? GTValues.UIV + 1 : GTValues.OpV + 1; + int minTier = Math.max(GTValues.LV, GTUtility.getTierByVoltage(recipe.getEUt())); + int state = (text.getState() + 1) % maxTier; + // ULV isnt real sorry + state = Math.max(state, minTier); + text.setColor(GTValues.VC[state]); + text.setCurrentText(GTValues.VN[state]); + text.setState(state); + return true; + })); + + // do not add the X button if no tweaker mod is present, or the button is already added(initExtras is called + // twice because of the comment above) + if (!RecipeCompatUtil.isTweakerLoaded() || !buttons.isEmpty()) return; BooleanSupplier creativePlayerCtPredicate = () -> Minecraft.getMinecraft().player != null && Minecraft.getMinecraft().player.isCreative(); @@ -336,16 +359,6 @@ public void initExtras() { return true; }) .setActiveSupplier(creativePlayerCtPredicate)); - - jeiTexts.add(new JeiInteractableText(0, 0, GTValues.VN[GTValues.ULV], 0x111111) - .setClickAction((minecraft, text, mouseX, mouseY, mouseButton) -> { - final int maxTier = GregTechAPI.isHighTier() ? GTValues.UIV + 1 : GTValues.OpV + 1; - final int state = (text.getState() + 1) % maxTier; - text.setColor(GTValues.VC[state]); - text.setCurrentText(GTValues.VN[state]); - text.setState(state); - return true; - })); } public ChancedItemOutput getOutputChance(int slot) { @@ -375,11 +388,6 @@ public boolean isNotConsumedFluid(int slot) { } public int getDisplayOCTier() { - return jeiTexts.get(0).getState(); - } - - public int getTieredColor(int tierDifference) { - if (tierDifference < 0) return 0xAA0000; - return 0x111111; + return jeiTexts.isEmpty() ? Integer.MIN_VALUE : jeiTexts.get(0).getState(); } } diff --git a/src/main/java/gregtech/integration/jei/utils/JeiInteractableText.java b/src/main/java/gregtech/integration/jei/utils/JeiInteractableText.java index 21b35288030..47f4254331d 100644 --- a/src/main/java/gregtech/integration/jei/utils/JeiInteractableText.java +++ b/src/main/java/gregtech/integration/jei/utils/JeiInteractableText.java @@ -16,12 +16,13 @@ public class JeiInteractableText { private BiConsumer> tooltipBuilder; private int state; - public JeiInteractableText(int x, int y, String defaultText, int color) { + public JeiInteractableText(int x, int y, String defaultText, int color, int baseState) { this.x = x; this.y = y; this.currentText = defaultText; this.textWidth = Minecraft.getMinecraft().fontRenderer.getStringWidth(defaultText); this.color = color; + this.state = baseState; } public void render(Minecraft minecraft, int recipeWidth, int recipeHeight, int mouseX, int mouseY) { From 1012b2e73af9f2e93665febb1045215b8beef23c Mon Sep 17 00:00:00 2001 From: vrejhead Date: Thu, 2 May 2024 18:11:09 -0700 Subject: [PATCH 04/23] allow recipemaps to disable the overclock button --- src/main/java/gregtech/api/recipes/RecipeMap.java | 11 ++++++++++- .../gregtech/api/recipes/RecipeMapBuilder.java | 10 +++++++++- src/main/java/gregtech/api/recipes/RecipeMaps.java | 9 ++++++++- .../integration/jei/recipe/GTRecipeWrapper.java | 14 +++++++++----- 4 files changed, 36 insertions(+), 8 deletions(-) diff --git a/src/main/java/gregtech/api/recipes/RecipeMap.java b/src/main/java/gregtech/api/recipes/RecipeMap.java index 9743c549ae5..cad66e52d93 100644 --- a/src/main/java/gregtech/api/recipes/RecipeMap.java +++ b/src/main/java/gregtech/api/recipes/RecipeMap.java @@ -99,7 +99,7 @@ public class RecipeMap> { public ChanceBoostFunction chanceFunction = DEFAULT_CHANCE_FUNCTION; public final String unlocalizedName; - + private boolean jeiOverclockButton = true; private final R recipeBuilderSample; private int maxInputs; private int maxOutputs; @@ -365,6 +365,15 @@ public RecipeMap> getSmallRecipeMap() { return smallRecipeMap; } + public RecipeMap disableJeiOverclockButton() { + this.jeiOverclockButton = false; + return this; + } + + public boolean JeiOverclockButtonEnabled() { + return this.jeiOverclockButton; + } + /** * Internal usage only, use {@link RecipeBuilder#buildAndRegister()} * diff --git a/src/main/java/gregtech/api/recipes/RecipeMapBuilder.java b/src/main/java/gregtech/api/recipes/RecipeMapBuilder.java index 8995cf529aa..04965292308 100644 --- a/src/main/java/gregtech/api/recipes/RecipeMapBuilder.java +++ b/src/main/java/gregtech/api/recipes/RecipeMapBuilder.java @@ -33,7 +33,7 @@ public class RecipeMapBuilder> { private boolean modifyFluidInputs = true; private int fluidOutputs; private boolean modifyFluidOutputs = true; - + private boolean jeiOverclockButton = true; private @Nullable TextureArea progressBar; private @Nullable ProgressWidget.MoveType moveType; @@ -253,6 +253,11 @@ public RecipeMapBuilder(@NotNull String unlocalizedName, @NotNull B defaultRecip return this; } + public @NotNull RecipeMapBuilder disableJeiOverclockButton() { + this.jeiOverclockButton = false; + return this; + } + /** * Add a recipe build action to be performed upon this RecipeMap's builder's recipe registration. * @@ -286,6 +291,9 @@ public RecipeMapBuilder(@NotNull String unlocalizedName, @NotNull B defaultRecip if (buildActions != null) { recipeMap.onRecipeBuild(buildActions); } + if (!jeiOverclockButton) { + recipeMap.disableJeiOverclockButton(); + } return recipeMap; } } diff --git a/src/main/java/gregtech/api/recipes/RecipeMaps.java b/src/main/java/gregtech/api/recipes/RecipeMaps.java index b5bdde0fa94..656a15d2117 100644 --- a/src/main/java/gregtech/api/recipes/RecipeMaps.java +++ b/src/main/java/gregtech/api/recipes/RecipeMaps.java @@ -525,6 +525,7 @@ public final class RecipeMaps { .fluidOutputs(1) .ui(CokeOvenUI::new) .sound(GTSoundEvents.FIRE) + .disableJeiOverclockButton() .build(); /** @@ -1287,6 +1288,7 @@ public final class RecipeMaps { .modifyFluidInputs(false) .modifyFluidOutputs(false) .sound(GTSoundEvents.FIRE) + .disableJeiOverclockButton() .build(); /** @@ -1336,7 +1338,7 @@ public final class RecipeMaps { @ZenProperty public static final RecipeMap RESEARCH_STATION_RECIPES = new RecipeMapResearchStation<>( - "research_station", new ComputationRecipeBuilder(), ResearchStationUI::new); + "research_station", new ComputationRecipeBuilder(), ResearchStationUI::new).disableJeiOverclockButton(); @ZenProperty public static final RecipeMap ROCK_BREAKER_RECIPES = new RecipeMapBuilder<>("rock_breaker", @@ -1483,6 +1485,7 @@ public final class RecipeMaps { .progressBar(GuiTextures.PROGRESS_BAR_ARROW_MULTIPLE) .sound(GTSoundEvents.COMBUSTION) .allowEmptyOutputs() + .disableJeiOverclockButton() .build(); @ZenProperty @@ -1493,6 +1496,7 @@ public final class RecipeMaps { .progressBar(GuiTextures.PROGRESS_BAR_GAS_COLLECTOR) .sound(GTSoundEvents.TURBINE) .allowEmptyOutputs() + .disableJeiOverclockButton() .build(); @ZenProperty @@ -1504,6 +1508,7 @@ public final class RecipeMaps { .progressBar(GuiTextures.PROGRESS_BAR_GAS_COLLECTOR) .sound(GTSoundEvents.TURBINE) .allowEmptyOutputs() + .disableJeiOverclockButton() .build(); @ZenProperty @@ -1514,6 +1519,7 @@ public final class RecipeMaps { .progressBar(GuiTextures.PROGRESS_BAR_ARROW_MULTIPLE) .sound(GTSoundEvents.COMBUSTION) .allowEmptyOutputs() + .disableJeiOverclockButton() .build(); @ZenProperty @@ -1525,6 +1531,7 @@ public final class RecipeMaps { .progressBar(GuiTextures.PROGRESS_BAR_GAS_COLLECTOR) .sound(GTSoundEvents.TURBINE) .allowEmptyOutputs() + .disableJeiOverclockButton() .build(); private RecipeMaps() {} diff --git a/src/main/java/gregtech/integration/jei/recipe/GTRecipeWrapper.java b/src/main/java/gregtech/integration/jei/recipe/GTRecipeWrapper.java index 20d270acde6..2c27a8705e0 100644 --- a/src/main/java/gregtech/integration/jei/recipe/GTRecipeWrapper.java +++ b/src/main/java/gregtech/integration/jei/recipe/GTRecipeWrapper.java @@ -252,8 +252,9 @@ public void drawInfo(@NotNull Minecraft minecraft, int recipeWidth, int recipeHe int yPosition = recipeHeight - ((recipe.getUnhiddenPropertyCount() + defaultLines) * 10 - 3); int recipeTier = GTUtility.getTierByVoltage(recipe.getEUt()); + // ULV doesn't overclock to LV, so treat ULV recipes as LV // tier difference can be negative here - int tierDifference = getDisplayOCTier() - recipeTier; + int tierDifference = getDisplayOCTier() - recipeTier - (recipeTier == GTValues.ULV ? 1 : 0); // if tier difference is negative, the color is red since the recipe can't be run tierDifference = Math.max(0, tierDifference); // if duration is less than 0.5, that means even with one less overclock, the recipe would still 1 tick @@ -280,10 +281,11 @@ public void drawInfo(@NotNull Minecraft minecraft, int recipeWidth, int recipeHe } } if (drawEUt) { + // scuffed way of dealing with 2 eu/t recipes, just recomputing instead of checking it eu/t <= 2 minecraft.fontRenderer.drawString( I18n.format(recipe.getEUt() >= 0 ? "gregtech.recipe.eu" : "gregtech.recipe.eu_inverted", (int) (eut), - GTValues.VN[tierDifference + recipeTier]), + GTValues.VN[GTUtility.getTierByVoltage(eut)]), 0, yPosition += LINE_HEIGHT, color); } if (drawDuration) { @@ -321,9 +323,11 @@ public List getTooltipStrings(int mouseX, int mouseY) { public void initExtras() { // initExtras is called in the super before this.recipe is set, so this has to be called twice if (recipe == null) return; + // don't render the overclock text for research + if (!recipeMap.JeiOverclockButtonEnabled()) return; + int recipeTier = Math.max(GTValues.LV, GTUtility.getTierByVoltage(recipe.getEUt())); - jeiTexts.add(new JeiInteractableText(0, 0, GTValues.VN[GTUtility.getTierByVoltage(recipe.getEUt())], 0x111111, - GTUtility.getTierByVoltage(recipe.getEUt())) + jeiTexts.add(new JeiInteractableText(0, 0, GTValues.VN[recipeTier], GTValues.VC[recipeTier], recipeTier) .setClickAction((minecraft, text, mouseX, mouseY, mouseButton) -> { int maxTier = GregTechAPI.isHighTier() ? GTValues.UIV + 1 : GTValues.OpV + 1; int minTier = Math.max(GTValues.LV, GTUtility.getTierByVoltage(recipe.getEUt())); @@ -388,6 +392,6 @@ public boolean isNotConsumedFluid(int slot) { } public int getDisplayOCTier() { - return jeiTexts.isEmpty() ? Integer.MIN_VALUE : jeiTexts.get(0).getState(); + return jeiTexts.isEmpty() ? Short.MIN_VALUE : jeiTexts.get(0).getState(); } } From 700133c7e1dccf4b2bf7c2bcccf1b47aff3bf52e Mon Sep 17 00:00:00 2001 From: vrejhead Date: Thu, 2 May 2024 18:28:20 -0700 Subject: [PATCH 05/23] yeah should have used long --- .../gregtech/integration/jei/recipe/GTRecipeWrapper.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/main/java/gregtech/integration/jei/recipe/GTRecipeWrapper.java b/src/main/java/gregtech/integration/jei/recipe/GTRecipeWrapper.java index 2c27a8705e0..7c479005faa 100644 --- a/src/main/java/gregtech/integration/jei/recipe/GTRecipeWrapper.java +++ b/src/main/java/gregtech/integration/jei/recipe/GTRecipeWrapper.java @@ -259,13 +259,12 @@ public void drawInfo(@NotNull Minecraft minecraft, int recipeWidth, int recipeHe tierDifference = Math.max(0, tierDifference); // if duration is less than 0.5, that means even with one less overclock, the recipe would still 1 tick // so add the yellow warning - double duration = (Math.floor(recipe.getDuration() / Math.pow(2, tierDifference))); + double duration = Math.floor(recipe.getDuration() / Math.pow(2, tierDifference)); int color = duration <= 0.5 ? 0xFFFF55 : 0x111111; long eut = (long) Math.abs(recipe.getEUt()) * (int) Math.pow(4, tierDifference); duration = Math.max(1, duration); // Default entries if (drawTotalEU) { - // sadly we still need a custom override here, since computation uses duration and EU/t very differently if (recipe.hasProperty(TotalComputationProperty.getInstance()) && recipe.hasProperty(ComputationProperty.getInstance())) { @@ -276,7 +275,7 @@ public void drawInfo(@NotNull Minecraft minecraft, int recipeWidth, int recipeHe } else { // duration is in sec minecraft.fontRenderer.drawString( - I18n.format("gregtech.recipe.total", (int) (eut * duration)), 0, yPosition, + I18n.format("gregtech.recipe.total", (long) (eut * duration)), 0, yPosition, color); } } From c7bd95e14f170800f0be6bda9d941861bade787f Mon Sep 17 00:00:00 2001 From: vrejhead Date: Thu, 2 May 2024 19:05:39 -0700 Subject: [PATCH 06/23] correct comments and stuff --- .../integration/jei/recipe/GTRecipeWrapper.java | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/src/main/java/gregtech/integration/jei/recipe/GTRecipeWrapper.java b/src/main/java/gregtech/integration/jei/recipe/GTRecipeWrapper.java index 7c479005faa..07f92ce7bcb 100644 --- a/src/main/java/gregtech/integration/jei/recipe/GTRecipeWrapper.java +++ b/src/main/java/gregtech/integration/jei/recipe/GTRecipeWrapper.java @@ -52,7 +52,7 @@ public class GTRecipeWrapper extends AdvancedRecipeWrapper { private final RecipeMap recipeMap; private final Recipe recipe; - + private boolean registeredTweakerJeiButton; private final List sortedInputs; private final List sortedFluidInputs; @@ -254,9 +254,7 @@ public void drawInfo(@NotNull Minecraft minecraft, int recipeWidth, int recipeHe int recipeTier = GTUtility.getTierByVoltage(recipe.getEUt()); // ULV doesn't overclock to LV, so treat ULV recipes as LV // tier difference can be negative here - int tierDifference = getDisplayOCTier() - recipeTier - (recipeTier == GTValues.ULV ? 1 : 0); - // if tier difference is negative, the color is red since the recipe can't be run - tierDifference = Math.max(0, tierDifference); + int tierDifference = Math.max(0, getDisplayOCTier() - recipeTier - (recipeTier == GTValues.ULV ? 1 : 0)); // if duration is less than 0.5, that means even with one less overclock, the recipe would still 1 tick // so add the yellow warning double duration = Math.floor(recipe.getDuration() / Math.pow(2, tierDifference)); @@ -280,7 +278,7 @@ public void drawInfo(@NotNull Minecraft minecraft, int recipeWidth, int recipeHe } } if (drawEUt) { - // scuffed way of dealing with 2 eu/t recipes, just recomputing instead of checking it eu/t <= 2 + // scuffed way of dealing with 2 eu/t recipes, just recomputing instead of checking if eu/t <= 2 minecraft.fontRenderer.drawString( I18n.format(recipe.getEUt() >= 0 ? "gregtech.recipe.eu" : "gregtech.recipe.eu_inverted", (int) (eut), @@ -321,9 +319,7 @@ public List getTooltipStrings(int mouseX, int mouseY) { @Override public void initExtras() { // initExtras is called in the super before this.recipe is set, so this has to be called twice - if (recipe == null) return; - // don't render the overclock text for research - if (!recipeMap.JeiOverclockButtonEnabled()) return; + if (recipe == null || !recipeMap.JeiOverclockButtonEnabled()) return; int recipeTier = Math.max(GTValues.LV, GTUtility.getTierByVoltage(recipe.getEUt())); jeiTexts.add(new JeiInteractableText(0, 0, GTValues.VN[recipeTier], GTValues.VC[recipeTier], recipeTier) @@ -341,7 +337,7 @@ public void initExtras() { // do not add the X button if no tweaker mod is present, or the button is already added(initExtras is called // twice because of the comment above) - if (!RecipeCompatUtil.isTweakerLoaded() || !buttons.isEmpty()) return; + if (!RecipeCompatUtil.isTweakerLoaded() || registeredTweakerJeiButton) return; BooleanSupplier creativePlayerCtPredicate = () -> Minecraft.getMinecraft().player != null && Minecraft.getMinecraft().player.isCreative(); @@ -362,6 +358,7 @@ public void initExtras() { return true; }) .setActiveSupplier(creativePlayerCtPredicate)); + registeredTweakerJeiButton = true; } public ChancedItemOutput getOutputChance(int slot) { From f940598d645e7c279abb5d201d2e0dc81e27b8f7 Mon Sep 17 00:00:00 2001 From: vrejhead Date: Thu, 2 May 2024 19:06:14 -0700 Subject: [PATCH 07/23] spotless jumpscare --- .../jei/recipe/GTRecipeWrapper.java | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/main/java/gregtech/integration/jei/recipe/GTRecipeWrapper.java b/src/main/java/gregtech/integration/jei/recipe/GTRecipeWrapper.java index 07f92ce7bcb..2328a34125b 100644 --- a/src/main/java/gregtech/integration/jei/recipe/GTRecipeWrapper.java +++ b/src/main/java/gregtech/integration/jei/recipe/GTRecipeWrapper.java @@ -323,17 +323,17 @@ public void initExtras() { int recipeTier = Math.max(GTValues.LV, GTUtility.getTierByVoltage(recipe.getEUt())); jeiTexts.add(new JeiInteractableText(0, 0, GTValues.VN[recipeTier], GTValues.VC[recipeTier], recipeTier) - .setClickAction((minecraft, text, mouseX, mouseY, mouseButton) -> { - int maxTier = GregTechAPI.isHighTier() ? GTValues.UIV + 1 : GTValues.OpV + 1; - int minTier = Math.max(GTValues.LV, GTUtility.getTierByVoltage(recipe.getEUt())); - int state = (text.getState() + 1) % maxTier; - // ULV isnt real sorry - state = Math.max(state, minTier); - text.setColor(GTValues.VC[state]); - text.setCurrentText(GTValues.VN[state]); - text.setState(state); - return true; - })); + .setClickAction((minecraft, text, mouseX, mouseY, mouseButton) -> { + int maxTier = GregTechAPI.isHighTier() ? GTValues.UIV + 1 : GTValues.OpV + 1; + int minTier = Math.max(GTValues.LV, GTUtility.getTierByVoltage(recipe.getEUt())); + int state = (text.getState() + 1) % maxTier; + // ULV isnt real sorry + state = Math.max(state, minTier); + text.setColor(GTValues.VC[state]); + text.setCurrentText(GTValues.VN[state]); + text.setState(state); + return true; + })); // do not add the X button if no tweaker mod is present, or the button is already added(initExtras is called // twice because of the comment above) From 12e842f3ac3e7ec1026095b7b15a1b421acc3796 Mon Sep 17 00:00:00 2001 From: vrejhead Date: Thu, 2 May 2024 19:29:54 -0700 Subject: [PATCH 08/23] make initExtras logic not trash --- .../jei/recipe/GTRecipeWrapper.java | 81 +++++++++---------- 1 file changed, 39 insertions(+), 42 deletions(-) diff --git a/src/main/java/gregtech/integration/jei/recipe/GTRecipeWrapper.java b/src/main/java/gregtech/integration/jei/recipe/GTRecipeWrapper.java index 2328a34125b..4c16151c0fc 100644 --- a/src/main/java/gregtech/integration/jei/recipe/GTRecipeWrapper.java +++ b/src/main/java/gregtech/integration/jei/recipe/GTRecipeWrapper.java @@ -52,7 +52,6 @@ public class GTRecipeWrapper extends AdvancedRecipeWrapper { private final RecipeMap recipeMap; private final Recipe recipe; - private boolean registeredTweakerJeiButton; private final List sortedInputs; private final List sortedFluidInputs; @@ -318,47 +317,45 @@ public List getTooltipStrings(int mouseX, int mouseY) { @Override public void initExtras() { - // initExtras is called in the super before this.recipe is set, so this has to be called twice - if (recipe == null || !recipeMap.JeiOverclockButtonEnabled()) return; - int recipeTier = Math.max(GTValues.LV, GTUtility.getTierByVoltage(recipe.getEUt())); - - jeiTexts.add(new JeiInteractableText(0, 0, GTValues.VN[recipeTier], GTValues.VC[recipeTier], recipeTier) - .setClickAction((minecraft, text, mouseX, mouseY, mouseButton) -> { - int maxTier = GregTechAPI.isHighTier() ? GTValues.UIV + 1 : GTValues.OpV + 1; - int minTier = Math.max(GTValues.LV, GTUtility.getTierByVoltage(recipe.getEUt())); - int state = (text.getState() + 1) % maxTier; - // ULV isnt real sorry - state = Math.max(state, minTier); - text.setColor(GTValues.VC[state]); - text.setCurrentText(GTValues.VN[state]); - text.setState(state); - return true; - })); - - // do not add the X button if no tweaker mod is present, or the button is already added(initExtras is called - // twice because of the comment above) - if (!RecipeCompatUtil.isTweakerLoaded() || registeredTweakerJeiButton) return; - - BooleanSupplier creativePlayerCtPredicate = () -> Minecraft.getMinecraft().player != null && - Minecraft.getMinecraft().player.isCreative(); - 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")) - .setClickAction((minecraft, mouseX, mouseY, mouseButton) -> { - String recipeLine = RecipeCompatUtil.getRecipeRemoveLine(recipeMap, recipe); - String output = RecipeCompatUtil.getFirstOutputString(recipe); - if (!output.isEmpty()) { - output = "// " + output + "\n"; - } - String copyString = output + recipeLine + "\n"; - ClipboardUtil.copyToClipboard(copyString); - Minecraft.getMinecraft().player.sendMessage( - new TextComponentString("Copied [\u00A76" + recipeLine + "\u00A7r] to the clipboard")); - return true; - }) - .setActiveSupplier(creativePlayerCtPredicate)); - registeredTweakerJeiButton = true; + // recipe is null on the first call of this method, so load the tweaker recipe remove button here + if (recipe == null) { + if (!RecipeCompatUtil.isTweakerLoaded()) return; + BooleanSupplier creativePlayerCtPredicate = () -> Minecraft.getMinecraft().player != null && + Minecraft.getMinecraft().player.isCreative(); + 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")) + .setClickAction((minecraft, mouseX, mouseY, mouseButton) -> { + String recipeLine = RecipeCompatUtil.getRecipeRemoveLine(recipeMap, recipe); + String output = RecipeCompatUtil.getFirstOutputString(recipe); + if (!output.isEmpty()) { + output = "// " + output + "\n"; + } + String copyString = output + recipeLine + "\n"; + ClipboardUtil.copyToClipboard(copyString); + Minecraft.getMinecraft().player.sendMessage( + new TextComponentString("Copied [\u00A76" + recipeLine + "\u00A7r] to the clipboard")); + return true; + }) + .setActiveSupplier(creativePlayerCtPredicate)); + } else if (recipeMap.JeiOverclockButtonEnabled()) { + // on second call recipe != null, so add this instead + int recipeTier = Math.max(GTValues.LV, GTUtility.getTierByVoltage(recipe.getEUt())); + + jeiTexts.add(new JeiInteractableText(0, 0, GTValues.VN[recipeTier], GTValues.VC[recipeTier], recipeTier) + .setClickAction((minecraft, text, mouseX, mouseY, mouseButton) -> { + int maxTier = GregTechAPI.isHighTier() ? GTValues.UIV + 1 : GTValues.OpV + 1; + int minTier = Math.max(GTValues.LV, GTUtility.getTierByVoltage(recipe.getEUt())); + int state = (text.getState() + 1) % maxTier; + // ULV isn't real sorry + state = Math.max(state, minTier); + text.setColor(GTValues.VC[state]); + text.setCurrentText(GTValues.VN[state]); + text.setState(state); + return true; + })); + } } public ChancedItemOutput getOutputChance(int slot) { From 3617e38451430ac30cba452f1026bc6c0c9f1a4b Mon Sep 17 00:00:00 2001 From: vrejhead Date: Thu, 2 May 2024 19:33:20 -0700 Subject: [PATCH 09/23] mb this actually makes it not trash --- .../gregtech/integration/jei/recipe/GTRecipeWrapper.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/main/java/gregtech/integration/jei/recipe/GTRecipeWrapper.java b/src/main/java/gregtech/integration/jei/recipe/GTRecipeWrapper.java index 4c16151c0fc..08bf3423f8e 100644 --- a/src/main/java/gregtech/integration/jei/recipe/GTRecipeWrapper.java +++ b/src/main/java/gregtech/integration/jei/recipe/GTRecipeWrapper.java @@ -317,9 +317,9 @@ public List getTooltipStrings(int mouseX, int mouseY) { @Override public void initExtras() { - // recipe is null on the first call of this method, so load the tweaker recipe remove button here - if (recipe == null) { - if (!RecipeCompatUtil.isTweakerLoaded()) return; + // recipe is null on the first call of this method + if (recipe == null) return; + if (RecipeCompatUtil.isTweakerLoaded()) { BooleanSupplier creativePlayerCtPredicate = () -> Minecraft.getMinecraft().player != null && Minecraft.getMinecraft().player.isCreative(); buttons.add(new JeiButton(166, 2, 10, 10) @@ -339,7 +339,8 @@ public void initExtras() { return true; }) .setActiveSupplier(creativePlayerCtPredicate)); - } else if (recipeMap.JeiOverclockButtonEnabled()) { + } + if (recipeMap.JeiOverclockButtonEnabled()) { // on second call recipe != null, so add this instead int recipeTier = Math.max(GTValues.LV, GTUtility.getTierByVoltage(recipe.getEUt())); From 3a4e6c1eb59ece8ef86817264e4e273c0277346a Mon Sep 17 00:00:00 2001 From: vrejhead Date: Thu, 2 May 2024 19:41:48 -0700 Subject: [PATCH 10/23] hopefully no more outdated comments --- .../gregtech/integration/jei/recipe/GTRecipeWrapper.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/main/java/gregtech/integration/jei/recipe/GTRecipeWrapper.java b/src/main/java/gregtech/integration/jei/recipe/GTRecipeWrapper.java index 08bf3423f8e..1a33fed2017 100644 --- a/src/main/java/gregtech/integration/jei/recipe/GTRecipeWrapper.java +++ b/src/main/java/gregtech/integration/jei/recipe/GTRecipeWrapper.java @@ -252,8 +252,9 @@ public void drawInfo(@NotNull Minecraft minecraft, int recipeWidth, int recipeHe int recipeTier = GTUtility.getTierByVoltage(recipe.getEUt()); // ULV doesn't overclock to LV, so treat ULV recipes as LV - // tier difference can be negative here - int tierDifference = Math.max(0, getDisplayOCTier() - recipeTier - (recipeTier == GTValues.ULV ? 1 : 0)); + recipeTier += recipeTier == GTValues.ULV ? 1 : 0; + // tier difference *should* not be negative here since at least displayOCTier() == recipeTier + int tierDifference = getDisplayOCTier() - recipeTier; // if duration is less than 0.5, that means even with one less overclock, the recipe would still 1 tick // so add the yellow warning double duration = Math.floor(recipe.getDuration() / Math.pow(2, tierDifference)); @@ -270,7 +271,6 @@ public void drawInfo(@NotNull Minecraft minecraft, int recipeWidth, int recipeHe minecraft.fontRenderer.drawString(I18n.format("gregtech.recipe.max_eu", eu / minimumCWUt), 0, yPosition, 0x111111); } else { - // duration is in sec minecraft.fontRenderer.drawString( I18n.format("gregtech.recipe.total", (long) (eut * duration)), 0, yPosition, color); @@ -341,7 +341,6 @@ public void initExtras() { .setActiveSupplier(creativePlayerCtPredicate)); } if (recipeMap.JeiOverclockButtonEnabled()) { - // on second call recipe != null, so add this instead int recipeTier = Math.max(GTValues.LV, GTUtility.getTierByVoltage(recipe.getEUt())); jeiTexts.add(new JeiInteractableText(0, 0, GTValues.VN[recipeTier], GTValues.VC[recipeTier], recipeTier) From e457c01129ae86224d4be45fd93ac0698f5076a4 Mon Sep 17 00:00:00 2001 From: vrejhead Date: Thu, 2 May 2024 20:04:41 -0700 Subject: [PATCH 11/23] left and right clicks and long eut and custom fusion overclocks --- .../jei/recipe/GTRecipeWrapper.java | 20 ++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/src/main/java/gregtech/integration/jei/recipe/GTRecipeWrapper.java b/src/main/java/gregtech/integration/jei/recipe/GTRecipeWrapper.java index 1a33fed2017..64d11d5e48f 100644 --- a/src/main/java/gregtech/integration/jei/recipe/GTRecipeWrapper.java +++ b/src/main/java/gregtech/integration/jei/recipe/GTRecipeWrapper.java @@ -259,7 +259,9 @@ public void drawInfo(@NotNull Minecraft minecraft, int recipeWidth, int recipeHe // so add the yellow warning double duration = Math.floor(recipe.getDuration() / Math.pow(2, tierDifference)); int color = duration <= 0.5 ? 0xFFFF55 : 0x111111; - long eut = (long) Math.abs(recipe.getEUt()) * (int) Math.pow(4, tierDifference); + // currently manual override for fusion's 2x EU/t instead of 4x, maybe custom multiplier per recipeMap soontm? + long eut = (long) Math.abs(recipe.getEUt()) * + (int) Math.pow(recipeMap == RecipeMaps.FUSION_RECIPES ? 2 : 4, tierDifference); duration = Math.max(1, duration); // Default entries if (drawTotalEU) { @@ -280,7 +282,7 @@ public void drawInfo(@NotNull Minecraft minecraft, int recipeWidth, int recipeHe // scuffed way of dealing with 2 eu/t recipes, just recomputing instead of checking if eu/t <= 2 minecraft.fontRenderer.drawString( I18n.format(recipe.getEUt() >= 0 ? "gregtech.recipe.eu" : "gregtech.recipe.eu_inverted", - (int) (eut), + eut, GTValues.VN[GTUtility.getTierByVoltage(eut)]), 0, yPosition += LINE_HEIGHT, color); } @@ -345,11 +347,19 @@ public void initExtras() { jeiTexts.add(new JeiInteractableText(0, 0, GTValues.VN[recipeTier], GTValues.VC[recipeTier], recipeTier) .setClickAction((minecraft, text, mouseX, mouseY, mouseButton) -> { - int maxTier = GregTechAPI.isHighTier() ? GTValues.UIV + 1 : GTValues.OpV + 1; + int maxTier = GregTechAPI.isHighTier() ? GTValues.UIV : GTValues.MAX; int minTier = Math.max(GTValues.LV, GTUtility.getTierByVoltage(recipe.getEUt())); - int state = (text.getState() + 1) % maxTier; // ULV isn't real sorry - state = Math.max(state, minTier); + int state = minTier; + if (mouseButton == 0) { + // increment tier if left click + state = text.getState() + 1; + if (state > maxTier) state = minTier; + } else if (mouseButton == 1) { + // decrement tier if right click + state = text.getState() - 1; + if (state < minTier) state = maxTier; + } text.setColor(GTValues.VC[state]); text.setCurrentText(GTValues.VN[state]); text.setState(state); From 05169b7e561cfcf4b093a8015f2cc37d00dbe407 Mon Sep 17 00:00:00 2001 From: vrejhead Date: Fri, 3 May 2024 18:40:16 -0700 Subject: [PATCH 12/23] add !!!COLOR!!! --- .../gregtech/integration/jei/recipe/GTRecipeWrapper.java | 7 +++---- .../integration/jei/utils/JeiInteractableText.java | 4 ++++ 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/main/java/gregtech/integration/jei/recipe/GTRecipeWrapper.java b/src/main/java/gregtech/integration/jei/recipe/GTRecipeWrapper.java index 64d11d5e48f..b2a06e97e76 100644 --- a/src/main/java/gregtech/integration/jei/recipe/GTRecipeWrapper.java +++ b/src/main/java/gregtech/integration/jei/recipe/GTRecipeWrapper.java @@ -283,7 +283,7 @@ public void drawInfo(@NotNull Minecraft minecraft, int recipeWidth, int recipeHe minecraft.fontRenderer.drawString( I18n.format(recipe.getEUt() >= 0 ? "gregtech.recipe.eu" : "gregtech.recipe.eu_inverted", eut, - GTValues.VN[GTUtility.getTierByVoltage(eut)]), + GTValues.VNF[GTUtility.getTierByVoltage(eut)]), 0, yPosition += LINE_HEIGHT, color); } if (drawDuration) { @@ -345,7 +345,7 @@ public void initExtras() { if (recipeMap.JeiOverclockButtonEnabled()) { int recipeTier = Math.max(GTValues.LV, GTUtility.getTierByVoltage(recipe.getEUt())); - jeiTexts.add(new JeiInteractableText(0, 0, GTValues.VN[recipeTier], GTValues.VC[recipeTier], recipeTier) + jeiTexts.add(new JeiInteractableText(0, 0, GTValues.VNF[recipeTier], 0x111111, recipeTier) .setClickAction((minecraft, text, mouseX, mouseY, mouseButton) -> { int maxTier = GregTechAPI.isHighTier() ? GTValues.UIV : GTValues.MAX; int minTier = Math.max(GTValues.LV, GTUtility.getTierByVoltage(recipe.getEUt())); @@ -360,8 +360,7 @@ public void initExtras() { state = text.getState() - 1; if (state < minTier) state = maxTier; } - text.setColor(GTValues.VC[state]); - text.setCurrentText(GTValues.VN[state]); + text.setCurrentText(GTValues.VNF[state]); text.setState(state); return true; })); diff --git a/src/main/java/gregtech/integration/jei/utils/JeiInteractableText.java b/src/main/java/gregtech/integration/jei/utils/JeiInteractableText.java index 47f4254331d..badb7b12d19 100644 --- a/src/main/java/gregtech/integration/jei/utils/JeiInteractableText.java +++ b/src/main/java/gregtech/integration/jei/utils/JeiInteractableText.java @@ -47,6 +47,10 @@ public String getCurrentText() { return this.currentText; } + /** + * This is overriden by in-text formatting codes! + * @param color The color to set the text to + */ public void setColor(int color) { this.color = color; } From a98ca750ecc59f5772575e882209740b6939280f Mon Sep 17 00:00:00 2001 From: vrejhead Date: Fri, 3 May 2024 18:40:52 -0700 Subject: [PATCH 13/23] thanks spotless --- .../java/gregtech/integration/jei/utils/JeiInteractableText.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/gregtech/integration/jei/utils/JeiInteractableText.java b/src/main/java/gregtech/integration/jei/utils/JeiInteractableText.java index badb7b12d19..b675a2a3e40 100644 --- a/src/main/java/gregtech/integration/jei/utils/JeiInteractableText.java +++ b/src/main/java/gregtech/integration/jei/utils/JeiInteractableText.java @@ -49,6 +49,7 @@ public String getCurrentText() { /** * This is overriden by in-text formatting codes! + * * @param color The color to set the text to */ public void setColor(int color) { From d2877d1bea371ae0616e3472dfe2641d5a66e298 Mon Sep 17 00:00:00 2001 From: vrejhead Date: Fri, 3 May 2024 19:00:42 -0700 Subject: [PATCH 14/23] pass state instead of current text --- .../gregtech/integration/jei/utils/JeiInteractableText.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/gregtech/integration/jei/utils/JeiInteractableText.java b/src/main/java/gregtech/integration/jei/utils/JeiInteractableText.java index b675a2a3e40..fc2025ba28d 100644 --- a/src/main/java/gregtech/integration/jei/utils/JeiInteractableText.java +++ b/src/main/java/gregtech/integration/jei/utils/JeiInteractableText.java @@ -13,7 +13,7 @@ public class JeiInteractableText { private String currentText; private int textWidth; private TextClickAction textClickAction; - private BiConsumer> tooltipBuilder; + private BiConsumer> tooltipBuilder; private int state; public JeiInteractableText(int x, int y, String defaultText, int color, int baseState) { @@ -29,7 +29,7 @@ public void render(Minecraft minecraft, int recipeWidth, int recipeHeight, int m minecraft.fontRenderer.drawString(currentText, x, y, color); } - public JeiInteractableText setTooltipBuilder(BiConsumer> builder) { + public JeiInteractableText setTooltipBuilder(BiConsumer> builder) { this.tooltipBuilder = builder; return this; } @@ -79,7 +79,7 @@ public int getState() { public void buildTooltip(List baseTooltip) { if (tooltipBuilder == null) return; - tooltipBuilder.accept(currentText, baseTooltip); + tooltipBuilder.accept(this.state, baseTooltip); } @FunctionalInterface From 28f73ccfd60321fdd113247fabccdc61921d293f Mon Sep 17 00:00:00 2001 From: vrejhead Date: Fri, 3 May 2024 20:28:40 -0700 Subject: [PATCH 15/23] move to bottom right, add tooltip --- .../jei/recipe/GTRecipeWrapper.java | 48 +++++++++++-------- .../jei/utils/AdvancedRecipeWrapper.java | 2 +- .../jei/utils/JeiInteractableText.java | 23 +++++++-- .../resources/assets/gregtech/lang/en_us.lang | 3 ++ 4 files changed, 52 insertions(+), 24 deletions(-) diff --git a/src/main/java/gregtech/integration/jei/recipe/GTRecipeWrapper.java b/src/main/java/gregtech/integration/jei/recipe/GTRecipeWrapper.java index b2a06e97e76..6496bda48bf 100644 --- a/src/main/java/gregtech/integration/jei/recipe/GTRecipeWrapper.java +++ b/src/main/java/gregtech/integration/jei/recipe/GTRecipeWrapper.java @@ -344,26 +344,34 @@ public void initExtras() { } if (recipeMap.JeiOverclockButtonEnabled()) { int recipeTier = Math.max(GTValues.LV, GTUtility.getTierByVoltage(recipe.getEUt())); - - jeiTexts.add(new JeiInteractableText(0, 0, GTValues.VNF[recipeTier], 0x111111, recipeTier) - .setClickAction((minecraft, text, mouseX, mouseY, mouseButton) -> { - int maxTier = GregTechAPI.isHighTier() ? GTValues.UIV : GTValues.MAX; - int minTier = Math.max(GTValues.LV, GTUtility.getTierByVoltage(recipe.getEUt())); - // ULV isn't real sorry - int state = minTier; - if (mouseButton == 0) { - // increment tier if left click - state = text.getState() + 1; - if (state > maxTier) state = minTier; - } else if (mouseButton == 1) { - // decrement tier if right click - state = text.getState() - 1; - if (state < minTier) state = maxTier; - } - text.setCurrentText(GTValues.VNF[state]); - text.setState(state); - return true; - })); + // seems like recipeHeight is always 120 + jeiTexts.add( + new JeiInteractableText(0, 120 - LINE_HEIGHT, GTValues.VNF[recipeTier], 0x111111, recipeTier, true) + .setTooltipBuilder((state, tooltip) -> { + tooltip.add(I18n.format("gregtech.jei.overclock_button", GTValues.VNF[state])); + tooltip.add(TooltipHelper.BLINKING_CYAN + I18n.format("gregtech.jei.overclock_warn")); + }) + .setClickAction((minecraft, text, mouseX, mouseY, mouseButton) -> { + // just here because if highTier is disabled, if a recipe is (incorrectly) registering + // UIV+ recipes, this allows it to go up to the recipe tier for that recipe + int maxTier = Math.max(recipeTier, + GregTechAPI.isHighTier() ? GTValues.UIV : GTValues.MAX); + int minTier = Math.max(GTValues.LV, GTUtility.getTierByVoltage(recipe.getEUt())); + // ULV isn't real sorry + int state = minTier; + if (mouseButton == 0) { + // increment tier if left click + state = text.getState() + 1; + if (state > maxTier) state = minTier; + } else if (mouseButton == 1) { + // decrement tier if right click + state = text.getState() - 1; + if (state < minTier) state = maxTier; + } + text.setCurrentText(GTValues.VNF[state]); + text.setState(state); + return true; + })); } } diff --git a/src/main/java/gregtech/integration/jei/utils/AdvancedRecipeWrapper.java b/src/main/java/gregtech/integration/jei/utils/AdvancedRecipeWrapper.java index e54edd65b0d..e0ce681ba97 100644 --- a/src/main/java/gregtech/integration/jei/utils/AdvancedRecipeWrapper.java +++ b/src/main/java/gregtech/integration/jei/utils/AdvancedRecipeWrapper.java @@ -51,7 +51,7 @@ public void drawInfo(@NotNull Minecraft minecraft, int recipeWidth, int recipeHe if (tooltip.isEmpty()) continue; int width = (int) (minecraft.displayWidth / 2f + recipeWidth / 2f); GuiUtils.drawHoveringText(tooltip, mouseX, mouseY, width, minecraft.displayHeight, - Math.min(200, width - mouseX - 5), minecraft.fontRenderer); + Math.min(150, width - mouseX - 5), minecraft.fontRenderer); GlStateManager.disableLighting(); } } diff --git a/src/main/java/gregtech/integration/jei/utils/JeiInteractableText.java b/src/main/java/gregtech/integration/jei/utils/JeiInteractableText.java index fc2025ba28d..72669232ec2 100644 --- a/src/main/java/gregtech/integration/jei/utils/JeiInteractableText.java +++ b/src/main/java/gregtech/integration/jei/utils/JeiInteractableText.java @@ -9,6 +9,7 @@ public class JeiInteractableText { private final int x; private final int y; + private final boolean invertX; private int color; private String currentText; private int textWidth; @@ -16,9 +17,22 @@ public class JeiInteractableText { private BiConsumer> tooltipBuilder; private int state; - public JeiInteractableText(int x, int y, String defaultText, int color, int baseState) { + /** + * Creates a new text object when can handle clicks and update state when clicked + * + * @param x x value, 0 on the left border, increases moving right. + * @param y x value, 0 on the top border, increases moving down. + * @param defaultText the text that should be initially displayed(without any clicks) + * @param color the default color of the text, overridden by in-text formatting codes + * @param baseState the default state of the button, it is used for tooltip and general information storage + * @param invertX instead defines x as the distance from the right border, + * * this takes into account the text width, + * ensuring the rightmost part of the text is always aligned + */ + public JeiInteractableText(int x, int y, String defaultText, int color, int baseState, boolean invertX) { this.x = x; this.y = y; + this.invertX = invertX; this.currentText = defaultText; this.textWidth = Minecraft.getMinecraft().fontRenderer.getStringWidth(defaultText); this.color = color; @@ -26,7 +40,7 @@ public JeiInteractableText(int x, int y, String defaultText, int color, int base } public void render(Minecraft minecraft, int recipeWidth, int recipeHeight, int mouseX, int mouseY) { - minecraft.fontRenderer.drawString(currentText, x, y, color); + minecraft.fontRenderer.drawString(currentText, invertX ? recipeWidth - x - textWidth : x, y, color); } public JeiInteractableText setTooltipBuilder(BiConsumer> builder) { @@ -35,7 +49,10 @@ public JeiInteractableText setTooltipBuilder(BiConsumer> b } public boolean isHovering(int mouseX, int mouseY) { - return mouseX >= x && mouseY >= y && mouseX <= x + textWidth && mouseY <= y + 10; + if (!(mouseY >= y && mouseY <= y + 10)) return false; + // seems like recipeWidth is always 176 + if (invertX) return 176 - textWidth - x <= mouseX && mouseX <= 176 - x; + return mouseX >= x && mouseX <= x + textWidth; } public void setCurrentText(String text) { diff --git a/src/main/resources/assets/gregtech/lang/en_us.lang b/src/main/resources/assets/gregtech/lang/en_us.lang index 78cbaeb9f2d..0b7f3bbbc5b 100644 --- a/src/main/resources/assets/gregtech/lang/en_us.lang +++ b/src/main/resources/assets/gregtech/lang/en_us.lang @@ -5499,6 +5499,9 @@ gregtech.jei.fluid.dep_chance_hover=The percentage chance for the vein to be dep gregtech.jei.fluid.dep_amount_hover=The amount the vein will be depleted by gregtech.jei.fluid.dep_yield_hover=The maximum yield of the vein when it is fully depleted +gregtech.jei.overclock_button=§rThe speed of the recipe at %s +gregtech.jei.overclock_warn=Results may not be fully accurate for some recipes! + gregtech.jei.materials.average_mass=Average mass: %,d gregtech.jei.materials.average_protons=Average protons: %,d gregtech.jei.materials.average_neutrons=Average neutrons: %,d From 9cc66cb9b26eca19e817961a543bccf54038ee95 Mon Sep 17 00:00:00 2001 From: vrejhead Date: Fri, 3 May 2024 20:32:37 -0700 Subject: [PATCH 16/23] manual LCR override --- .../java/gregtech/integration/jei/recipe/GTRecipeWrapper.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/gregtech/integration/jei/recipe/GTRecipeWrapper.java b/src/main/java/gregtech/integration/jei/recipe/GTRecipeWrapper.java index 6496bda48bf..523eba74439 100644 --- a/src/main/java/gregtech/integration/jei/recipe/GTRecipeWrapper.java +++ b/src/main/java/gregtech/integration/jei/recipe/GTRecipeWrapper.java @@ -257,7 +257,7 @@ public void drawInfo(@NotNull Minecraft minecraft, int recipeWidth, int recipeHe int tierDifference = getDisplayOCTier() - recipeTier; // if duration is less than 0.5, that means even with one less overclock, the recipe would still 1 tick // so add the yellow warning - double duration = Math.floor(recipe.getDuration() / Math.pow(2, tierDifference)); + double duration = Math.floor(recipe.getDuration() / Math.pow(recipeMap == RecipeMaps.LARGE_CHEMICAL_RECIPES ? 4 : 2, tierDifference)); int color = duration <= 0.5 ? 0xFFFF55 : 0x111111; // currently manual override for fusion's 2x EU/t instead of 4x, maybe custom multiplier per recipeMap soontm? long eut = (long) Math.abs(recipe.getEUt()) * From d2f475485130a002f29928c1eacba11b1f3f8bc2 Mon Sep 17 00:00:00 2001 From: vrejhead Date: Sat, 4 May 2024 00:58:28 -0700 Subject: [PATCH 17/23] spotless + dedicate logic into seperate method --- .../java/gregtech/api/recipes/RecipeMap.java | 2 +- .../jei/recipe/GTRecipeWrapper.java | 64 +++++++++++-------- 2 files changed, 37 insertions(+), 29 deletions(-) diff --git a/src/main/java/gregtech/api/recipes/RecipeMap.java b/src/main/java/gregtech/api/recipes/RecipeMap.java index cad66e52d93..83d646f7a4b 100644 --- a/src/main/java/gregtech/api/recipes/RecipeMap.java +++ b/src/main/java/gregtech/api/recipes/RecipeMap.java @@ -370,7 +370,7 @@ public RecipeMap disableJeiOverclockButton() { return this; } - public boolean JeiOverclockButtonEnabled() { + public boolean jeiOverclockButtonEnabled() { return this.jeiOverclockButton; } diff --git a/src/main/java/gregtech/integration/jei/recipe/GTRecipeWrapper.java b/src/main/java/gregtech/integration/jei/recipe/GTRecipeWrapper.java index 523eba74439..e76828ab0df 100644 --- a/src/main/java/gregtech/integration/jei/recipe/GTRecipeWrapper.java +++ b/src/main/java/gregtech/integration/jei/recipe/GTRecipeWrapper.java @@ -250,19 +250,9 @@ public void drawInfo(@NotNull Minecraft minecraft, int recipeWidth, int recipeHe int yPosition = recipeHeight - ((recipe.getUnhiddenPropertyCount() + defaultLines) * 10 - 3); - int recipeTier = GTUtility.getTierByVoltage(recipe.getEUt()); - // ULV doesn't overclock to LV, so treat ULV recipes as LV - recipeTier += recipeTier == GTValues.ULV ? 1 : 0; - // tier difference *should* not be negative here since at least displayOCTier() == recipeTier - int tierDifference = getDisplayOCTier() - recipeTier; - // if duration is less than 0.5, that means even with one less overclock, the recipe would still 1 tick - // so add the yellow warning - double duration = Math.floor(recipe.getDuration() / Math.pow(recipeMap == RecipeMaps.LARGE_CHEMICAL_RECIPES ? 4 : 2, tierDifference)); - int color = duration <= 0.5 ? 0xFFFF55 : 0x111111; - // currently manual override for fusion's 2x EU/t instead of 4x, maybe custom multiplier per recipeMap soontm? - long eut = (long) Math.abs(recipe.getEUt()) * - (int) Math.pow(recipeMap == RecipeMaps.FUSION_RECIPES ? 2 : 4, tierDifference); - duration = Math.max(1, duration); + // [EUt, duration, color] + long[] overclockResult = calculateJeiOverclock(); + // Default entries if (drawTotalEU) { // sadly we still need a custom override here, since computation uses duration and EU/t very differently @@ -274,23 +264,23 @@ public void drawInfo(@NotNull Minecraft minecraft, int recipeWidth, int recipeHe 0x111111); } else { minecraft.fontRenderer.drawString( - I18n.format("gregtech.recipe.total", (long) (eut * duration)), 0, yPosition, - color); + I18n.format("gregtech.recipe.total", overclockResult[0] * overclockResult[1]), 0, yPosition, + (int) overclockResult[2]); } } if (drawEUt) { // scuffed way of dealing with 2 eu/t recipes, just recomputing instead of checking if eu/t <= 2 minecraft.fontRenderer.drawString( I18n.format(recipe.getEUt() >= 0 ? "gregtech.recipe.eu" : "gregtech.recipe.eu_inverted", - eut, - GTValues.VNF[GTUtility.getTierByVoltage(eut)]), - 0, yPosition += LINE_HEIGHT, color); + overclockResult[0], + GTValues.VNF[GTUtility.getTierByVoltage(overclockResult[0])]), + 0, yPosition += LINE_HEIGHT, (int) overclockResult[2]); } if (drawDuration) { minecraft.fontRenderer.drawString( I18n.format("gregtech.recipe.duration", - TextFormattingUtil.formatNumbers(duration / 20)), - 0, yPosition += LINE_HEIGHT, color); + TextFormattingUtil.formatNumbers(overclockResult[1] / 20D)), + 0, yPosition += LINE_HEIGHT, (int) overclockResult[2]); } // Property custom entries for (Map.Entry, Object> propertyEntry : recipe.getPropertyValues()) { @@ -342,8 +332,9 @@ public void initExtras() { }) .setActiveSupplier(creativePlayerCtPredicate)); } - if (recipeMap.JeiOverclockButtonEnabled()) { + if (recipeMap.jeiOverclockButtonEnabled()) { int recipeTier = Math.max(GTValues.LV, GTUtility.getTierByVoltage(recipe.getEUt())); + int maxTier = Math.max(recipeTier, GregTechAPI.isHighTier() ? GTValues.UIV : GTValues.MAX); // seems like recipeHeight is always 120 jeiTexts.add( new JeiInteractableText(0, 120 - LINE_HEIGHT, GTValues.VNF[recipeTier], 0x111111, recipeTier, true) @@ -354,19 +345,15 @@ public void initExtras() { .setClickAction((minecraft, text, mouseX, mouseY, mouseButton) -> { // just here because if highTier is disabled, if a recipe is (incorrectly) registering // UIV+ recipes, this allows it to go up to the recipe tier for that recipe - int maxTier = Math.max(recipeTier, - GregTechAPI.isHighTier() ? GTValues.UIV : GTValues.MAX); int minTier = Math.max(GTValues.LV, GTUtility.getTierByVoltage(recipe.getEUt())); // ULV isn't real sorry - int state = minTier; + int state = text.getState(); if (mouseButton == 0) { // increment tier if left click - state = text.getState() + 1; - if (state > maxTier) state = minTier; + if (++state > maxTier) state = minTier; } else if (mouseButton == 1) { // decrement tier if right click - state = text.getState() - 1; - if (state < minTier) state = maxTier; + if (--state < minTier) state = maxTier; } text.setCurrentText(GTValues.VNF[state]); text.setState(state); @@ -375,6 +362,27 @@ public void initExtras() { } } + public long[] calculateJeiOverclock() { + long[] result = new long[3]; + + int recipeTier = GTUtility.getTierByVoltage(recipe.getEUt()); + // ULV doesn't overclock to LV, so treat ULV recipes as LV + recipeTier += recipeTier == GTValues.ULV ? 1 : 0; + // tier difference *should* not be negative here since at least displayOCTier() == recipeTier + int tierDifference = getDisplayOCTier() - recipeTier; + // if duration is less than 0.5, that means even with one less overclock, the recipe would still 1 tick + // so add the yellow warning + // LCR and fusion get manual overrides for now + double duration = Math.floor(recipe.getDuration() / + Math.pow(recipeMap == RecipeMaps.LARGE_CHEMICAL_RECIPES ? 4 : 2, tierDifference)); + result[2] = duration <= 0.5 ? 0xFFFF55 : 0x111111; + result[0] = (long) Math.abs(recipe.getEUt()) * + (int) Math.pow(recipeMap == RecipeMaps.FUSION_RECIPES ? 2 : 4, tierDifference); + result[1] = Math.max(1, (int) duration); + + return result; + } + public ChancedItemOutput getOutputChance(int slot) { if (slot >= recipe.getChancedOutputs().getChancedEntries().size() || slot < 0) return null; return recipe.getChancedOutputs().getChancedEntries().get(slot); From 83f07dab03e3e02ea26de37936e0be0000932b59 Mon Sep 17 00:00:00 2001 From: vrejhead Date: Sat, 4 May 2024 01:16:38 -0700 Subject: [PATCH 18/23] yeah recipeHeight isnt always 120 --- .../gregtech/integration/jei/recipe/GTRecipeWrapper.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/main/java/gregtech/integration/jei/recipe/GTRecipeWrapper.java b/src/main/java/gregtech/integration/jei/recipe/GTRecipeWrapper.java index e76828ab0df..90779df4033 100644 --- a/src/main/java/gregtech/integration/jei/recipe/GTRecipeWrapper.java +++ b/src/main/java/gregtech/integration/jei/recipe/GTRecipeWrapper.java @@ -335,9 +335,9 @@ public void initExtras() { if (recipeMap.jeiOverclockButtonEnabled()) { int recipeTier = Math.max(GTValues.LV, GTUtility.getTierByVoltage(recipe.getEUt())); int maxTier = Math.max(recipeTier, GregTechAPI.isHighTier() ? GTValues.UIV : GTValues.MAX); - // seems like recipeHeight is always 120 + // scuffed positioning because we can't have good ui(until mui soontm) jeiTexts.add( - new JeiInteractableText(0, 120 - LINE_HEIGHT, GTValues.VNF[recipeTier], 0x111111, recipeTier, true) + new JeiInteractableText(0, 90 - LINE_HEIGHT, GTValues.VNF[recipeTier], 0x111111, recipeTier, true) .setTooltipBuilder((state, tooltip) -> { tooltip.add(I18n.format("gregtech.jei.overclock_button", GTValues.VNF[state])); tooltip.add(TooltipHelper.BLINKING_CYAN + I18n.format("gregtech.jei.overclock_warn")); @@ -363,8 +363,11 @@ public void initExtras() { } public long[] calculateJeiOverclock() { - long[] result = new long[3]; + // simple case + if (!recipeMap.jeiOverclockButtonEnabled()) + return new long[] { recipe.getEUt(), recipe.getDuration(), 0x111111 }; + long[] result = new long[3]; int recipeTier = GTUtility.getTierByVoltage(recipe.getEUt()); // ULV doesn't overclock to LV, so treat ULV recipes as LV recipeTier += recipeTier == GTValues.ULV ? 1 : 0; From 6ff20df8aaf8a703e8fbd07bc2ea7ef69e540f7e Mon Sep 17 00:00:00 2001 From: vrejhead Date: Sat, 4 May 2024 12:56:13 -0700 Subject: [PATCH 19/23] improve logic --- .../jei/recipe/GTRecipeWrapper.java | 23 ++++++++----------- .../jei/utils/JeiInteractableText.java | 2 +- 2 files changed, 11 insertions(+), 14 deletions(-) diff --git a/src/main/java/gregtech/integration/jei/recipe/GTRecipeWrapper.java b/src/main/java/gregtech/integration/jei/recipe/GTRecipeWrapper.java index 90779df4033..5c72ac55d0d 100644 --- a/src/main/java/gregtech/integration/jei/recipe/GTRecipeWrapper.java +++ b/src/main/java/gregtech/integration/jei/recipe/GTRecipeWrapper.java @@ -334,7 +334,10 @@ public void initExtras() { } if (recipeMap.jeiOverclockButtonEnabled()) { int recipeTier = Math.max(GTValues.LV, GTUtility.getTierByVoltage(recipe.getEUt())); + // just here because if highTier is disabled, if a recipe is (incorrectly) registering + // UIV+ recipes, this allows it to go up to the recipe tier for that recipe only int maxTier = Math.max(recipeTier, GregTechAPI.isHighTier() ? GTValues.UIV : GTValues.MAX); + int minTier = Math.max(GTValues.LV, GTUtility.getTierByVoltage(recipe.getEUt())); // scuffed positioning because we can't have good ui(until mui soontm) jeiTexts.add( new JeiInteractableText(0, 90 - LINE_HEIGHT, GTValues.VNF[recipeTier], 0x111111, recipeTier, true) @@ -343,10 +346,6 @@ public void initExtras() { tooltip.add(TooltipHelper.BLINKING_CYAN + I18n.format("gregtech.jei.overclock_warn")); }) .setClickAction((minecraft, text, mouseX, mouseY, mouseButton) -> { - // just here because if highTier is disabled, if a recipe is (incorrectly) registering - // UIV+ recipes, this allows it to go up to the recipe tier for that recipe - int minTier = Math.max(GTValues.LV, GTUtility.getTierByVoltage(recipe.getEUt())); - // ULV isn't real sorry int state = text.getState(); if (mouseButton == 0) { // increment tier if left click @@ -354,7 +353,7 @@ public void initExtras() { } else if (mouseButton == 1) { // decrement tier if right click if (--state < minTier) state = maxTier; - } + } else return false; text.setCurrentText(GTValues.VNF[state]); text.setState(state); return true; @@ -367,12 +366,14 @@ public long[] calculateJeiOverclock() { if (!recipeMap.jeiOverclockButtonEnabled()) return new long[] { recipe.getEUt(), recipe.getDuration(), 0x111111 }; - long[] result = new long[3]; - int recipeTier = GTUtility.getTierByVoltage(recipe.getEUt()); // ULV doesn't overclock to LV, so treat ULV recipes as LV - recipeTier += recipeTier == GTValues.ULV ? 1 : 0; + int recipeTier = Math.max(GTValues.LV, GTUtility.getTierByVoltage(recipe.getEUt())); // tier difference *should* not be negative here since at least displayOCTier() == recipeTier - int tierDifference = getDisplayOCTier() - recipeTier; + int tierDifference = jeiTexts.get(0).getState() - recipeTier; + // there isn't any overclocking + if (tierDifference == 0) return new long[] { recipe.getEUt(), recipe.getDuration(), 0x111111 }; + + long[] result = new long[3]; // if duration is less than 0.5, that means even with one less overclock, the recipe would still 1 tick // so add the yellow warning // LCR and fusion get manual overrides for now @@ -411,8 +412,4 @@ public boolean isNotConsumedItem(int slot) { public boolean isNotConsumedFluid(int slot) { return slot < this.sortedFluidInputs.size() && this.sortedFluidInputs.get(slot).isNonConsumable(); } - - public int getDisplayOCTier() { - return jeiTexts.isEmpty() ? Short.MIN_VALUE : jeiTexts.get(0).getState(); - } } diff --git a/src/main/java/gregtech/integration/jei/utils/JeiInteractableText.java b/src/main/java/gregtech/integration/jei/utils/JeiInteractableText.java index 72669232ec2..333adfaec21 100644 --- a/src/main/java/gregtech/integration/jei/utils/JeiInteractableText.java +++ b/src/main/java/gregtech/integration/jei/utils/JeiInteractableText.java @@ -26,7 +26,7 @@ public class JeiInteractableText { * @param color the default color of the text, overridden by in-text formatting codes * @param baseState the default state of the button, it is used for tooltip and general information storage * @param invertX instead defines x as the distance from the right border, - * * this takes into account the text width, + * this takes into account the text width, * ensuring the rightmost part of the text is always aligned */ public JeiInteractableText(int x, int y, String defaultText, int color, int baseState, boolean invertX) { From 5d98bf83a55339a54cca3bfdbdffd12c22c9e8e7 Mon Sep 17 00:00:00 2001 From: Zorbatron Date: Sun, 4 Aug 2024 21:33:47 -0400 Subject: [PATCH 20/23] Add the base chance + tier boosted chance to output items in recipe tooltips --- .../integration/jei/recipe/GTRecipeWrapper.java | 12 ++++++++++++ src/main/resources/assets/gregtech/lang/en_us.lang | 1 + 2 files changed, 13 insertions(+) diff --git a/src/main/java/gregtech/integration/jei/recipe/GTRecipeWrapper.java b/src/main/java/gregtech/integration/jei/recipe/GTRecipeWrapper.java index 5c72ac55d0d..915c0ff6045 100644 --- a/src/main/java/gregtech/integration/jei/recipe/GTRecipeWrapper.java +++ b/src/main/java/gregtech/integration/jei/recipe/GTRecipeWrapper.java @@ -211,6 +211,18 @@ public void addIngredientTooltips(@NotNull Collection tooltip, boolean n tooltip.add(TooltipHelper.BLINKING_CYAN + I18n.format("gregtech.recipe.chance", chance, boost)); } + + // Add the total chance to the tooltip + if (recipeMap.jeiOverclockButtonEnabled()) { + int tier = jeiTexts.get(0).getState(); + int recipeTier = Math.max(GTValues.LV, GTUtility.getTierByVoltage(recipe.getEUt())); + int tierDifference = tier - recipeTier; + + // The total chance may or may not max out at 100%. + // TODO possibly change in the future. + double totalChance = Math.min(chance + boost * tierDifference, 100); + tooltip.add(I18n.format("gregtech.recipe.chance_total", GTValues.VNF[tier], totalChance)); + } } } else if (notConsumed) { tooltip.add(TooltipHelper.BLINKING_CYAN + I18n.format("gregtech.recipe.not_consumed")); diff --git a/src/main/resources/assets/gregtech/lang/en_us.lang b/src/main/resources/assets/gregtech/lang/en_us.lang index 0b7f3bbbc5b..6026510e0e1 100644 --- a/src/main/resources/assets/gregtech/lang/en_us.lang +++ b/src/main/resources/assets/gregtech/lang/en_us.lang @@ -5365,6 +5365,7 @@ gregtech.recipe.amperage=Amperage: %,d gregtech.recipe.not_consumed=Does not get consumed in the process gregtech.recipe.chance=Chance: %s%% +%s%%/tier gregtech.recipe.chance_logic=Chance: %s%% +%s%%/tier (%s) +gregtech.recipe.chance_total=At %s§r: %f%% gregtech.chance_logic.or=OR gregtech.chance_logic.and=AND gregtech.chance_logic.xor=XOR From ca8fdbd757c2138c82449ce8d3e2cfc6673952fe Mon Sep 17 00:00:00 2001 From: Zorbatron Date: Sun, 4 Aug 2024 23:59:01 -0400 Subject: [PATCH 21/23] Do the same for the ore processing pages --- .../integration/jei/basic/OreByProduct.java | 76 +++++++++++++++++++ 1 file changed, 76 insertions(+) diff --git a/src/main/java/gregtech/integration/jei/basic/OreByProduct.java b/src/main/java/gregtech/integration/jei/basic/OreByProduct.java index 8e062d069c0..dd17b409db2 100755 --- a/src/main/java/gregtech/integration/jei/basic/OreByProduct.java +++ b/src/main/java/gregtech/integration/jei/basic/OreByProduct.java @@ -1,5 +1,7 @@ package gregtech.integration.jei.basic; +import gregtech.api.GTValues; +import gregtech.api.GregTechAPI; import gregtech.api.recipes.chance.output.impl.ChancedItemOutput; import gregtech.api.unification.OreDictUnifier; import gregtech.api.unification.material.Material; @@ -10,12 +12,18 @@ import gregtech.api.unification.ore.OrePrefix; import gregtech.client.utils.TooltipHelper; import gregtech.common.metatileentities.MetaTileEntities; +import gregtech.integration.jei.utils.JeiInteractableText; +import net.minecraft.client.Minecraft; +import net.minecraft.client.audio.PositionedSoundRecord; +import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.resources.I18n; import net.minecraft.init.Blocks; import net.minecraft.init.Items; +import net.minecraft.init.SoundEvents; import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.fml.client.config.GuiUtils; import net.minecraftforge.oredict.OreDictionary; import com.google.common.collect.ImmutableList; @@ -25,6 +33,7 @@ import mezz.jei.api.ingredients.VanillaTypes; import mezz.jei.api.recipe.IRecipeWrapper; import org.apache.commons.lang3.tuple.Pair; +import org.jetbrains.annotations.NotNull; import java.util.ArrayList; import java.util.List; @@ -37,6 +46,8 @@ public class OreByProduct implements IRecipeWrapper { private static final int NUM_INPUTS = 21; + public final List jeiTexts = new ArrayList<>(); + public static void addOreByProductPrefix(OrePrefix orePrefix) { if (!ORES.contains(orePrefix)) { ORES.add(orePrefix); @@ -275,6 +286,30 @@ public OreByProduct(Material material) { } else { addEmptyOutputs(6); } + + // just here because if highTier is disabled, if a recipe is (incorrectly) registering + // UIV+ recipes, this allows it to go up to the recipe tier for that recipe only + int maxTier = GregTechAPI.isHighTier() ? GTValues.UIV : GTValues.MAX; + // scuffed positioning because we can't have good ui(until mui soontm) + jeiTexts.add( + new JeiInteractableText(0, 160, GTValues.VNF[GTValues.LV], 0x111111, GTValues.LV, true) + .setTooltipBuilder((state, tooltip) -> { + tooltip.add(I18n.format("gregtech.jei.overclock_button", GTValues.VNF[state])); + tooltip.add(TooltipHelper.BLINKING_CYAN + I18n.format("gregtech.jei.overclock_warn")); + }) + .setClickAction((minecraft, text, mouseX, mouseY, mouseButton) -> { + int state = text.getState(); + if (mouseButton == 0) { + // increment tier if left click + if (++state > maxTier) state = GTValues.LV; + } else if (mouseButton == 1) { + // decrement tier if right click + if (--state < GTValues.LV) state = maxTier; + } else return false; + text.setCurrentText(GTValues.VNF[state]); + text.setState(state); + return true; + })); } @Override @@ -290,6 +325,18 @@ public void addTooltip(int slotIndex, boolean input, Object ingredient, List tooltip = new ArrayList<>(); + text.buildTooltip(tooltip); + if (tooltip.isEmpty()) continue; + int width = (int) (minecraft.displayWidth / 2f + recipeWidth / 2f); + GuiUtils.drawHoveringText(tooltip, mouseX, mouseY, width, minecraft.displayHeight, + Math.min(150, width - mouseX - 5), minecraft.fontRenderer); + GlStateManager.disableLighting(); + } + } + } + + @Override + public boolean handleClick(@NotNull Minecraft minecraft, int mouseX, int mouseY, int mouseButton) { + for (JeiInteractableText text : jeiTexts) { + if (text.isHovering(mouseX, mouseY) && + text.getTextClickAction().click(minecraft, text, mouseX, mouseY, mouseButton)) { + Minecraft.getMinecraft().getSoundHandler() + .playSound(PositionedSoundRecord.getMasterRecord(SoundEvents.UI_BUTTON_CLICK, 1.0F)); + return true; + } + } + return false; + } } From b614312023b56c9e1d864ff50b6852bb776afc8f Mon Sep 17 00:00:00 2001 From: Zorbatron Date: Fri, 9 Aug 2024 17:30:44 -0400 Subject: [PATCH 22/23] Reset the voltage to the recipe if middle clicked --- .../java/gregtech/integration/jei/recipe/GTRecipeWrapper.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/java/gregtech/integration/jei/recipe/GTRecipeWrapper.java b/src/main/java/gregtech/integration/jei/recipe/GTRecipeWrapper.java index 915c0ff6045..05802a11d86 100644 --- a/src/main/java/gregtech/integration/jei/recipe/GTRecipeWrapper.java +++ b/src/main/java/gregtech/integration/jei/recipe/GTRecipeWrapper.java @@ -365,6 +365,9 @@ public void initExtras() { } else if (mouseButton == 1) { // decrement tier if right click if (--state < minTier) state = maxTier; + } else if (mouseButton == 2) { + // reset tier if middle click + state = minTier; } else return false; text.setCurrentText(GTValues.VNF[state]); text.setState(state); From ff93f2cf4dfd4b714ca9e0252163ac8cce5bd7ab Mon Sep 17 00:00:00 2001 From: Zorbatron <46525467+Zorbatron@users.noreply.github.com> Date: Sun, 17 Nov 2024 22:25:30 -0500 Subject: [PATCH 23/23] Make middle clicking reset the ore page too. Make it work after merging in main --- .../java/gregtech/api/recipes/RecipeMaps.java | 10 +++++----- .../integration/jei/basic/OreByProduct.java | 13 ++++++++----- .../jei/recipe/GTRecipeWrapper.java | 18 +++++++++--------- 3 files changed, 22 insertions(+), 19 deletions(-) diff --git a/src/main/java/gregtech/api/recipes/RecipeMaps.java b/src/main/java/gregtech/api/recipes/RecipeMaps.java index 37bbc5b9ad2..94453eab348 100644 --- a/src/main/java/gregtech/api/recipes/RecipeMaps.java +++ b/src/main/java/gregtech/api/recipes/RecipeMaps.java @@ -1488,7 +1488,7 @@ public final class RecipeMaps { .sound(GTSoundEvents.COMBUSTION) .allowEmptyOutputs() .generator() - .disableJeiOverclockButton() + .disableJeiOverclockButton() .build(); @ZenProperty @@ -1500,7 +1500,7 @@ public final class RecipeMaps { .sound(GTSoundEvents.TURBINE) .allowEmptyOutputs() .generator() - .disableJeiOverclockButton() + .disableJeiOverclockButton() .build(); @ZenProperty @@ -1513,7 +1513,7 @@ public final class RecipeMaps { .sound(GTSoundEvents.TURBINE) .allowEmptyOutputs() .generator() - .disableJeiOverclockButton() + .disableJeiOverclockButton() .build(); @ZenProperty @@ -1525,7 +1525,7 @@ public final class RecipeMaps { .sound(GTSoundEvents.COMBUSTION) .allowEmptyOutputs() .generator() - .disableJeiOverclockButton() + .disableJeiOverclockButton() .build(); @ZenProperty @@ -1538,7 +1538,7 @@ public final class RecipeMaps { .sound(GTSoundEvents.TURBINE) .allowEmptyOutputs() .generator() - .disableJeiOverclockButton() + .disableJeiOverclockButton() .build(); private RecipeMaps() {} diff --git a/src/main/java/gregtech/integration/jei/basic/OreByProduct.java b/src/main/java/gregtech/integration/jei/basic/OreByProduct.java index dd17b409db2..2deb2ac6ca1 100755 --- a/src/main/java/gregtech/integration/jei/basic/OreByProduct.java +++ b/src/main/java/gregtech/integration/jei/basic/OreByProduct.java @@ -289,12 +289,12 @@ public OreByProduct(Material material) { // just here because if highTier is disabled, if a recipe is (incorrectly) registering // UIV+ recipes, this allows it to go up to the recipe tier for that recipe only - int maxTier = GregTechAPI.isHighTier() ? GTValues.UIV : GTValues.MAX; + int maxTier = GregTechAPI.isHighTier() ? GTValues.UIV : GTValues.MAX_TRUE; // scuffed positioning because we can't have good ui(until mui soontm) jeiTexts.add( - new JeiInteractableText(0, 160, GTValues.VNF[GTValues.LV], 0x111111, GTValues.LV, true) + new JeiInteractableText(0, 160, GTValues.VOCNF[GTValues.LV], 0x111111, GTValues.LV, true) .setTooltipBuilder((state, tooltip) -> { - tooltip.add(I18n.format("gregtech.jei.overclock_button", GTValues.VNF[state])); + tooltip.add(I18n.format("gregtech.jei.overclock_button", GTValues.VOCNF[state])); tooltip.add(TooltipHelper.BLINKING_CYAN + I18n.format("gregtech.jei.overclock_warn")); }) .setClickAction((minecraft, text, mouseX, mouseY, mouseButton) -> { @@ -305,8 +305,11 @@ public OreByProduct(Material material) { } else if (mouseButton == 1) { // decrement tier if right click if (--state < GTValues.LV) state = maxTier; + } else if (mouseButton == 2) { + // reset tier if middle click + state = GTValues.LV; } else return false; - text.setCurrentText(GTValues.VNF[state]); + text.setCurrentText(GTValues.VOCNF[state]); text.setState(state); return true; })); @@ -336,7 +339,7 @@ public void addTooltip(int slotIndex, boolean input, Object ingredient, List tooltip, boolean n // The total chance may or may not max out at 100%. // TODO possibly change in the future. double totalChance = Math.min(chance + boost * tierDifference, 100); - tooltip.add(I18n.format("gregtech.recipe.chance_total", GTValues.VNF[tier], totalChance)); + tooltip.add(I18n.format("gregtech.recipe.chance_total", GTValues.VOCNF[tier], totalChance)); } } } else if (notConsumed) { @@ -278,7 +278,7 @@ public void drawInfo(@NotNull Minecraft minecraft, int recipeWidth, int recipeHe // sadly we still need a custom override here, since computation uses duration and EU/t very differently if (recipe.hasProperty(TotalComputationProperty.getInstance()) && recipe.hasProperty(ComputationProperty.getInstance())) { - long eu = Math.abs((long) recipe.getEUt()) * recipe.getDuration(); + long eu = Math.abs(recipe.getEUt()) * recipe.getDuration(); int minimumCWUt = recipe.getProperty(ComputationProperty.getInstance(), 1); minecraft.fontRenderer.drawString(I18n.format("gregtech.recipe.max_eu", eu / minimumCWUt), 0, yPosition, 0x111111); @@ -293,7 +293,7 @@ public void drawInfo(@NotNull Minecraft minecraft, int recipeWidth, int recipeHe minecraft.fontRenderer.drawString( I18n.format(recipe.getEUt() >= 0 ? "gregtech.recipe.eu" : "gregtech.recipe.eu_inverted", overclockResult[0], - GTValues.VNF[GTUtility.getTierByVoltage(overclockResult[0])]), + GTValues.VOCNF[GTUtility.getOCTierByVoltage(overclockResult[0])]), 0, yPosition += LINE_HEIGHT, (int) overclockResult[2]); } if (drawDuration) { @@ -368,17 +368,17 @@ public void initExtras() { .setClickAction((mc, x, y, button) -> false) .setActiveSupplier(creativeTweaker)); - if (recipeMap.jeiOverclockButtonEnabled()) { + if (recipeMap != null && recipeMap.jeiOverclockButtonEnabled()) { int recipeTier = Math.max(GTValues.LV, GTUtility.getTierByVoltage(recipe.getEUt())); // just here because if highTier is disabled, if a recipe is (incorrectly) registering // UIV+ recipes, this allows it to go up to the recipe tier for that recipe only - int maxTier = Math.max(recipeTier, GregTechAPI.isHighTier() ? GTValues.UIV : GTValues.MAX); + int maxTier = Math.max(recipeTier, GregTechAPI.isHighTier() ? GTValues.UIV : GTValues.MAX_TRUE); int minTier = Math.max(GTValues.LV, GTUtility.getTierByVoltage(recipe.getEUt())); // scuffed positioning because we can't have good ui(until mui soontm) jeiTexts.add( - new JeiInteractableText(0, 90 - LINE_HEIGHT, GTValues.VNF[recipeTier], 0x111111, recipeTier, true) + new JeiInteractableText(0, 90 - LINE_HEIGHT, GTValues.VOCNF[recipeTier], 0x111111, recipeTier, true) .setTooltipBuilder((state, tooltip) -> { - tooltip.add(I18n.format("gregtech.jei.overclock_button", GTValues.VNF[state])); + tooltip.add(I18n.format("gregtech.jei.overclock_button", GTValues.VOCNF[state])); tooltip.add(TooltipHelper.BLINKING_CYAN + I18n.format("gregtech.jei.overclock_warn")); }) .setClickAction((minecraft, text, mouseX, mouseY, mouseButton) -> { @@ -393,7 +393,7 @@ public void initExtras() { // reset tier if middle click state = minTier; } else return false; - text.setCurrentText(GTValues.VNF[state]); + text.setCurrentText(GTValues.VOCNF[state]); text.setState(state); return true; })); @@ -419,7 +419,7 @@ public long[] calculateJeiOverclock() { double duration = Math.floor(recipe.getDuration() / Math.pow(recipeMap == RecipeMaps.LARGE_CHEMICAL_RECIPES ? 4 : 2, tierDifference)); result[2] = duration <= 0.5 ? 0xFFFF55 : 0x111111; - result[0] = (long) Math.abs(recipe.getEUt()) * + result[0] = Math.abs(recipe.getEUt()) * (int) Math.pow(recipeMap == RecipeMaps.FUSION_RECIPES ? 2 : 4, tierDifference); result[1] = Math.max(1, (int) duration);