diff options
author | Vixid <52578495+Vixid1@users.noreply.github.com> | 2022-10-30 10:26:40 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-10-30 21:26:40 +1100 |
commit | e4033c2dad92fedb7feb7cfdd205aa6290e4294b (patch) | |
tree | c27fb17b9d6c12c6cd115e1d002285abf5c1fedb /src/main/java/io | |
parent | 0ff09b9032d2f1a9c5a8cab3c876037702445af6 (diff) | |
download | NotEnoughUpdates-e4033c2dad92fedb7feb7cfdd205aa6290e4294b.tar.gz NotEnoughUpdates-e4033c2dad92fedb7feb7cfdd205aa6290e4294b.tar.bz2 NotEnoughUpdates-e4033c2dad92fedb7feb7cfdd205aa6290e4294b.zip |
Recipe History and Fairy Soul distance meter. (#357)
Co-authored-by: Roman / Linnea Gräf <roman.graef@gmail.com>
Co-authored-by: Walker Selby <git@walkerselby.com>
Diffstat (limited to 'src/main/java/io')
7 files changed, 123 insertions, 7 deletions
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NEUManager.java b/src/main/java/io/github/moulberry/notenoughupdates/NEUManager.java index af190244..71aa10b6 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/NEUManager.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/NEUManager.java @@ -34,6 +34,7 @@ import io.github.moulberry.notenoughupdates.recipes.CraftingOverlay; import io.github.moulberry.notenoughupdates.recipes.CraftingRecipe; import io.github.moulberry.notenoughupdates.recipes.Ingredient; import io.github.moulberry.notenoughupdates.recipes.NeuRecipe; +import io.github.moulberry.notenoughupdates.recipes.RecipeHistory; import io.github.moulberry.notenoughupdates.util.ApiUtil; import io.github.moulberry.notenoughupdates.util.Constants; import io.github.moulberry.notenoughupdates.util.HotmInformation; @@ -113,12 +114,16 @@ public class NEUManager { new KeyBinding("Show usages for item", Keyboard.KEY_U, "NotEnoughUpdates"); public final KeyBinding keybindViewRecipe = new KeyBinding("Show recipe for item", Keyboard.KEY_R, "NotEnoughUpdates"); + public final KeyBinding keybindPreviousRecipe = + new KeyBinding("Show previous recipe", Keyboard.KEY_LBRACKET, "NotEnoughUpdates"); + public final KeyBinding keybindNextRecipe = + new KeyBinding("Show next recipe", Keyboard.KEY_RBRACKET, "NotEnoughUpdates"); public final KeyBinding keybindToggleDisplay = new KeyBinding("Toggle NEU overlay", 0, "NotEnoughUpdates"); public final KeyBinding keybindClosePanes = new KeyBinding("Close NEU panes", 0, "NotEnoughUpdates"); public final KeyBinding keybindItemSelect = new KeyBinding("Select Item", -98 /*middle*/, "NotEnoughUpdates"); public final KeyBinding[] keybinds = new KeyBinding[]{ - keybindGive, keybindFavourite, keybindViewUsages, keybindViewRecipe, - keybindToggleDisplay, keybindClosePanes, keybindItemSelect + keybindGive, keybindFavourite, keybindViewUsages, keybindViewRecipe, keybindPreviousRecipe, + keybindNextRecipe, keybindToggleDisplay, keybindClosePanes, keybindItemSelect }; public String viewItemAttemptID = null; @@ -884,7 +889,6 @@ public class NEUManager { case "viewpotion": neu.sendChatMessage("/viewpotion " + internalName.split(";")[0].toLowerCase(Locale.ROOT)); } - displayGuiItemRecipe(internalName); } public void showRecipe(String internalName) { @@ -988,6 +992,7 @@ public class NEUManager { List<NeuRecipe> usages = getAvailableUsagesFor(internalName); if (usages.isEmpty()) return false; NotEnoughUpdates.INSTANCE.openGui = (new GuiItemRecipe(usages, this)); + RecipeHistory.add(NotEnoughUpdates.INSTANCE.openGui); return true; } @@ -996,6 +1001,7 @@ public class NEUManager { List<NeuRecipe> recipes = getAvailableRecipesFor(internalName); if (recipes.isEmpty()) return false; NotEnoughUpdates.INSTANCE.openGui = (new GuiItemRecipe(recipes, this)); + RecipeHistory.add(NotEnoughUpdates.INSTANCE.openGui); return true; } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/core/util/render/RenderUtils.java b/src/main/java/io/github/moulberry/notenoughupdates/core/util/render/RenderUtils.java index e7ce29c3..d7bd097a 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/core/util/render/RenderUtils.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/core/util/render/RenderUtils.java @@ -378,14 +378,18 @@ public class RenderUtils { } public static void renderWayPoint(List<String> str, Vec3i loc, float partialTicks) { - renderWayPoint(str, new Vector3f(loc.getX(), loc.getY(), loc.getZ()), partialTicks); + renderWayPoint(str, new Vector3f(loc.getX(), loc.getY(), loc.getZ()), partialTicks, false); } public static void renderWayPoint(String str, Vector3f loc, float partialTicks) { - renderWayPoint(Arrays.asList(str), loc, partialTicks); + renderWayPoint(Arrays.asList(str), loc, partialTicks, false); + } + + public static void renderWayPoint(Vec3i loc, float partialTicks) { + renderWayPoint(Arrays.asList(""), new Vector3f(loc.getX(), loc.getY(), loc.getZ()), partialTicks, true); } - public static void renderWayPoint(List<String> lines, Vector3f loc, float partialTicks) { + public static void renderWayPoint(List<String> lines, Vector3f loc, float partialTicks, boolean onlyShowDistance) { GlStateManager.alphaFunc(516, 0.1F); GlStateManager.pushMatrix(); @@ -409,7 +413,7 @@ public class RenderUtils { GlStateManager.translate(x, y, z); GlStateManager.translate(0, viewer.getEyeHeight(), 0); - lines = new ArrayList<>(lines); + lines = onlyShowDistance ? new ArrayList<>() : new ArrayList<>(lines); lines.add(EnumChatFormatting.YELLOW.toString() + Math.round(dist) + "m"); renderNametag(lines); diff --git a/src/main/java/io/github/moulberry/notenoughupdates/listener/NEUEventListener.java b/src/main/java/io/github/moulberry/notenoughupdates/listener/NEUEventListener.java index 43a1daf9..5b388dea 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/listener/NEUEventListener.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/listener/NEUEventListener.java @@ -34,11 +34,13 @@ import io.github.moulberry.notenoughupdates.miscfeatures.ItemCustomizeManager; import io.github.moulberry.notenoughupdates.miscfeatures.NPCRetexturing; import io.github.moulberry.notenoughupdates.miscgui.AccessoryBagOverlay; import io.github.moulberry.notenoughupdates.miscgui.GuiCustomEnchant; +import io.github.moulberry.notenoughupdates.miscgui.GuiItemRecipe; import io.github.moulberry.notenoughupdates.miscgui.hex.GuiCustomHex; import io.github.moulberry.notenoughupdates.miscgui.StorageOverlay; import io.github.moulberry.notenoughupdates.overlays.OverlayManager; import io.github.moulberry.notenoughupdates.overlays.TextOverlay; import io.github.moulberry.notenoughupdates.overlays.TextTabOverlay; +import io.github.moulberry.notenoughupdates.recipes.RecipeHistory; import io.github.moulberry.notenoughupdates.util.Constants; import io.github.moulberry.notenoughupdates.util.NotificationHandler; import io.github.moulberry.notenoughupdates.util.ProfileApiSyncer; @@ -162,6 +164,11 @@ public class NEUEventListener { if (longUpdate) { + + if (!(Minecraft.getMinecraft().currentScreen instanceof GuiItemRecipe)) { + RecipeHistory.clear(); + } + CrystalOverlay.tick(); FairySouls.getInstance().tick(); XPInformation.getInstance().tick(); diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/FairySouls.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/FairySouls.java index 4cdb1557..5fa68fc2 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/FairySouls.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/FairySouls.java @@ -177,6 +177,7 @@ public class FairySouls { double factor = normalize(currentDistSq, 0.0, farSoulDistSq); int rgb = interpolateColors(closeColor, farColor, Math.min(0.40, factor)); RenderUtils.renderBeaconBeamOrBoundingBox(currentSoul, rgb, 1.0f, event.partialTicks); + if (NotEnoughUpdates.INSTANCE.config.misc.fairySoulWaypointDistance) RenderUtils.renderWayPoint(currentSoul, event.partialTicks); } } 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 0a1e5b81..a0a5e71a 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiItemRecipe.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiItemRecipe.java @@ -21,8 +21,10 @@ package io.github.moulberry.notenoughupdates.miscgui; import com.google.common.collect.ImmutableList; import io.github.moulberry.notenoughupdates.NEUManager; +import io.github.moulberry.notenoughupdates.NotEnoughUpdates; import io.github.moulberry.notenoughupdates.core.util.ArrowPagesUtils; import io.github.moulberry.notenoughupdates.recipes.NeuRecipe; +import io.github.moulberry.notenoughupdates.recipes.RecipeHistory; import io.github.moulberry.notenoughupdates.recipes.RecipeSlot; import io.github.moulberry.notenoughupdates.recipes.RecipeType; import io.github.moulberry.notenoughupdates.util.Utils; @@ -259,6 +261,12 @@ public class GuiItemRecipe extends GuiScreen { } } } + + if (keyPressed == manager.keybindPreviousRecipe.getKeyCode()) { + NotEnoughUpdates.INSTANCE.openGui = RecipeHistory.getPrevious(); + } else if (keyPressed == manager.keybindNextRecipe.getKeyCode()) { + NotEnoughUpdates.INSTANCE.openGui = RecipeHistory.getNext(); + } } public void changeRecipe(int tabIndex, int recipeIndex) { @@ -278,6 +286,13 @@ public class GuiItemRecipe extends GuiScreen { super.mouseClicked(mouseX, mouseY, mouseButton); NeuRecipe currentRecipe = getCurrentRecipe(); int[] topLeft = currentRecipe.getPageFlipPositionLeftTopCorner(); + + if (mouseButton == 3) { + NotEnoughUpdates.INSTANCE.openGui = RecipeHistory.getPrevious(); + } else if (mouseButton == 4) { + NotEnoughUpdates.INSTANCE.openGui = RecipeHistory.getNext(); + } + ArrowPagesUtils.onPageSwitchMouse( guiLeft, guiTop, diff --git a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Misc.java b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Misc.java index afeec514..78bb0f95 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Misc.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Misc.java @@ -83,6 +83,15 @@ public class Misc { @Expose @ConfigOption( + name = "Show Waypoint Distance", + desc = "Show the distance to each fairy soul waypoint" + ) + @ConfigEditorBoolean + @ConfigAccordionId(id = 0) + public boolean fairySoulWaypointDistance = false; + + @Expose + @ConfigOption( name = "Mark All As Found", desc = "Mark all fairy souls in current location as found" ) diff --git a/src/main/java/io/github/moulberry/notenoughupdates/recipes/RecipeHistory.java b/src/main/java/io/github/moulberry/notenoughupdates/recipes/RecipeHistory.java new file mode 100644 index 00000000..c4a0f6e4 --- /dev/null +++ b/src/main/java/io/github/moulberry/notenoughupdates/recipes/RecipeHistory.java @@ -0,0 +1,74 @@ +/* + * Copyright (C) 2022 NotEnoughUpdates contributors + * + * This file is part of NotEnoughUpdates. + * + * NotEnoughUpdates is free software: you can redistribute it + * and/or modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation, either + * version 3 of the License, or (at your option) any later version. + * + * NotEnoughUpdates is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with NotEnoughUpdates. If not, see <https://www.gnu.org/licenses/>. + */ + +package io.github.moulberry.notenoughupdates.recipes; + +import net.minecraft.client.gui.GuiScreen; + +import java.util.ArrayList; + +public class RecipeHistory { + + private static final int MAX_HISTORY_SIZE = 50; + + private static ArrayList<GuiScreen> history = new ArrayList<>(); + private static int historyIndex = 0; + + public static void add(GuiScreen recipe) { + if (history.size() == MAX_HISTORY_SIZE) { + history.remove(0); + historyIndex--; + } else { + if (history.size() == 0) { + history.add(recipe); + } else { + if (historyIndex < history.size() - 1) { + history = new ArrayList<>(history.subList(0, historyIndex + 1)); + } + history.add(recipe); + historyIndex++; + } + } + } + + public static GuiScreen getPrevious() { + if (history.size() > 0) { + if (historyIndex - 1 < 0) { + return null; + } + historyIndex--; + return history.get(historyIndex); + } + return null; + } + + public static GuiScreen getNext() { + if (historyIndex < history.size() - 1) { + historyIndex++; + return history.get(historyIndex); + } + return null; + } + + public static void clear() { + history = new ArrayList<>(); + historyIndex = 0; + } + +} |