diff options
author | jani270 <69345714+jani270@users.noreply.github.com> | 2024-02-14 00:20:10 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-02-14 00:20:10 +0100 |
commit | 6538b081f82ef9c8ba2050fae240dd0bba355461 (patch) | |
tree | 81d9de2421a9625750cd5d6a84b85c3dd787c822 /src/main/java | |
parent | f76e940e28d43ea33e2b40a918495e3c5a8cc5ad (diff) | |
download | NotEnoughUpdates-6538b081f82ef9c8ba2050fae240dd0bba355461.tar.gz NotEnoughUpdates-6538b081f82ef9c8ba2050fae240dd0bba355461.tar.bz2 NotEnoughUpdates-6538b081f82ef9c8ba2050fae240dd0bba355461.zip |
Added Ctrl-Click to open bazaar to the minion helper (#1011)
* feat: Ctrl-Click to open bazaar
* Use max number of items for minion crafts
---------
Co-authored-by: Linnea Gräf <nea@nea.moe>
Diffstat (limited to 'src/main/java')
3 files changed, 42 insertions, 2 deletions
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/auction/APIManager.java b/src/main/java/io/github/moulberry/notenoughupdates/auction/APIManager.java index 58d8c23b..2e65ead3 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/auction/APIManager.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/auction/APIManager.java @@ -271,7 +271,7 @@ public class APIManager { return e.getAsJsonObject(); } - private static final List<String> hardcodedVanillaItems = Utils.createList( + public static final List<String> hardcodedVanillaItems = Utils.createList( "WOOD_AXE", "WOOD_HOE", "WOOD_PICKAXE", "WOOD_SPADE", "WOOD_SWORD", "GOLD_AXE", "GOLD_HOE", "GOLD_PICKAXE", "GOLD_SPADE", "GOLD_SWORD", "ROOKIE_HOE" diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/Minion.java b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/Minion.java index 346fbfe2..4dcb1ec2 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/Minion.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/Minion.java @@ -20,13 +20,25 @@ package io.github.moulberry.notenoughupdates.miscgui.minionhelper; import io.github.moulberry.notenoughupdates.NotEnoughUpdates; +import io.github.moulberry.notenoughupdates.auction.APIManager; +import io.github.moulberry.notenoughupdates.core.util.MiscUtils; import io.github.moulberry.notenoughupdates.miscgui.minionhelper.render.renderables.OverviewLine; import io.github.moulberry.notenoughupdates.miscgui.minionhelper.requirements.MinionRequirement; +import io.github.moulberry.notenoughupdates.miscgui.minionhelper.sources.CraftingSource; import io.github.moulberry.notenoughupdates.miscgui.minionhelper.sources.CustomSource; import io.github.moulberry.notenoughupdates.miscgui.minionhelper.sources.MinionSource; +import io.github.moulberry.notenoughupdates.util.ItemResolutionQuery; +import io.github.moulberry.notenoughupdates.util.Utils; +import net.minecraft.item.ItemStack; +import org.lwjgl.input.Keyboard; +import org.lwjgl.input.Mouse; import java.util.ArrayList; +import java.util.Comparator; +import java.util.HashMap; import java.util.List; +import java.util.Map; +import java.util.Optional; public class Minion extends OverviewLine { private final String internalName; @@ -107,7 +119,34 @@ public class Minion extends OverviewLine { @Override public void onClick() { - NotEnoughUpdates.INSTANCE.manager.displayGuiItemRecipe(internalName); + if (Mouse.getEventButton() != 0 || !Keyboard.isKeyDown(Keyboard.KEY_LCONTROL)) { + NotEnoughUpdates.INSTANCE.manager.displayGuiItemRecipe(internalName); + } else { + if (minionSource instanceof CraftingSource) { + CraftingSource craftingSource = (CraftingSource) minionSource; + Map<String, Integer> counts = new HashMap<>(); + for (Map.Entry<String, Integer> entry : craftingSource.getItems().entries()) { + counts.compute(entry.getKey(), (k, v) -> (v == null ? 0 : v) + entry.getValue()); + } + Optional<Map.Entry<String, Integer>> resource = counts + .entrySet() + .stream() + .filter(it -> !APIManager.hardcodedVanillaItems.contains(it.getKey())) + .max(Comparator.comparingInt(Map.Entry::getValue)); + if (!resource.isPresent()) return; + + String bazaarName = resource.get().getKey(); + int totalAmount = resource.get().getValue(); + + MiscUtils.copyToClipboard(String.valueOf(totalAmount)); + ItemStack itemStack = new ItemResolutionQuery(NotEnoughUpdates.INSTANCE.manager).withKnownInternalName( + bazaarName).resolveToItemStack(); + if (itemStack != null) { + String displayName = Utils.cleanColour(itemStack.getDisplayName()); + NotEnoughUpdates.INSTANCE.trySendCommand("/bz " + displayName); + } + } + } } public void setCustomSource(CustomSource customSource) { diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/render/MinionHelperOverlayHover.java b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/render/MinionHelperOverlayHover.java index a3549d51..18b26754 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/render/MinionHelperOverlayHover.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/render/MinionHelperOverlayHover.java @@ -196,6 +196,7 @@ public class MinionHelperOverlayHover { lines.add(""); lines.add("§eClick to view recipe!"); + lines.add("§eCtrl-Click to open bazaar!"); } return lines; } |