aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/de/hysky/skyblocker/utils/container/ContainerSolver.java
diff options
context:
space:
mode:
authorRime <81419447+Emirlol@users.noreply.github.com>2024-06-21 07:43:33 +0300
committerKevinthegreat <92656833+kevinthegreat1@users.noreply.github.com>2024-07-22 14:22:55 +0800
commit99dd2eb4e024c6b5d6355eef342af63649d9fb08 (patch)
tree597e659332f4f050460baeee314742bddcc423eb /src/main/java/de/hysky/skyblocker/utils/container/ContainerSolver.java
parent8f540ffc0f2e6dc90f8c9a1ac249ff9185243d3c (diff)
downloadSkyblocker-99dd2eb4e024c6b5d6355eef342af63649d9fb08.tar.gz
Skyblocker-99dd2eb4e024c6b5d6355eef342af63649d9fb08.tar.bz2
Skyblocker-99dd2eb4e024c6b5d6355eef342af63649d9fb08.zip
Rename AbstractContainerMatcher and its extending interfaces to remove the `Abstract` prefix and rename simple implementations with a `Simple` prefix
Diffstat (limited to 'src/main/java/de/hysky/skyblocker/utils/container/ContainerSolver.java')
-rw-r--r--src/main/java/de/hysky/skyblocker/utils/container/ContainerSolver.java68
1 files changed, 33 insertions, 35 deletions
diff --git a/src/main/java/de/hysky/skyblocker/utils/container/ContainerSolver.java b/src/main/java/de/hysky/skyblocker/utils/container/ContainerSolver.java
index 6d3240ea..f3cb400e 100644
--- a/src/main/java/de/hysky/skyblocker/utils/container/ContainerSolver.java
+++ b/src/main/java/de/hysky/skyblocker/utils/container/ContainerSolver.java
@@ -1,38 +1,36 @@
package de.hysky.skyblocker.utils.container;
-import org.intellij.lang.annotations.Language;
-import org.jetbrains.annotations.NotNull;
-
-import java.util.regex.Pattern;
-
-/**
- * Simple implementation of a container solver. Extend this class to add a new gui solver,
- * like terminal solvers or experiment solvers and add it to {@link ContainerSolverManager#solvers}.
- */
-public abstract class ContainerSolver extends RegexContainerMatcher implements AbstractContainerSolver {
- /**
- * Utility constructor that will compile the given string into a pattern.
- *
- * @see #ContainerSolver(Pattern)
- */
- protected ContainerSolver(@NotNull @Language("RegExp") String titlePattern) {
- super(titlePattern);
- }
-
- /**
- * Creates a ContainerSolver that will be applied to screens with titles that match the given pattern.
- *
- * @param titlePattern The pattern to match the screen title against.
- */
- protected ContainerSolver(@NotNull Pattern titlePattern) {
- super(titlePattern);
- }
-
- // A container solver that applies to every screen doesn't make sense,
- // so we don't provide a constructor for that and force getTitlePattern to be @NotNull
- @Override
- public @NotNull Pattern getTitlePattern() {
- assert super.getTitlePattern() != null;
- return super.getTitlePattern();
- }
+import de.hysky.skyblocker.SkyblockerMod;
+import de.hysky.skyblocker.utils.render.gui.ColorHighlight;
+import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
+import net.minecraft.client.gui.screen.ingame.GenericContainerScreen;
+import net.minecraft.item.ItemStack;
+
+import java.util.List;
+
+public interface ContainerSolver extends ContainerMatcher {
+ List<ColorHighlight> getColors(Int2ObjectMap<ItemStack> slots);
+
+ default void start(GenericContainerScreen screen) {}
+
+ default void reset() {}
+
+ default boolean onClickSlot(int slot, ItemStack stack, int screenId) {
+ return false;
+ }
+
+ static void markHighlightsDirty() {
+ SkyblockerMod.getInstance().containerSolverManager.markDirty();
+ }
+
+ static void trimEdges(Int2ObjectMap<ItemStack> slots, int rows) {
+ for (int i = 0; i < rows; i++) {
+ slots.remove(9 * i);
+ slots.remove(9 * i + 8);
+ }
+ for (int i = 1; i < 8; i++) {
+ slots.remove(i);
+ slots.remove((rows - 1) * 9 + i);
+ }
+ }
}