-
Notifications
You must be signed in to change notification settings - Fork 35
/
SHConfig.java
357 lines (303 loc) · 17.1 KB
/
SHConfig.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
package net.silentchaos512.scalinghealth.config;
import com.google.common.collect.ImmutableList;
import net.minecraftforge.common.ForgeConfigSpec;
import net.minecraftforge.common.ForgeConfigSpec.*;
import net.minecraftforge.fml.ModLoadingContext;
import net.minecraftforge.fml.config.ModConfig;
import net.silentchaos512.scalinghealth.client.gui.difficulty.DifficultyMeterShow;
import net.silentchaos512.scalinghealth.client.gui.health.AbsorptionIconStyle;
import net.silentchaos512.scalinghealth.client.gui.health.HealthTextColor;
import net.silentchaos512.scalinghealth.client.gui.health.HealthTextStyle;
import net.silentchaos512.scalinghealth.client.gui.health.HeartIconStyle;
import net.silentchaos512.utils.Anchor;
import net.silentchaos512.utils.Color;
import org.apache.commons.lang3.tuple.Pair;
import java.util.function.Supplier;
public class SHConfig {
public static class Client {
// Debug
public final EnumValue<Anchor> debugOverlayAnchor;
public final DoubleValue debugOverlayTextScale;
// Health Icons
public final EnumValue<HeartIconStyle> heartIconStyle;
public final ColorList heartColors;
public final BooleanValue lastHeartOutline;
public final ConfigValue<Integer> lastHeartOutlineColor;
public final BooleanValue heartColorLooping;
// Heart Tanks
public final BooleanValue heartTanks;
// Health Text
public final EnumValue<HealthTextStyle> healthTextStyle;
public final DoubleValue healthTextScale;
public final IntValue healthTextOffsetX;
public final IntValue healthTextOffsetY;
public final EnumValue<HealthTextColor> healthTextColorStyle;
public final ConfigValue<Integer> healthTextFullColor;
public final ConfigValue<Integer> healthTextEmptyColor;
// Absorption Icons
public final EnumValue<AbsorptionIconStyle> absorptionIconStyle;
public final ColorList absorptionHeartColors;
// Absorption Text
public final EnumValue<HealthTextStyle> absorptionTextStyle;
public final IntValue absorptionTextOffsetX;
public final IntValue absorptionTextOffsetY;
public final ConfigValue<Integer> absorptionTextColor;
//Blights
public final BooleanValue displayBlightEffect;
// Difficulty
public final BooleanValue warnWhenSleeping;
// Difficulty Meter
public final EnumValue<DifficultyMeterShow> difficultyMeterShow;
public final DoubleValue difficultyMeterShowTime;
public final EnumValue<Anchor> difficultyMeterAnchor;
public final IntValue difficultyMeterOffsetX;
public final IntValue difficultyMeterOffsetY;
public final DoubleValue difficultyMeterTextScale;
public Client(Builder builder) {
debugOverlayAnchor = builder
.comment("Position of debug overlay")
.defineEnum("debug.overlay.anchor", Anchor.TOP_RIGHT);
debugOverlayTextScale = builder
.comment("Overlay text size, where 1 is standard-sized text")
.defineInRange("debug.overlay.textScale",0.75, 0.01, Double.MAX_VALUE);
//region Health Hearts
heartIconStyle = builder
.comment("Heart style",
"REPLACE_ALL: All rows replaced with Scaling Health style hearts",
"REPLACE_AFTER_FIRST_ROW: Leave the first row vanilla style, Scaling Health style for additional rows",
"VANILLA: Do not change heart rendering (use this if you want another mod to handle heart rendering)")
.defineEnum("hearts.health.icons.style", HeartIconStyle.REPLACE_ALL);
heartColors = new ColorList(builder, "hearts.health.icons.colors",
"The color of each row of hearts. If the player has more rows than colors, it starts over from the beginning.",
0xBF0000, // 0 red
0xE66000, // 25 orange-red
0xE69900, // 40 orange
0xE6D300, // 55 yellow
0x99E600, // 80 lime
0x4CE600, // 100 green
0x00E699, // 160 teal
0x00E6E6, // 180 aqua
0x0099E6, // 200 sky blue
0x0000E6, // 240 blue
0x9900E6, // 280 dark purple
0xD580FF, // 280 light purple
0x8C8C8C, // 0 gray
0xE6E6E6 // 0 white
);
lastHeartOutline = builder
.comment("The player's highest heart will get an outline around it.")
.define("hearts.health.icons.lastHeartOutline", true);
lastHeartOutlineColor = builder
.comment("The color of the last heart outline, if enabled (see lastHeartOutline)")
.define("hearts.health.icons.lastHeartOutlineColor", Color.VALUE_WHITE, SHConfig::validateColor);
heartColorLooping = builder
.comment("If true, heart colors will 'loop around' to the first color after going through the",
"entire list. Set false to have every row after the last have the same color.")
.define("hearts.health.icons.colorLooping",true);
// Tanks
heartTanks = builder
.comment("Enable heart tanks, the small icons above your hearts which indicate the number of filled health rows")
.define("hearts.health.tanks.enabled", true);
healthTextStyle = builder
.comment("Style of health text")
.defineEnum("hearts.health.text.style", HealthTextStyle.ROWS);
healthTextScale = builder
.comment("Health text scale, relative to its normal size (which varies by style)")
.defineInRange("hearts.health.text.scale", 1.0, 0.01, Double.MAX_VALUE);
healthTextOffsetX = builder
.comment("Fine-tune text position")
.defineInRange("hearts.health.text.offsetX", 0, Integer.MIN_VALUE, Integer.MAX_VALUE);
healthTextOffsetY = builder
.comment("Fine-tune text position")
.defineInRange("hearts.health.text.offsetY", 0, Integer.MIN_VALUE, Integer.MAX_VALUE);
healthTextColorStyle = builder
.comment("Health text color style.",
"TRANSITION: Gradually goes from full color to empty color as health is lost",
"PSYCHEDELIC: Taste the rainbow!",
"SOLID: Just stays at full color regardless of health")
.defineEnum("hearts.health.text.color.style", HealthTextColor.TRANSITION);
healthTextFullColor = builder
.comment("Color when health is full or style is SOLID")
.define("hearts.health.text.color.full", 0x4CFF4C, SHConfig::validateColor);
healthTextEmptyColor = builder
.comment("Color when health is empty and style is TRANSITION")
.define("hearts.health.text.color.empty", 0xFF4C4C, SHConfig::validateColor);
//endregion
//region Absorption Hearts
absorptionIconStyle = builder
.comment("Style of absorption icons")
.defineEnum("hearts.absorption.icons.style", AbsorptionIconStyle.SHIELD);
absorptionHeartColors = new ColorList(builder, "hearts.absorption.icons.colors",
"The color of each row of absorption hearts. If the player has more rows than colors, it starts over from the beginning.",
0xBF0000, // 0 red
0xE66000, // 25 orange-red
0xE69900, // 40 orange
0xE6D300, // 55 yellow
0x99E600, // 80 lime
0x4CE600, // 100 green
0x00E699, // 160 teal
0x00E6E6, // 180 aqua
0x0099E6, // 200 sky blue
0x0000E6, // 240 blue
0x9900E6, // 280 dark purple
0xD580FF, // 280 light purple
0x8C8C8C, // 0 gray
0xE6E6E6 // 0 white
);
absorptionTextStyle = builder
.comment("Style for absorption text. Because there is no 'max' value, the options are more limited.")
.defineEnum("hearts.absorption.text.style", HealthTextStyle.DISABLED, ImmutableList.of(HealthTextStyle.DISABLED, HealthTextStyle.HEALTH_ONLY, HealthTextStyle.ROWS));
absorptionTextOffsetX = builder
.comment("Fine-tune text position")
.defineInRange("hearts.absorption.text.offsetX", 0, Integer.MIN_VALUE, Integer.MAX_VALUE);
absorptionTextOffsetY = builder
.comment("Fine-tune text position")
.defineInRange("hearts.absorption.text.offsetY", 0, Integer.MIN_VALUE, Integer.MAX_VALUE);
absorptionTextColor = builder
.comment("The color of the absorption text")
.define("hearts.absorption.text.color", Color.VALUE_WHITE, SHConfig::validateColor);
//endregion
//region Difficulty
warnWhenSleeping = builder
.comment("Display a warning to players trying to sleep, to remind them their difficulty may change. Sleeping is still allowed.")
.define("difficulty.warnWhenSleeping", true);
difficultyMeterShow = builder
.comment("When to show the difficulty meter.")
.defineEnum("difficulty.meter.show", DifficultyMeterShow.SOMETIMES);
difficultyMeterShowTime = builder
.comment("Show the difficulty meter for this many seconds (only on SOMETIMES mode)")
.defineInRange("difficulty.meter.showDuration", 8, 0, Double.MAX_VALUE);
difficultyMeterAnchor = builder
.comment("Position of the difficulty meter.")
.defineEnum("difficulty.meter.position.anchor", Anchor.BOTTOM_LEFT);
difficultyMeterOffsetX = builder
.comment("Fine-tune the difficulty meter's position")
.defineInRange("difficulty.meter.position.offsetX",5, Integer.MIN_VALUE, Integer.MAX_VALUE);
difficultyMeterOffsetY = builder
.comment("Fine-tune the difficulty meter's position")
.defineInRange("difficulty.meter.position.offsetY", -30, Integer.MIN_VALUE, Integer.MAX_VALUE);
difficultyMeterTextScale = builder
.comment("Scale of text on the difficulty meter")
.defineInRange("difficulty.meter.text.scale", 0.6, 0, Double.MAX_VALUE);
displayBlightEffect = builder
.comment("whether the purple flame should render on blights or not.",
"This does not change whether the mob is a blight, only hides the effect.")
.define("blights.render", true);
//endregion
}
public void reload() {
this.absorptionHeartColors.recalculate();
this.heartColors.recalculate();
}
}
public static class Server {
public final BooleanValue debugMaster;
public final Supplier<Boolean> debugShowOverlay;
public final Supplier<Boolean> debugLogEntitySpawns;
public final Supplier<Boolean> debugLogScaledDamage;
public final Supplier<Boolean> debugMobPotionEffects;
public final BooleanValue crystalsAddHealth;
public final BooleanValue xpAddHealth;
public final BooleanValue crystalsRegenHealth;
public final BooleanValue crystalsAddPetHealth;
public final BooleanValue crystalsAddDamage;
public final BooleanValue hpCrystalsOreGen;
public final BooleanValue powerCrystalsOreGen;
public final BooleanValue mobDamageIncrease;
public final BooleanValue mobHpIncrease;
public final BooleanValue playerDamageScaling;
public final BooleanValue mobDamageScaling;
public final BooleanValue enableDifficulty;
public final BooleanValue enableBlights;
public Server(Builder builder) {
builder.comment("All SH features can be disabled here. False to disable.")
.push("features");
crystalsAddHealth = builder
.comment("Enable player bonus hp by crystals.")
.define("crystalsAddHealth", true);
xpAddHealth = builder
.comment("Enable player bonus hp by xp.")
.define("xpAddHealth", true);
crystalsRegenHealth = builder
.comment("Enable player regen hp by crystals.")
.define("crystalsRegenHealth", true);
crystalsAddPetHealth = builder
.comment("Enable pet add hp by crystals.")
.define("crystalsAddPetHealth", true);
crystalsAddDamage = builder
.comment("Enable player add damage by crystals.")
.define("crystalsAddDamage", true);
hpCrystalsOreGen = builder
.comment("Enable ore gen of health crystals. Still drops as loot.")
.define("hpCrystalsOreGen", true);
powerCrystalsOreGen = builder
.comment("Enable ore gen of power crystals. Still drops as loot.")
.define("powerCrystalsOreGen", true);
mobHpIncrease = builder
.comment("Mobs will gain bonus health with difficulty.")
.define("mobHpIncrease", true);
mobDamageIncrease = builder
.comment("Mobs will gain bonus damage with difficulty.")
.define("mobDamageIncrease", true);
playerDamageScaling = builder
.comment("Enable player damage scaling.")
.define("playerDamageScaling", true);
mobDamageScaling = builder
.comment("Enable mob damage scaling.")
.define("mobDamageScaling", true);
enableDifficulty = builder
.comment("Enable difficulty system. If disabled, everything will have 0 difficulty.")
.define("enableDifficulty", true);
enableBlights = builder
.comment("Enable blights. If disabled, no blights will spawn.")
.define("enableBlights", true);
builder.pop().comment(
"Debug settings are intended for tuning configs or diagnosing issues.",
"They may decrease performance and should be disabled for normal play."
).push("debug");
debugMaster = builder
.comment("Must be true for other debug settings to apply")
.define("masterSwitch", false);
debugShowOverlay = withMasterCheck(builder
.comment("Show some text in-game about player health, difficulty, and maybe other things.")
.define("showOverlay", true)
);
debugLogEntitySpawns = withMasterCheck(builder
.comment("Log details of entity spawns, including effects of difficulty.",
"This creates a lot of log spam, and will likely lag the game.")
.define("logEntitySpawns", false)
);
debugMobPotionEffects = withMasterCheck(builder
.comment("Logs details of potions effects added to mobs.")
.define("logApplyingMobPotions", false)
);
debugLogScaledDamage = withMasterCheck(builder
.comment("Log details of scaled damage, useful for fine-tuning damage scaling.",
"May create a fair amount of log spam, but shouldn't slow down the game too much.")
.define("logDamageScaling", false)
);
}
private Supplier<Boolean> withMasterCheck(BooleanValue option) {
return () -> debugMaster.get() && option.get();
}
}
private static final ForgeConfigSpec CLIENT_SPEC;
private static final ForgeConfigSpec SERVER_SPEC;
public static final Client CLIENT;
public static final Server SERVER;
static {
Pair<Client, ForgeConfigSpec> pCli = new Builder().configure(Client::new);
CLIENT_SPEC = pCli.getRight();
CLIENT = pCli.getLeft();
Pair<Server, ForgeConfigSpec> pSev = new Builder().configure(Server::new);
SERVER_SPEC = pSev.getRight();
SERVER = pSev.getLeft();
}
public static void register() {
ModLoadingContext.get().registerConfig(ModConfig.Type.CLIENT, CLIENT_SPEC);
ModLoadingContext.get().registerConfig(ModConfig.Type.SERVER, SERVER_SPEC);
}
private static boolean validateColor(Object o) {
return o instanceof Integer && Color.validate(o.toString());
}
}