aboutsummaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
authornea <romangraef@gmail.com>2022-04-15 16:01:01 +0200
committernea <romangraef@gmail.com>2022-04-15 16:01:20 +0200
commit81ec60cdbdc2a18e516698fb74e445c2f0a9f7fc (patch)
tree992d4c525684438a50c214b2dafd58ff2069b795 /src/main
parent9de7bb033454ba1bf50cc3e3762c39d028ff294b (diff)
downloadNotEnoughUpdates-81ec60cdbdc2a18e516698fb74e445c2f0a9f7fc.tar.gz
NotEnoughUpdates-81ec60cdbdc2a18e516698fb74e445c2f0a9f7fc.tar.bz2
NotEnoughUpdates-81ec60cdbdc2a18e516698fb74e445c2f0a9f7fc.zip
better recipe display name
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/NEUManager.java12
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiItemRecipe.java10
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/recipes/CraftingOverlay.java2
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/recipes/MobLootRecipe.java11
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/recipes/NeuRecipe.java4
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/recipes/RecipeType.java4
6 files changed, 27 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 0e683e5a..6572431b 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/NEUManager.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/NEUManager.java
@@ -895,12 +895,12 @@ public class NEUManager {
String clickcommand = item.get("clickcommand").getAsString();
switch (clickcommand.intern()) {
case "viewrecipe":
- displayGuiItemRecipe(internalName, null);
+ displayGuiItemRecipe(internalName);
break;
case "viewoption":
neu.sendChatMessage("/viewpotion " + internalName.split(";")[0].toLowerCase(Locale.ROOT));
}
- displayGuiItemRecipe(internalName, "");
+ displayGuiItemRecipe(internalName);
}
public void showRecipe(String internalName) {
@@ -990,16 +990,16 @@ public class NEUManager {
List<NeuRecipe> usages = getAvailableUsagesFor(internalName);
if (usages.isEmpty()) return false;
Minecraft.getMinecraft().displayGuiScreen(
- new GuiItemRecipe("Item Usages", usages, this));
+ new GuiItemRecipe(usages, this));
return true;
}
- public boolean displayGuiItemRecipe(String internalName, String text) {
+ public boolean displayGuiItemRecipe(String internalName) {
if (!recipesMap.containsKey(internalName)) return false;
List<NeuRecipe> recipes = getAvailableRecipesFor(internalName);
if (recipes.isEmpty()) return false;
Minecraft.getMinecraft().displayGuiScreen(
- new GuiItemRecipe(text != null ? text : "Item Recipe", recipes, this));
+ new GuiItemRecipe(recipes, this));
return true;
}
@@ -1010,7 +1010,7 @@ public class NEUManager {
public boolean failViewItem(String text) {
if (viewItemAttemptID != null && !viewItemAttemptID.isEmpty()) {
if (System.currentTimeMillis() - viewItemAttemptTime < 500) {
- return displayGuiItemRecipe(viewItemAttemptID, text);
+ return displayGuiItemRecipe(viewItemAttemptID);
}
}
return false;
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiItemRecipe.java b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiItemRecipe.java
index 3d2ed9a7..be9ce6c7 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiItemRecipe.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiItemRecipe.java
@@ -49,7 +49,6 @@ public class GuiItemRecipe extends GuiScreen {
private int currentIndex = 0;
private int currentTab = 0;
- private final String title;
private final Map<RecipeType, List<NeuRecipe>> craftingRecipes = new HashMap<>();
private final List<RecipeType> tabs = new ArrayList<>();
private final NEUManager manager;
@@ -59,9 +58,8 @@ public class GuiItemRecipe extends GuiScreen {
public int xSize = 176;
public int ySize = 222;
- public GuiItemRecipe(String title, List<NeuRecipe> unsortedRecipes, NEUManager manager) {
+ public GuiItemRecipe(List<NeuRecipe> unsortedRecipes, NEUManager manager) {
this.manager = manager;
- this.title = title;
for (NeuRecipe recipe : unsortedRecipes) {
craftingRecipes.computeIfAbsent(recipe.getType(), ignored -> new ArrayList<>()).add(recipe);
@@ -123,7 +121,7 @@ public class GuiItemRecipe extends GuiScreen {
drawArrows(currentRecipe, mouseX, mouseY);
Utils.drawStringScaledMaxWidth(
- title,
+ currentRecipe.getTitle(),
fontRendererObj,
guiLeft + TITLE_X,
guiTop + TITLE_Y,
@@ -286,7 +284,7 @@ public class GuiItemRecipe extends GuiScreen {
if (isWithinRect(mouseX, mouseY, slot.getX(this), slot.getY(this), SLOT_SIZE, SLOT_SIZE)) {
ItemStack itemStack = slot.getItemStack();
if (keyPressed == manager.keybindViewRecipe.getKeyCode()) {
- manager.displayGuiItemRecipe(manager.getInternalNameForItem(itemStack), null);
+ manager.displayGuiItemRecipe(manager.getInternalNameForItem(itemStack));
} else if (keyPressed == manager.keybindViewUsages.getKeyCode()) {
manager.displayGuiItemUsages(manager.getInternalNameForItem(itemStack));
}
@@ -350,7 +348,7 @@ public class GuiItemRecipe extends GuiScreen {
if (isWithinRect(mouseX, mouseY, slot.getX(this), slot.getY(this), SLOT_SIZE, SLOT_SIZE)) {
ItemStack itemStack = slot.getItemStack();
if (mouseButton == 0) {
- manager.displayGuiItemRecipe(manager.getInternalNameForItem(itemStack), null);
+ manager.displayGuiItemRecipe(manager.getInternalNameForItem(itemStack));
} else if (mouseButton == 1) {
manager.displayGuiItemUsages(manager.getInternalNameForItem(itemStack));
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/recipes/CraftingOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/recipes/CraftingOverlay.java
index d0b464f6..9d305e1d 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/recipes/CraftingOverlay.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/recipes/CraftingOverlay.java
@@ -103,7 +103,7 @@ public class CraftingOverlay {
if (Keyboard.getEventKey() == Keyboard.KEY_R)
manager.showRecipe(recipeIngredient.getInternalItemId());
if (Keyboard.getEventKey() == Keyboard.KEY_U)
- manager.displayGuiItemRecipe(recipeIngredient.getInternalItemId(), null);
+ manager.displayGuiItemRecipe(recipeIngredient.getInternalItemId());
}
});
});
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/recipes/MobLootRecipe.java b/src/main/java/io/github/moulberry/notenoughupdates/recipes/MobLootRecipe.java
index c8c425fb..dcbf71da 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/recipes/MobLootRecipe.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/recipes/MobLootRecipe.java
@@ -149,6 +149,15 @@ public class MobLootRecipe implements NeuRecipe {
}
@Override
+ public String getTitle() {
+ return getFullMobName();
+ }
+
+ public String getFullMobName() {
+ return (level > 0 ? "§8[§7Lv " + level + "§8] §c" : "§c") + name;
+ }
+
+ @Override
public List<RecipeSlot> getSlots() {
List<RecipeSlot> slots = new ArrayList<>();
BiConsumer<Integer, ItemStack> addSlot = (sl, is) -> slots.add(
@@ -215,7 +224,7 @@ public class MobLootRecipe implements NeuRecipe {
PANORAMA_HEIGHT
)) {
List<String> stuff = new ArrayList<>();
- stuff.add((level > 0 ? "§8[§7Lv " + level + "§8] §c" : "§c") + name);
+ stuff.add(getFullMobName());
stuff.add("");
if (coins > 0)
stuff.add("§r§6Coins: " + coins);
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/recipes/NeuRecipe.java b/src/main/java/io/github/moulberry/notenoughupdates/recipes/NeuRecipe.java
index 232e1629..8202bb48 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/recipes/NeuRecipe.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/recipes/NeuRecipe.java
@@ -17,6 +17,10 @@ public interface NeuRecipe {
RecipeType getType();
+ default String getTitle() {
+ return getType().getLabel();
+ }
+
default void drawExtraInfo(GuiItemRecipe gui, int mouseX, int mouseY) {
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/recipes/RecipeType.java b/src/main/java/io/github/moulberry/notenoughupdates/recipes/RecipeType.java
index 67042a98..cc8b50be 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/recipes/RecipeType.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/recipes/RecipeType.java
@@ -8,8 +8,8 @@ import net.minecraft.item.ItemStack;
public enum RecipeType {
CRAFTING("crafting", "Crafting", CraftingRecipe::parseCraftingRecipe, new ItemStack(Blocks.crafting_table)),
- FORGE("forge", "Forge", ForgeRecipe::parseForgeRecipe, new ItemStack(Blocks.anvil)),
- TRADE("trade", "Trade", VillagerTradeRecipe::parseStaticRecipe, new ItemStack(Items.emerald)),
+ FORGE("forge", "Forging", ForgeRecipe::parseForgeRecipe, new ItemStack(Blocks.anvil)),
+ TRADE("trade", "Trading", VillagerTradeRecipe::parseStaticRecipe, new ItemStack(Items.emerald)),
MOB_LOOT("drops", "Mob Loot", MobLootRecipe::parseRecipe, new ItemStack(Items.diamond_sword));
private final String id;