diff --git a/src/main/java/de/hysky/skyblocker/config/categories/DungeonsCategory.java b/src/main/java/de/hysky/skyblocker/config/categories/DungeonsCategory.java index d44ab49026..53efca21d9 100644 --- a/src/main/java/de/hysky/skyblocker/config/categories/DungeonsCategory.java +++ b/src/main/java/de/hysky/skyblocker/config/categories/DungeonsCategory.java @@ -252,6 +252,13 @@ public static ConfigCategory create(SkyblockerConfig defaults, SkyblockerConfig newValue -> config.dungeons.terminals.solveStartsWith = newValue) .controller(ConfigUtils::createBooleanController) .build()) + .option(Option.createBuilder() + .name(Text.translatable("skyblocker.config.dungeons.terminals.blockIncorrectClicks")) + .binding(defaults.dungeons.terminals.blockIncorrectClicks, + () -> config.dungeons.terminals.blockIncorrectClicks, + newValue -> config.dungeons.terminals.blockIncorrectClicks = newValue) + .controller(ConfigUtils::createBooleanController) + .build()) .build()) // Dungeon Secret Waypoints diff --git a/src/main/java/de/hysky/skyblocker/config/configs/DungeonsConfig.java b/src/main/java/de/hysky/skyblocker/config/configs/DungeonsConfig.java index 2c99dc56f0..09eff9ee35 100644 --- a/src/main/java/de/hysky/skyblocker/config/configs/DungeonsConfig.java +++ b/src/main/java/de/hysky/skyblocker/config/configs/DungeonsConfig.java @@ -127,6 +127,9 @@ public static class Terminals { @SerialEntry public boolean solveStartsWith = true; + + @SerialEntry + public boolean blockIncorrectClicks = false; } public static class SecretWaypoints { diff --git a/src/main/java/de/hysky/skyblocker/mixins/HandledScreenMixin.java b/src/main/java/de/hysky/skyblocker/mixins/HandledScreenMixin.java index 04e6749c7b..dd91314a3e 100644 --- a/src/main/java/de/hysky/skyblocker/mixins/HandledScreenMixin.java +++ b/src/main/java/de/hysky/skyblocker/mixins/HandledScreenMixin.java @@ -216,7 +216,9 @@ protected HandledScreenMixin(Text title) { } if (currentSolver != null) { - SkyblockerMod.getInstance().containerSolverManager.onSlotClick(slotId, stack); + boolean disallowed = SkyblockerMod.getInstance().containerSolverManager.onSlotClick(slotId, stack); + + if (disallowed) ci.cancel(); } // Experiment Solvers diff --git a/src/main/java/de/hysky/skyblocker/skyblock/dungeon/terminal/ColorTerminal.java b/src/main/java/de/hysky/skyblocker/skyblock/dungeon/terminal/ColorTerminal.java index 01673f2355..833e85a30c 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/dungeon/terminal/ColorTerminal.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/dungeon/terminal/ColorTerminal.java @@ -16,7 +16,7 @@ import java.util.*; -public class ColorTerminal extends ContainerSolver { +public class ColorTerminal extends ContainerSolver implements TerminalSolver { private static final Logger LOGGER = LoggerFactory.getLogger(ColorTerminal.class.getName()); private static final Map colorFromName; private DyeColor targetColor; @@ -53,6 +53,14 @@ protected List getColors(String[] groups, Int2ObjectMap(); diff --git a/src/main/java/de/hysky/skyblocker/skyblock/dungeon/terminal/LightsOnTerminal.java b/src/main/java/de/hysky/skyblocker/skyblock/dungeon/terminal/LightsOnTerminal.java new file mode 100644 index 0000000000..67b51c22c6 --- /dev/null +++ b/src/main/java/de/hysky/skyblocker/skyblock/dungeon/terminal/LightsOnTerminal.java @@ -0,0 +1,37 @@ +package de.hysky.skyblocker.skyblock.dungeon.terminal; + +import java.util.List; + +import de.hysky.skyblocker.utils.render.gui.ColorHighlight; +import de.hysky.skyblocker.utils.render.gui.ContainerSolver; +import it.unimi.dsi.fastutil.ints.Int2ObjectMap; +import net.minecraft.item.ItemStack; +import net.minecraft.item.Items; + +/** + * The terminal where you change all the panes that are red to green. + * + * This doesn't solve the terminal because you don't need a solver for it, but rather to simply allow for click blocking. + */ +public class LightsOnTerminal extends ContainerSolver implements TerminalSolver { + private static final List EMPTY = List.of(); + + public LightsOnTerminal() { + super("^Correct all the panes!$"); + } + + @Override + protected boolean isEnabled() { + return shouldBlockIncorrectClicks(); + } + + @Override + protected List getColors(String[] groups, Int2ObjectMap slots) { + return EMPTY; + } + + @Override + protected boolean onClickSlot(int slot, ItemStack stack, int screenId, String[] groups) { + return stack.isOf(Items.LIME_STAINED_GLASS_PANE); + } +} diff --git a/src/main/java/de/hysky/skyblocker/skyblock/dungeon/terminal/OrderTerminal.java b/src/main/java/de/hysky/skyblocker/skyblock/dungeon/terminal/OrderTerminal.java index d8d9a63a5a..e980a13669 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/dungeon/terminal/OrderTerminal.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/dungeon/terminal/OrderTerminal.java @@ -11,7 +11,7 @@ import java.util.Collections; import java.util.List; -public class OrderTerminal extends ContainerSolver { +public class OrderTerminal extends ContainerSolver implements TerminalSolver { private final int PANES_NUM = 14; private int[] orderedSlots; private int currentNum = Integer.MAX_VALUE; @@ -55,4 +55,15 @@ public boolean orderSlots(Int2ObjectMap slots) { currentNum = 0; return true; } + + @Override + protected boolean onClickSlot(int slot, ItemStack stack, int screenId, String[] groups) { + if (stack == null || stack.isEmpty()) return false; + + if (!stack.isOf(Items.RED_STAINED_GLASS_PANE) || stack.getCount() != currentNum + 1) { + return shouldBlockIncorrectClicks(); + } + + return false; + } } \ No newline at end of file diff --git a/src/main/java/de/hysky/skyblocker/skyblock/dungeon/terminal/StartsWithTerminal.java b/src/main/java/de/hysky/skyblocker/skyblock/dungeon/terminal/StartsWithTerminal.java index c4cc8e473b..51a778a529 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/dungeon/terminal/StartsWithTerminal.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/dungeon/terminal/StartsWithTerminal.java @@ -13,7 +13,7 @@ import java.util.List; import java.util.function.Predicate; -public class StartsWithTerminal extends ContainerSolver { +public class StartsWithTerminal extends ContainerSolver implements TerminalSolver { private final Int2ObjectOpenHashMap trackedItemStates = new Int2ObjectOpenHashMap<>(); private int lastKnownScreenId = Integer.MIN_VALUE; @@ -50,9 +50,9 @@ protected List getColors(String[] groups, Int2ObjectMap getColors(String[] groups, Int2ObjectMap slots); - protected void trimEdges(Int2ObjectMap slots, int rows) { + protected final void trimEdges(Int2ObjectMap slots, int rows) { for (int i = 0; i < rows; i++) { slots.remove(9 * i); slots.remove(9 * i + 8); diff --git a/src/main/java/de/hysky/skyblocker/utils/render/gui/ContainerSolverManager.java b/src/main/java/de/hysky/skyblocker/utils/render/gui/ContainerSolverManager.java index b37c57a48a..08fb6a8637 100644 --- a/src/main/java/de/hysky/skyblocker/utils/render/gui/ContainerSolverManager.java +++ b/src/main/java/de/hysky/skyblocker/utils/render/gui/ContainerSolverManager.java @@ -8,6 +8,7 @@ import de.hysky.skyblocker.skyblock.dungeon.CroesusHelper; import de.hysky.skyblocker.skyblock.dungeon.CroesusProfit; import de.hysky.skyblocker.skyblock.dungeon.terminal.ColorTerminal; +import de.hysky.skyblocker.skyblock.dungeon.terminal.LightsOnTerminal; import de.hysky.skyblocker.skyblock.dungeon.terminal.OrderTerminal; import de.hysky.skyblocker.skyblock.dungeon.terminal.StartsWithTerminal; import de.hysky.skyblocker.skyblock.experiment.ChronomatronSolver; @@ -47,6 +48,7 @@ public ContainerSolverManager() { new ColorTerminal(), new OrderTerminal(), new StartsWithTerminal(), + new LightsOnTerminal(), new CroesusHelper(), new CroesusProfit(), new ChronomatronSolver(), @@ -114,10 +116,15 @@ public void markDirty() { highlights = null; } - public void onSlotClick(int slot, ItemStack stack) { + /** + * @return Whether the click should be disallowed. + */ + public boolean onSlotClick(int slot, ItemStack stack) { if (currentSolver != null) { - currentSolver.onClickSlot(slot, stack, screenId, groups); + return currentSolver.onClickSlot(slot, stack, screenId, groups); } + + return false; } public void onDraw(DrawContext context, List slots) { diff --git a/src/main/resources/assets/skyblocker/lang/en_us.json b/src/main/resources/assets/skyblocker/lang/en_us.json index 2549f80eb6..45390c360c 100644 --- a/src/main/resources/assets/skyblocker/lang/en_us.json +++ b/src/main/resources/assets/skyblocker/lang/en_us.json @@ -168,6 +168,7 @@ "skyblocker.config.dungeons.starredMobGlow.@Tooltip": "Applies the glowing effect to starred mobs that are visible.\n\nWARNING: This feature is experimental and you may encounter issues with it.", "skyblocker.config.dungeons.terminals": "Terminal Solvers (F7/M7)", + "skyblocker.config.dungeons.terminals.blockIncorrectClicks": "Block Incorrect Clicks", "skyblocker.config.dungeons.terminals.solveColor": "Solve Select Colored", "skyblocker.config.dungeons.terminals.solveOrder": "Solve Click In Order", "skyblocker.config.dungeons.terminals.solveStartsWith": "Solve Starts With",