diff options
-rw-r--r-- | src/main/java/io/github/moulberry/notenoughupdates/NEUManager.java | 17 | ||||
-rw-r--r-- | src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java | 17 |
2 files changed, 18 insertions, 16 deletions
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NEUManager.java b/src/main/java/io/github/moulberry/notenoughupdates/NEUManager.java index 4e5a3a01..d7ed948c 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/NEUManager.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/NEUManager.java @@ -3,7 +3,6 @@ package io.github.moulberry.notenoughupdates; import com.google.gson.*; import io.github.moulberry.notenoughupdates.auction.APIManager; import io.github.moulberry.notenoughupdates.miscgui.GuiItemRecipe; -import io.github.moulberry.notenoughupdates.options.NEUConfig; import io.github.moulberry.notenoughupdates.recipes.CraftingOverlay; import io.github.moulberry.notenoughupdates.recipes.CraftingRecipe; import io.github.moulberry.notenoughupdates.recipes.Ingredient; @@ -419,10 +418,18 @@ public class NEUManager { return recipesMap.getOrDefault(internalName, Collections.emptySet()); } + public List<NeuRecipe> getAvailableRecipesFor(String internalname) { + return getRecipesFor(internalname).stream().filter(NeuRecipe::isAvailable).collect(Collectors.toList()); + } + public Set<NeuRecipe> getUsagesFor(String internalName) { return usagesMap.getOrDefault(internalName, Collections.emptySet()); } + public List<NeuRecipe> getAvailableUsagesFor(String internalname) { + return getUsagesFor(internalname).stream().filter(NeuRecipe::isAvailable).collect(Collectors.toList()); + } + /** * Searches a string for a query. This method is used to mimic the behaviour of the more complex map-based search * function. This method is used for the chest-item-search feature. @@ -953,19 +960,19 @@ public class NEUManager { public boolean displayGuiItemUsages(String internalName) { if (!usagesMap.containsKey(internalName)) return false; - Set<NeuRecipe> usages = usagesMap.get(internalName); + List<NeuRecipe> usages = getAvailableRecipesFor(internalName); if (usages.isEmpty()) return false; Minecraft.getMinecraft().displayGuiScreen( - new GuiItemRecipe("Item Usages", usages.stream().filter(NeuRecipe::isAvailable).collect(Collectors.toList()), this)); + new GuiItemRecipe("Item Usages", usages, this)); return true; } public boolean displayGuiItemRecipe(String internalName, String text) { if (!recipesMap.containsKey(internalName)) return false; - Set<NeuRecipe> recipes = recipesMap.get(internalName); + List<NeuRecipe> recipes = getAvailableRecipesFor(internalName); if (recipes.isEmpty()) return false; Minecraft.getMinecraft().displayGuiScreen( - new GuiItemRecipe(text != null ? text : "Item Recipe", recipes.stream().filter(NeuRecipe::isAvailable).collect(Collectors.toList()), this)); + new GuiItemRecipe(text != null ? text : "Item Recipe", recipes, this)); return true; } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java index 1fbffd5f..04ed9964 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java @@ -62,9 +62,8 @@ import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL14; import org.lwjgl.util.vector.Vector2f; -import java.awt.*; +import java.awt.Color; import java.lang.reflect.InvocationTargetException; -import java.util.List; import java.util.*; import java.util.concurrent.CompletableFuture; import java.util.concurrent.ExecutorService; @@ -2345,14 +2344,10 @@ public class NEUOverlay extends Gui { ItemPriceInformation.addToTooltip(text, internalname, stack); } - boolean hasClick = false; - boolean hasInfo = false; - if (json.has("clickcommand") && !json.get("clickcommand").getAsString().isEmpty()) { - hasClick = true; - } - if (json.has("info") && json.get("info").getAsJsonArray().size() > 0) { - hasInfo = true; - } + boolean hasClick = + (json.has("clickcommand") && !json.get("clickcommand").getAsString().isEmpty()) + || !manager.getAvailableRecipesFor(internalname).isEmpty(); + boolean hasInfo = json.has("info") && json.get("info").getAsJsonArray().size() > 0; if (hasClick || hasInfo) text.add(""); if (hasClick) @@ -2685,4 +2680,4 @@ public class NEUOverlay extends Gui { public float getInfoPaneOffsetFactor() { return infoPaneOffsetFactor.getValue() * getWidthMult(); } -}
\ No newline at end of file +} |