aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/me/Danker/features/puzzlesolvers/SelectAllColourSolver.java
diff options
context:
space:
mode:
authorbowser0000 <bowser0000@gmail.com>2021-02-27 18:25:51 -0500
committerbowser0000 <bowser0000@gmail.com>2021-02-27 18:25:51 -0500
commitad53066846fb168255499a332a1ad4bca39f5935 (patch)
tree9482f461f3f12c64bcb8e6572f43bc480d817d85 /src/main/java/me/Danker/features/puzzlesolvers/SelectAllColourSolver.java
parenta2f85ba6b9d80be3026aa906783a21c0b05cb681 (diff)
downloadSkyblockMod-ad53066846fb168255499a332a1ad4bca39f5935.tar.gz
SkyblockMod-ad53066846fb168255499a332a1ad4bca39f5935.tar.bz2
SkyblockMod-ad53066846fb168255499a332a1ad4bca39f5935.zip
Move features into their own files
Diffstat (limited to 'src/main/java/me/Danker/features/puzzlesolvers/SelectAllColourSolver.java')
-rw-r--r--src/main/java/me/Danker/features/puzzlesolvers/SelectAllColourSolver.java59
1 files changed, 59 insertions, 0 deletions
diff --git a/src/main/java/me/Danker/features/puzzlesolvers/SelectAllColourSolver.java b/src/main/java/me/Danker/features/puzzlesolvers/SelectAllColourSolver.java
new file mode 100644
index 0000000..cce89d2
--- /dev/null
+++ b/src/main/java/me/Danker/features/puzzlesolvers/SelectAllColourSolver.java
@@ -0,0 +1,59 @@
+package me.Danker.features.puzzlesolvers;
+
+import me.Danker.commands.ToggleCommand;
+import me.Danker.events.GuiChestBackgroundDrawnEvent;
+import me.Danker.utils.Utils;
+import net.minecraft.client.Minecraft;
+import net.minecraft.inventory.Slot;
+import net.minecraft.item.ItemStack;
+import net.minecraft.util.StringUtils;
+import net.minecraftforge.client.event.GuiOpenEvent;
+import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+public class SelectAllColourSolver {
+
+ static Pattern selectAllTerminalPattern = Pattern.compile("[A-Z]{2,}");
+ static String terminalColorNeeded;
+
+ @SubscribeEvent
+ public void onGuiRender(GuiChestBackgroundDrawnEvent event) {
+ String displayName = event.displayName;
+ if (ToggleCommand.selectAllToggled && Utils.inDungeons && displayName.startsWith("Select all the")) {
+ String colour;
+ List<String> colourParts = new ArrayList<>();
+ Matcher colourMatcher = selectAllTerminalPattern.matcher(displayName);
+ while (colourMatcher.find()) {
+ colourParts.add(colourMatcher.group());
+ }
+ colour = String.join(" ", colourParts);
+ terminalColorNeeded = colour;
+
+ for (Slot slot : event.slots) {
+ if (slot.inventory == Minecraft.getMinecraft().thePlayer.inventory) continue;
+ ItemStack item = slot.getStack();
+ if (item == null) continue;
+ if (item.isItemEnchanted()) continue;
+ String itemName = StringUtils.stripControlCodes(item.getDisplayName()).toUpperCase();
+ if (itemName.contains(terminalColorNeeded) ||
+ (terminalColorNeeded.equals("SILVER") && itemName.contains("LIGHT GRAY")) ||
+ (terminalColorNeeded.equals("WHITE") && (itemName.equals("WOOL") || itemName.equals("BONE MEAL"))) ||
+ (terminalColorNeeded.equals("BLACK") && itemName.equals("INK SACK")) ||
+ (terminalColorNeeded.equals("BLUE") && itemName.equals("LAPIS LAZULI")) ||
+ (terminalColorNeeded.equals("BROWN") && itemName.equals("COCOA BEANS"))) {
+ Utils.drawOnSlot(event.chestSize, slot.xDisplayPosition, slot.yDisplayPosition, 0xBF40FF40);
+ }
+ }
+ }
+ }
+
+ @SubscribeEvent
+ public void onGuiOpen(GuiOpenEvent event) {
+ terminalColorNeeded = null;
+ }
+
+}