aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornea <romangraef@gmail.com>2022-02-10 23:10:17 +0100
committernea <romangraef@gmail.com>2022-02-10 23:10:17 +0100
commit172359d22651351d5c584b12d5ab81e3eba9f2a4 (patch)
tree0f28ddf998bc569ea5159f08112a5722902537cc
parent5324270800260afaea795934114a6bcd78e11c9f (diff)
downloadNotEnoughUpdates-172359d22651351d5c584b12d5ab81e3eba9f2a4.tar.gz
NotEnoughUpdates-172359d22651351d5c584b12d5ab81e3eba9f2a4.tar.bz2
NotEnoughUpdates-172359d22651351d5c584b12d5ab81e3eba9f2a4.zip
available recipes
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/NEUManager.java17
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java17
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
+}