1
- package settingdust.modsets
1
+ package settingdust.modsets.game
2
2
3
3
import dev.isxander.yacl3.api.Binding
4
4
import dev.isxander.yacl3.api.Option
@@ -13,7 +13,9 @@ import kotlinx.serialization.Serializable
13
13
import net.minecraft.network.chat.Component
14
14
import net.minecraft.network.chat.HoverEvent
15
15
import net.minecraft.network.chat.Style
16
- import settingdust.modsets.Rules.getOrThrow
16
+ import settingdust.modsets.ModSets
17
+ import settingdust.modsets.ModSetsConfig
18
+ import settingdust.modsets.game.Rules.getOrThrow
17
19
18
20
interface Described {
19
21
val text: Component
@@ -72,15 +74,15 @@ object LabelRule : OptionRule<Component> {
72
74
73
75
private val String .booleanBinding: Binding <Boolean >
74
76
get() {
75
- val mods = ModSets .rules .modSets.getOrThrow(this ).mods.toSet()
77
+ val mods = Rules .modSets.getOrThrow(this ).mods.toSet()
76
78
return Binding .generic(
77
79
true ,
78
- { mods.any { it !in ModSets .config .disabledMods } },
80
+ { mods.any { it !in ModSetsConfig .disabledMods } },
79
81
{
80
82
if (it) {
81
- ModSets .config .disabledMods.removeAll(mods)
83
+ ModSetsConfig .disabledMods.removeAll(mods)
82
84
} else {
83
- ModSets .config .disabledMods.addAll(mods)
85
+ ModSetsConfig .disabledMods.addAll(mods)
84
86
}
85
87
},
86
88
)
@@ -97,7 +99,7 @@ data class BooleanRule(val mod: String) : OptionRule<Boolean> {
97
99
.apply {
98
100
(
99
101
rule.description
100
- ? : ModSets .rules .modSets[mod]?.description
102
+ ? : Rules .modSets[mod]?.description
101
103
)?.let { description(OptionDescription .of(it)) }
102
104
}
103
105
.instant(true )
@@ -122,7 +124,7 @@ data class CyclingRule(val mods: List<String>) : OptionRule<String> {
122
124
CyclingListControllerBuilder .create(it)
123
125
.values(mods)
124
126
.valueFormatter { mod ->
125
- val modSet = ModSets .rules .modSets.getOrThrow(mod)
127
+ val modSet = Rules .modSets.getOrThrow(mod)
126
128
modSet.text.copy()
127
129
.withStyle(
128
130
Style .EMPTY .withHoverEvent(
@@ -142,31 +144,31 @@ data class CyclingRule(val mods: List<String>) : OptionRule<String> {
142
144
Binding .generic(
143
145
firstMod,
144
146
{
145
- val modSets = ModSets .rules .modSets
147
+ val modSets = Rules .modSets
146
148
val enabledModSet = mods.asSequence()
147
149
.filter { modSet ->
148
150
val mods = modSets.getOrThrow(modSet).mods
149
- mods.isNotEmpty() && mods.none { it in ModSets .config .disabledMods }
151
+ mods.isNotEmpty() && mods.none { it in ModSetsConfig .disabledMods }
150
152
}
151
153
.toList()
152
154
if (enabledModSet.size > 1 ) {
153
155
ModSets .logger.warn(" More than one mod is enabled in cycling list: " + enabledModSet.joinToString() + " . Will take the first and disable the others" )
154
- ModSets .config .disabledMods.addAll(
156
+ ModSetsConfig .disabledMods.addAll(
155
157
enabledModSet.drop(1 ).flatMap { modSets.getOrThrow(it).mods },
156
158
)
157
- ModSets .config .disabledMods.removeAll(modSets.getOrThrow(enabledModSet.first()).mods.toSet())
159
+ ModSetsConfig .disabledMods.removeAll(modSets.getOrThrow(enabledModSet.first()).mods.toSet())
158
160
return @generic enabledModSet.first()
159
161
}
160
162
val currentSelected =
161
163
enabledModSet.singleOrNull() ? : mods.firstOrNull { modSets.getOrThrow(it).mods.isEmpty() }
162
164
? : firstMod
163
165
164
- ModSets .config .disabledMods.removeAll(modSets.getOrThrow(currentSelected).mods.toSet())
166
+ ModSetsConfig .disabledMods.removeAll(modSets.getOrThrow(currentSelected).mods.toSet())
165
167
return @generic currentSelected
166
168
},
167
169
) { value: String ->
168
- ModSets .config. disabledMods.addAll(mods.flatMap { ModSets .rules .modSets.getOrThrow(it).mods })
169
- ModSets .config. disabledMods.removeAll(ModSets .rules .modSets.getOrThrow(value).mods.toSet())
170
+ ModSetsConfig . disabledMods.addAll(mods.flatMap { Rules .modSets.getOrThrow(it).mods })
171
+ ModSetsConfig . disabledMods.removeAll(Rules .modSets.getOrThrow(value).mods.toSet())
170
172
},
171
173
).build()
172
174
}
@@ -185,7 +187,7 @@ data class ModsGroupRule(val mods: List<String>, val collapsed: Boolean = true)
185
187
val group = OptionGroup .createBuilder().name(rule.text)
186
188
rule.description?.let { group.description(OptionDescription .of(it)) }
187
189
for (mod in mods) {
188
- val modSet = ModSets .rules .modSets.getOrThrow(mod)
190
+ val modSet = Rules .modSets.getOrThrow(mod)
189
191
val option = Option .createBuilder<Boolean >().name(modSet.text)
190
192
modSet.description?.let { option.description(OptionDescription .of(it)) }
191
193
group.option(
0 commit comments