diff options
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; } |