Skip to content

Commit 9bd7be4

Browse files
feat: Change All to Same Color Lock mode
1 parent 6039b01 commit 9bd7be4

File tree

3 files changed

+29
-5
lines changed

3 files changed

+29
-5
lines changed

src/main/kotlin/gg/skytils/skytilsmod/core/Config.kt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1403,6 +1403,16 @@ object Config : Vigilant(
14031403
)
14041404
var changeToSameColorMode = 0
14051405

1406+
@Property(
1407+
type = PropertyType.SWITCH, name = "Change All to Same Color Solver Lock",
1408+
description = "Locks the first selected target color in place.",
1409+
category = "Dungeons", subcategory = "Terminal Solvers",
1410+
i18nName = "skytils.config.dungeons.terminal_solvers.change_all_to_same_color_solver_lock",
1411+
i18nCategory = "skytils.config.dungeons",
1412+
i18nSubcategory = "skytils.config.dungeons.terminal_solvers"
1413+
)
1414+
var changeToSameColorLock = false
1415+
14061416
@Property(
14071417
type = PropertyType.SWITCH, name = "Click in Order Solver",
14081418
description = "Shows the items to click on the Click in Order terminal.",
@@ -4448,6 +4458,7 @@ object Config : Vigilant(
44484458
addDependency("clickInOrderSecond", "clickInOrderTerminalSolver")
44494459
addDependency("clickInOrderThird", "clickInOrderTerminalSolver")
44504460
addDependency("changeToSameColorMode", "changeAllSameColorTerminalSolver")
4461+
addDependency("changeToSameColorLock", "changeAllSameColorTerminalSolver")
44514462
addDependency("predictAlignmentClicks", "alignmentTerminalSolver")
44524463
addDependency("predictSimonClicks", "simonSaysSolver")
44534464

src/main/kotlin/gg/skytils/skytilsmod/features/impl/dungeons/solvers/terminals/ChangeAllToSameColorSolver.kt

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,11 @@ import gg.skytils.skytilsmod.utils.Utils
2424
import gg.skytils.skytilsmod.utils.graphics.ScreenRenderer
2525
import gg.skytils.skytilsmod.utils.graphics.SmartFontRenderer
2626
import gg.skytils.skytilsmod.utils.graphics.colors.CommonColors
27+
import net.minecraft.client.gui.inventory.GuiContainer
2728
import net.minecraft.client.renderer.GlStateManager
2829
import net.minecraft.inventory.ContainerChest
2930
import net.minecraft.item.EnumDyeColor
31+
import net.minecraftforge.client.event.GuiOpenEvent
3032
import net.minecraftforge.event.entity.player.ItemTooltipEvent
3133
import net.minecraftforge.fml.common.eventhandler.EventPriority
3234
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
@@ -43,19 +45,29 @@ object ChangeAllToSameColorSolver {
4345
c.metadata to i
4446
}
4547
private var mostCommon = EnumDyeColor.RED.metadata
48+
private var isLocked = false
49+
50+
@SubscribeEvent
51+
fun onWindowClose(event: GuiOpenEvent) {
52+
if (event.gui as? GuiContainer == null) isLocked = false
53+
}
4654

4755
@SubscribeEvent
4856
fun onForegroundEvent(event: GuiContainerEvent.ForegroundDrawnEvent) {
4957
if (!Utils.inDungeons || !Skytils.config.changeAllSameColorTerminalSolver || event.container !is ContainerChest || event.chestName != "Change all to same color!") return
5058
val grid = event.container.inventorySlots.filter {
5159
it.inventory == event.container.lowerChestInventory && it.stack?.displayName?.startsWith("§a") == true
5260
}
53-
val counts = ordering.keys.associateWith { c -> grid.count { it.stack?.metadata == c } }
54-
val currentPath = counts[mostCommon]!!
55-
val (candidate, maxCount) = counts.maxBy { it.value }
5661

57-
if (maxCount > currentPath) {
58-
mostCommon = candidate
62+
if (!Skytils.config.changeToSameColorLock || !isLocked) {
63+
val counts = ordering.keys.associateWith { c -> grid.count { it.stack?.metadata == c } }
64+
val currentPath = counts[mostCommon]!!
65+
val (candidate, maxCount) = counts.maxBy { it.value }
66+
67+
if (maxCount > currentPath) {
68+
mostCommon = candidate
69+
}
70+
isLocked = true
5971
}
6072

6173
val targetIndex = ordering[mostCommon]!!

src/main/resources/assets/skytils/lang/en_US.lang

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ skytils.config.dungeons.terminal_solvers.block_incorrect_terminal_clicks=Block I
130130
skytils.config.dungeons.terminal_solvers.middle_click_on_terminals=Middle Click on Terminals
131131
skytils.config.dungeons.terminal_solvers.change_all_to_same_color_solver=Change All to Same Color Solver
132132
skytils.config.dungeons.terminal_solvers.change_all_to_same_color_solver_mode=Change All to Same Color Solver Mode
133+
skytils.config.dungeons.terminal_solvers.change_all_to_same_color_solver_lock=Change All to Same Color Lock
133134
skytils.config.dungeons.terminal_solvers.click_in_order_solver=Click in Order Solver
134135
skytils.config.dungeons.terminal_solvers.click_in_order_first_color=Click in Order First Color
135136
skytils.config.dungeons.terminal_solvers.click_in_order_second_color=Click in Order Second Color

0 commit comments

Comments
 (0)