aboutsummaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
authorLorenz <lo.scherf@gmail.com>2022-07-30 15:09:25 +0200
committerLorenz <lo.scherf@gmail.com>2022-07-30 15:09:25 +0200
commit61577ecf7f4b4eeaa9669253d5aba87d2a5b0df5 (patch)
treed85904cf6593bd993aa9faa5a380bcdca218e724 /src/main
parentbc75fa40f943490cb8be9669ab2a7f84a2efdbb6 (diff)
downloadNotEnoughUpdates-61577ecf7f4b4eeaa9669253d5aba87d2a5b0df5.tar.gz
NotEnoughUpdates-61577ecf7f4b4eeaa9669253d5aba87d2a5b0df5.tar.bz2
NotEnoughUpdates-61577ecf7f4b4eeaa9669253d5aba87d2a5b0df5.zip
updating overlay when finding new minions in inventory
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/commands/dev/DevTestCommand.java4
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/MinionHelperManager.java30
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/MinionHelperOverlay.java20
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/loaders/MinionHelperApiLoader.java6
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/loaders/MinionHelperInventoryLoader.java11
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/loaders/MinionHelperRepoLoader.java4
6 files changed, 64 insertions, 11 deletions
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/commands/dev/DevTestCommand.java b/src/main/java/io/github/moulberry/notenoughupdates/commands/dev/DevTestCommand.java
index 307d0e7b..ca4d3080 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/commands/dev/DevTestCommand.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/commands/dev/DevTestCommand.java
@@ -27,6 +27,7 @@ import io.github.moulberry.notenoughupdates.miscfeatures.customblockzones.Custom
import io.github.moulberry.notenoughupdates.miscfeatures.customblockzones.LocationChangeEvent;
import io.github.moulberry.notenoughupdates.miscfeatures.customblockzones.SpecialBlockZone;
import io.github.moulberry.notenoughupdates.miscgui.GuiPriceGraph;
+import io.github.moulberry.notenoughupdates.miscgui.minionhelper.MinionHelperManager;
import io.github.moulberry.notenoughupdates.util.SBInfo;
import io.github.moulberry.notenoughupdates.util.Utils;
import net.minecraft.client.Minecraft;
@@ -178,5 +179,8 @@ public class DevTestCommand extends ClientCommandBase {
double z = Math.floor(Minecraft.getMinecraft().thePlayer.posZ) + 0.5f;
Minecraft.getMinecraft().thePlayer.setPosition(x, Minecraft.getMinecraft().thePlayer.posY, z);
}
+ if (args.length >= 1 && args[0].equalsIgnoreCase("minion")) {
+ MinionHelperManager.getInstance().handleCommand(args);
+ }
}
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/MinionHelperManager.java b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/MinionHelperManager.java
index dbfeffbf..aa579774 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/MinionHelperManager.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/MinionHelperManager.java
@@ -22,6 +22,8 @@ package io.github.moulberry.notenoughupdates.miscgui.minionhelper;
import com.google.common.collect.ArrayListMultimap;
import com.google.gson.JsonObject;
import io.github.moulberry.notenoughupdates.NotEnoughUpdates;
+import io.github.moulberry.notenoughupdates.miscgui.minionhelper.loaders.MinionHelperApiLoader;
+import io.github.moulberry.notenoughupdates.miscgui.minionhelper.loaders.MinionHelperRepoLoader;
import io.github.moulberry.notenoughupdates.miscgui.minionhelper.requirements.CollectionRequirement;
import io.github.moulberry.notenoughupdates.miscgui.minionhelper.requirements.CustomRequirement;
import io.github.moulberry.notenoughupdates.miscgui.minionhelper.requirements.MinionRequirement;
@@ -315,4 +317,32 @@ public class MinionHelperManager {
public boolean isShouldNotifyNoCollectionApi() {
return shouldNotifyNoCollectionApi;
}
+
+ public void handleCommand(String[] args) {
+ if (args.length == 2) {
+ String parameter = args[1];
+ if (parameter.equals("clear")) {
+ minions.clear();
+ Utils.addChatMessage("minions cleared");
+ return;
+ }
+ if (parameter.equals("resetrepo")) {
+ MinionHelperRepoLoader.getInstance().setDirty();
+ Utils.addChatMessage("repo reload requested");
+ return;
+ }
+ if (parameter.equals("resetapi")) {
+ MinionHelperApiLoader.getInstance().setDirty();
+ Utils.addChatMessage("api reload requested");
+ return;
+ }
+ }
+
+ Utils.addChatMessage("");
+ Utils.addChatMessage("§3NEU Minion Helper commands: §c((for testing only!)");
+ Utils.addChatMessage("§6/neudevtest minion clear §7Clears the internal minion data");
+ Utils.addChatMessage("§6/neudevtest minion resetrepo §7Manually loading the data from repo");
+ Utils.addChatMessage("§6/neudevtest minion resetapi §7Manually loading the data from api");
+ Utils.addChatMessage("");
+ }
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/MinionHelperOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/MinionHelperOverlay.java
index 65e57079..9ca7c107 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/MinionHelperOverlay.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/MinionHelperOverlay.java
@@ -60,8 +60,8 @@ public class MinionHelperOverlay {
private final MinionHelperManager manager = MinionHelperManager.getInstance();
private Minion lastHovered = null;
- private LinkedHashMap<String, RenderableObject> cacheShift = null;
- private LinkedHashMap<String, RenderableObject> cacheNoShift = null;
+ private LinkedHashMap<String, RenderableObject> cacheRenderMapShift = null;
+ private LinkedHashMap<String, RenderableObject> cacheRenderMapNoShift = null;
public static MinionHelperOverlay getInstance() {
if (instance == null) {
@@ -72,8 +72,12 @@ public class MinionHelperOverlay {
@SubscribeEvent
public void onGuiOpen(GuiOpenEvent event) {
- cacheShift = null;
- cacheNoShift = null;
+ resetCache();
+ }
+
+ public void resetCache() {
+ cacheRenderMapShift = null;
+ cacheRenderMapNoShift = null;
}
public static final ResourceLocation auctionProfitImage =
@@ -298,9 +302,9 @@ public class MinionHelperOverlay {
private LinkedHashMap<String, RenderableObject> getRenderMap() {
boolean shift = Keyboard.isKeyDown(Keyboard.KEY_LSHIFT);
if (!shift) {
- if (cacheNoShift != null) return cacheNoShift;
+ if (cacheRenderMapNoShift != null) return cacheRenderMapNoShift;
} else {
- if (cacheShift != null) return cacheShift;
+ if (cacheRenderMapShift != null) return cacheRenderMapShift;
}
Map<Minion, Long> prices = getMissing(shift);
@@ -341,9 +345,9 @@ public class MinionHelperOverlay {
}
if (shift) {
- cacheShift = renderMap;
+ cacheRenderMapShift = renderMap;
} else {
- cacheNoShift = renderMap;
+ cacheRenderMapNoShift = renderMap;
}
return renderMap;
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/loaders/MinionHelperApiLoader.java b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/loaders/MinionHelperApiLoader.java
index c17d4883..3f1ec62c 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/loaders/MinionHelperApiLoader.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/loaders/MinionHelperApiLoader.java
@@ -19,7 +19,6 @@
package io.github.moulberry.notenoughupdates.miscgui.minionhelper.loaders;
-import com.google.common.collect.Lists;
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
@@ -29,7 +28,6 @@ import io.github.moulberry.notenoughupdates.miscgui.minionhelper.ApiData;
import io.github.moulberry.notenoughupdates.miscgui.minionhelper.MinionHelperManager;
import io.github.moulberry.notenoughupdates.profileviewer.ProfileViewer;
import io.github.moulberry.notenoughupdates.util.Constants;
-import io.github.moulberry.notenoughupdates.util.NotificationHandler;
import io.github.moulberry.notenoughupdates.util.SBInfo;
import io.github.moulberry.notenoughupdates.util.Utils;
import net.minecraft.client.Minecraft;
@@ -194,4 +192,8 @@ public class MinionHelperApiLoader {
));
manager.reloadRequirements();
}
+
+ public void setDirty() {
+ this.dirty = true;
+ }
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/loaders/MinionHelperInventoryLoader.java b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/loaders/MinionHelperInventoryLoader.java
index 3f694f82..e4f6aace 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/loaders/MinionHelperInventoryLoader.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/loaders/MinionHelperInventoryLoader.java
@@ -23,7 +23,9 @@ import io.github.moulberry.notenoughupdates.NotEnoughUpdates;
import io.github.moulberry.notenoughupdates.core.util.StringUtils;
import io.github.moulberry.notenoughupdates.miscgui.minionhelper.Minion;
import io.github.moulberry.notenoughupdates.miscgui.minionhelper.MinionHelperManager;
+import io.github.moulberry.notenoughupdates.miscgui.minionhelper.MinionHelperOverlay;
import io.github.moulberry.notenoughupdates.util.ItemUtils;
+import io.github.moulberry.notenoughupdates.util.Utils;
import net.minecraft.client.Minecraft;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.ContainerChest;
@@ -82,6 +84,7 @@ public class MinionHelperInventoryLoader {
if (!shouldLoad) return;
+ int crafted = 0;
for (Slot slot : openContainer.inventorySlots) {
if (!slot.getHasStack()) continue;
ItemStack stack = slot.getStack();
@@ -100,10 +103,16 @@ public class MinionHelperInventoryLoader {
}
if (line.contains("§a")) {
Minion minion = manager.getMinionByName(displayName, index);
- minion.setCrafted(true);
+ if (!minion.isCrafted()) {
+ minion.setCrafted(true);
+ crafted++;
+ }
}
}
}
+ if (crafted > 0) {
+ MinionHelperOverlay.getInstance().resetCache();
+ }
}
}
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/loaders/MinionHelperRepoLoader.java b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/loaders/MinionHelperRepoLoader.java
index 8873aca2..868fdaad 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/loaders/MinionHelperRepoLoader.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/loaders/MinionHelperRepoLoader.java
@@ -365,4 +365,8 @@ public class MinionHelperRepoLoader {
displayNameCache.put(internalName, displayName);
return displayName;
}
+
+ public void setDirty() {
+ this.dirty = true;
+ }
}