001/*
002 * This file is part of Baritone.
003 *
004 * Baritone is free software: you can redistribute it and/or modify
005 * it under the terms of the GNU Lesser General Public License as published by
006 * the Free Software Foundation, either version 3 of the License, or
007 * (at your option) any later version.
008 *
009 * Baritone is distributed in the hope that it will be useful,
010 * but WITHOUT ANY WARRANTY; without even the implied warranty of
011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
012 * GNU Lesser General Public License for more details.
013 *
014 * You should have received a copy of the GNU Lesser General Public License
015 * along with Baritone.  If not, see <https://www.gnu.org/licenses/>.
016 */
017
018package baritone.api;
019
020import baritone.api.utils.NotificationHelper;
021import baritone.api.utils.SettingsUtil;
022import baritone.api.utils.TypeUtils;
023import baritone.api.utils.gui.BaritoneToast;
024import net.minecraft.block.Block;
025import net.minecraft.client.Minecraft;
026import net.minecraft.init.Blocks;
027import net.minecraft.item.Item;
028import net.minecraft.util.math.Vec3i;
029import net.minecraft.util.text.ITextComponent;
030
031import java.awt.*;
032import java.lang.reflect.Field;
033import java.lang.reflect.ParameterizedType;
034import java.lang.reflect.Type;
035import java.util.List;
036import java.util.*;
037import java.util.function.Consumer;
038import java.util.function.BiConsumer;
039
040/**
041 * Baritone's settings. Settings apply to all Baritone instances.
042 *
043 * @author leijurv
044 */
045public final class Settings {
046
047    /**
048     * Allow Baritone to break blocks
049     */
050    public final Setting<Boolean> allowBreak = new Setting<>(true);
051
052    /**
053     * Allow Baritone to sprint
054     */
055    public final Setting<Boolean> allowSprint = new Setting<>(true);
056
057    /**
058     * Allow Baritone to place blocks
059     */
060    public final Setting<Boolean> allowPlace = new Setting<>(true);
061
062    /**
063     * Allow Baritone to move items in your inventory to your hotbar
064     */
065    public final Setting<Boolean> allowInventory = new Setting<>(false);
066
067    /**
068     * Disable baritone's auto-tool at runtime, but still assume that another mod will provide auto tool functionality
069     * <p>
070     * Specifically, path calculation will still assume that an auto tool will run at execution time, even though
071     * Baritone itself will not do that.
072     */
073    public final Setting<Boolean> assumeExternalAutoTool = new Setting<>(false);
074
075    /**
076     * Automatically select the best available tool
077     */
078    public final Setting<Boolean> autoTool = new Setting<>(true);
079
080    /**
081     * It doesn't actually take twenty ticks to place a block, this cost is so high
082     * because we want to generally conserve blocks which might be limited.
083     * <p>
084     * Decrease to make Baritone more often consider paths that would require placing blocks
085     */
086    public final Setting<Double> blockPlacementPenalty = new Setting<>(20D);
087
088    /**
089     * This is just a tiebreaker to make it less likely to break blocks if it can avoid it.
090     * For example, fire has a break cost of 0, this makes it nonzero, so all else being equal
091     * it will take an otherwise equivalent route that doesn't require it to put out fire.
092     */
093    public final Setting<Double> blockBreakAdditionalPenalty = new Setting<>(2D);
094
095    /**
096     * Additional penalty for hitting the space bar (ascend, pillar, or parkour) because it uses hunger
097     */
098    public final Setting<Double> jumpPenalty = new Setting<>(2D);
099
100    /**
101     * Walking on water uses up hunger really quick, so penalize it
102     */
103    public final Setting<Double> walkOnWaterOnePenalty = new Setting<>(3D);
104
105    /**
106     * Allow Baritone to fall arbitrary distances and place a water bucket beneath it.
107     * Reliability: questionable.
108     */
109    public final Setting<Boolean> allowWaterBucketFall = new Setting<>(true);
110
111    /**
112     * Allow Baritone to assume it can walk on still water just like any other block.
113     * This functionality is assumed to be provided by a separate library that might have imported Baritone.
114     */
115    public final Setting<Boolean> assumeWalkOnWater = new Setting<>(false);
116
117    /**
118     * If you have Fire Resistance and Jesus then I guess you could turn this on lol
119     */
120    public final Setting<Boolean> assumeWalkOnLava = new Setting<>(false);
121
122    /**
123     * Assume step functionality; don't jump on an Ascend.
124     */
125    public final Setting<Boolean> assumeStep = new Setting<>(false);
126
127    /**
128     * Assume safe walk functionality; don't sneak on a backplace traverse.
129     * <p>
130     * Warning: if you do something janky like sneak-backplace from an ender chest, if this is true
131     * it won't sneak right click, it'll just right click, which means it'll open the chest instead of placing
132     * against it. That's why this defaults to off.
133     */
134    public final Setting<Boolean> assumeSafeWalk = new Setting<>(false);
135
136    /**
137     * If true, parkour is allowed to make jumps when standing on blocks at the maximum height, so player feet is y=256
138     * <p>
139     * Defaults to false because this fails on constantiam. Please let me know if this is ever disabled. Please.
140     */
141    public final Setting<Boolean> allowJumpAt256 = new Setting<>(false);
142
143    /**
144     * This should be monetized it's so good
145     * <p>
146     * Defaults to true, but only actually takes effect if allowParkour is also true
147     */
148    public final Setting<Boolean> allowParkourAscend = new Setting<>(true);
149
150    /**
151     * Allow descending diagonally
152     * <p>
153     * Safer than allowParkour yet still slightly unsafe, can make contact with unchecked adjacent blocks, so it's unsafe in the nether.
154     * <p>
155     * For a generic "take some risks" mode I'd turn on this one, parkour, and parkour place.
156     */
157    public final Setting<Boolean> allowDiagonalDescend = new Setting<>(false);
158
159    /**
160     * Allow diagonal ascending
161     * <p>
162     * Actually pretty safe, much safer than diagonal descend tbh
163     */
164    public final Setting<Boolean> allowDiagonalAscend = new Setting<>(false);
165
166    /**
167     * Allow mining the block directly beneath its feet
168     * <p>
169     * Turn this off to force it to make more staircases and less shafts
170     */
171    public final Setting<Boolean> allowDownward = new Setting<>(true);
172
173    /**
174     * Blocks that Baritone is allowed to place (as throwaway, for sneak bridging, pillaring, etc.)
175     */
176    public final Setting<List<Item>> acceptableThrowawayItems = new Setting<>(new ArrayList<>(Arrays.asList(
177            Item.getItemFromBlock(Blocks.DIRT),
178            Item.getItemFromBlock(Blocks.COBBLESTONE),
179            Item.getItemFromBlock(Blocks.NETHERRACK),
180            Item.getItemFromBlock(Blocks.STONE)
181    )));
182
183    /**
184     * Blocks that Baritone will attempt to avoid (Used in avoidance)
185     */
186    public final Setting<List<Block>> blocksToAvoid = new Setting<>(new ArrayList<>(
187            // Leave Empty by Default
188    ));
189
190    /**
191     * Blocks that Baritone is not allowed to break
192     */
193    public final Setting<List<Block>> blocksToAvoidBreaking = new Setting<>(new ArrayList<>(Arrays.asList( // TODO can this be a HashSet or ImmutableSet?
194            Blocks.CRAFTING_TABLE,
195            Blocks.FURNACE,
196            Blocks.LIT_FURNACE,
197            Blocks.CHEST,
198            Blocks.TRAPPED_CHEST,
199            Blocks.STANDING_SIGN,
200            Blocks.WALL_SIGN
201    )));
202
203    /**
204     * A list of blocks to be treated as if they're air.
205     * <p>
206     * If a schematic asks for air at a certain position, and that position currently contains a block on this list, it will be treated as correct.
207     */
208    public final Setting<List<Block>> buildIgnoreBlocks = new Setting<>(new ArrayList<>(Arrays.asList(
209
210    )));
211
212    /**
213     * A list of blocks to be treated as correct.
214     * <p>
215     * If a schematic asks for any block on this list at a certain position, it will be treated as correct, regardless of what it currently is.
216     */
217    public final Setting<List<Block>> buildSkipBlocks = new Setting<>(new ArrayList<>(Arrays.asList(
218
219    )));
220
221    /**
222     * A mapping of blocks to blocks treated as correct in their position
223     * <p>
224     * If a schematic asks for a block on this mapping, all blocks on the mapped list will be accepted at that location as well
225     */
226    public final Setting<Map<Block, List<Block>>> buildValidSubstitutes = new Setting<>(new HashMap<>());
227
228    /**
229     * A mapping of blocks to blocks to be built instead
230     * <p>
231     * If a schematic asks for a block on this mapping, Baritone will place the first placeable block in the mapped list
232     */
233    public final Setting<Map<Block, List<Block>>> buildSubstitutes = new Setting<>(new HashMap<>());
234
235    /**
236     * A list of blocks to become air
237     * <p>
238     * If a schematic asks for a block on this list, only air will be accepted at that location (and nothing on buildIgnoreBlocks)
239     */
240    public final Setting<List<Block>> okIfAir = new Setting<>(new ArrayList<>(Arrays.asList(
241
242    )));
243
244    /**
245     * If this is true, the builder will treat all non-air blocks as correct. It will only place new blocks.
246     */
247    public final Setting<Boolean> buildIgnoreExisting = new Setting<>(false);
248
249    /**
250     * If this setting is true, Baritone will never break a block that is adjacent to an unsupported falling block.
251     * <p>
252     * I.E. it will never trigger cascading sand / gravel falls
253     */
254    public final Setting<Boolean> avoidUpdatingFallingBlocks = new Setting<>(true);
255
256    /**
257     * Enables some more advanced vine features. They're honestly just gimmicks and won't ever be needed in real
258     * pathing scenarios. And they can cause Baritone to get trapped indefinitely in a strange scenario.
259     * <p>
260     * Almost never turn this on lol
261     */
262    public final Setting<Boolean> allowVines = new Setting<>(false);
263
264    /**
265     * Slab behavior is complicated, disable this for higher path reliability. Leave enabled if you have bottom slabs
266     * everywhere in your base.
267     */
268    public final Setting<Boolean> allowWalkOnBottomSlab = new Setting<>(true);
269
270    /**
271     * You know what it is
272     * <p>
273     * But it's very unreliable and falls off when cornering like all the time so.
274     * <p>
275     * It also overshoots the landing pretty much always (making contact with the next block over), so be careful
276     */
277    public final Setting<Boolean> allowParkour = new Setting<>(false);
278
279    /**
280     * Actually pretty reliable.
281     * <p>
282     * Doesn't make it any more dangerous compared to just normal allowParkour th
283     */
284    public final Setting<Boolean> allowParkourPlace = new Setting<>(false);
285
286    /**
287     * For example, if you have Mining Fatigue or Haste, adjust the costs of breaking blocks accordingly.
288     */
289    public final Setting<Boolean> considerPotionEffects = new Setting<>(true);
290
291    /**
292     * Sprint and jump a block early on ascends wherever possible
293     */
294    public final Setting<Boolean> sprintAscends = new Setting<>(true);
295
296    /**
297     * If we overshoot a traverse and end up one block beyond the destination, mark it as successful anyway.
298     * <p>
299     * This helps with speed exceeding 20m/s
300     */
301    public final Setting<Boolean> overshootTraverse = new Setting<>(true);
302
303    /**
304     * When breaking blocks for a movement, wait until all falling blocks have settled before continuing
305     */
306    public final Setting<Boolean> pauseMiningForFallingBlocks = new Setting<>(true);
307
308    /**
309     * How many ticks between right clicks are allowed. Default in game is 4
310     */
311    public final Setting<Integer> rightClickSpeed = new Setting<>(4);
312
313    /**
314     * Block reach distance
315     */
316    public final Setting<Float> blockReachDistance = new Setting<>(4.5f);
317
318    /**
319     * How many degrees to randomize the pitch and yaw every tick. Set to 0 to disable
320     */
321    public final Setting<Double> randomLooking = new Setting<>(0.01d);
322
323    /**
324     * This is the big A* setting.
325     * As long as your cost heuristic is an *underestimate*, it's guaranteed to find you the best path.
326     * 3.5 is always an underestimate, even if you are sprinting.
327     * If you're walking only (with allowSprint off) 4.6 is safe.
328     * Any value below 3.5 is never worth it. It's just more computation to find the same path, guaranteed.
329     * (specifically, it needs to be strictly slightly less than ActionCosts.WALK_ONE_BLOCK_COST, which is about 3.56)
330     * <p>
331     * Setting it at 3.57 or above with sprinting, or to 4.64 or above without sprinting, will result in
332     * faster computation, at the cost of a suboptimal path. Any value above the walk / sprint cost will result
333     * in it going straight at its goal, and not investigating alternatives, because the combined cost / heuristic
334     * metric gets better and better with each block, instead of slightly worse.
335     * <p>
336     * Finding the optimal path is worth it, so it's the default.
337     */
338    public final Setting<Double> costHeuristic = new Setting<>(3.563);
339
340    // a bunch of obscure internal A* settings that you probably don't want to change
341    /**
342     * The maximum number of times it will fetch outside loaded or cached chunks before assuming that
343     * pathing has reached the end of the known area, and should therefore stop.
344     */
345    public final Setting<Integer> pathingMaxChunkBorderFetch = new Setting<>(50);
346
347    /**
348     * Set to 1.0 to effectively disable this feature
349     *
350     * @see <a href="https://github.com/cabaletta/baritone/issues/18">Issue #18</a>
351     */
352    public final Setting<Double> backtrackCostFavoringCoefficient = new Setting<>(0.5);
353
354    /**
355     * Toggle the following 4 settings
356     * <p>
357     * They have a noticeable performance impact, so they default off
358     * <p>
359     * Specifically, building up the avoidance map on the main thread before pathing starts actually takes a noticeable
360     * amount of time, especially when there are a lot of mobs around, and your game jitters for like 200ms while doing so
361     */
362    public final Setting<Boolean> avoidance = new Setting<>(false);
363
364    /**
365     * Set to 1.0 to effectively disable this feature
366     * <p>
367     * Set below 1.0 to go out of your way to walk near mob spawners
368     */
369    public final Setting<Double> mobSpawnerAvoidanceCoefficient = new Setting<>(2.0);
370
371    public final Setting<Integer> mobSpawnerAvoidanceRadius = new Setting<>(16);
372
373    /**
374     * Set to 1.0 to effectively disable this feature
375     * <p>
376     * Set below 1.0 to go out of your way to walk near mobs
377     */
378    public final Setting<Double> mobAvoidanceCoefficient = new Setting<>(1.5);
379
380    public final Setting<Integer> mobAvoidanceRadius = new Setting<>(8);
381
382    /**
383     * When running a goto towards a container block (chest, ender chest, furnace, etc),
384     * right click and open it once you arrive.
385     */
386    public final Setting<Boolean> rightClickContainerOnArrival = new Setting<>(true);
387
388    /**
389     * When running a goto towards a nether portal block, walk all the way into the portal
390     * instead of stopping one block before.
391     */
392    public final Setting<Boolean> enterPortal = new Setting<>(true);
393
394    /**
395     * Don't repropagate cost improvements below 0.01 ticks. They're all just floating point inaccuracies,
396     * and there's no point.
397     */
398    public final Setting<Boolean> minimumImprovementRepropagation = new Setting<>(true);
399
400    /**
401     * After calculating a path (potentially through cached chunks), artificially cut it off to just the part that is
402     * entirely within currently loaded chunks. Improves path safety because cached chunks are heavily simplified.
403     * <p>
404     * This is much safer to leave off now, and makes pathing more efficient. More explanation in the issue.
405     *
406     * @see <a href="https://github.com/cabaletta/baritone/issues/114">Issue #114</a>
407     */
408    public final Setting<Boolean> cutoffAtLoadBoundary = new Setting<>(false);
409
410    /**
411     * If a movement's cost increases by more than this amount between calculation and execution (due to changes
412     * in the environment / world), cancel and recalculate
413     */
414    public final Setting<Double> maxCostIncrease = new Setting<>(10D);
415
416    /**
417     * Stop 5 movements before anything that made the path COST_INF.
418     * For example, if lava has spread across the path, don't walk right up to it then recalculate, it might
419     * still be spreading lol
420     */
421    public final Setting<Integer> costVerificationLookahead = new Setting<>(5);
422
423    /**
424     * Static cutoff factor. 0.9 means cut off the last 10% of all paths, regardless of chunk load state
425     */
426    public final Setting<Double> pathCutoffFactor = new Setting<>(0.9);
427
428    /**
429     * Only apply static cutoff for paths of at least this length (in terms of number of movements)
430     */
431    public final Setting<Integer> pathCutoffMinimumLength = new Setting<>(30);
432
433    /**
434     * Start planning the next path once the remaining movements tick estimates sum up to less than this value
435     */
436    public final Setting<Integer> planningTickLookahead = new Setting<>(150);
437
438    /**
439     * Default size of the Long2ObjectOpenHashMap used in pathing
440     */
441    public final Setting<Integer> pathingMapDefaultSize = new Setting<>(1024);
442
443    /**
444     * Load factor coefficient for the Long2ObjectOpenHashMap used in pathing
445     * <p>
446     * Decrease for faster map operations, but higher memory usage
447     */
448    public final Setting<Float> pathingMapLoadFactor = new Setting<>(0.75f);
449
450    /**
451     * How far are you allowed to fall onto solid ground (without a water bucket)?
452     * 3 won't deal any damage. But if you just want to get down the mountain quickly and you have
453     * Feather Falling IV, you might set it a bit higher, like 4 or 5.
454     */
455    public final Setting<Integer> maxFallHeightNoWater = new Setting<>(3);
456
457    /**
458     * How far are you allowed to fall onto solid ground (with a water bucket)?
459     * It's not that reliable, so I've set it below what would kill an unarmored player (23)
460     */
461    public final Setting<Integer> maxFallHeightBucket = new Setting<>(20);
462
463    /**
464     * Is it okay to sprint through a descend followed by a diagonal?
465     * The player overshoots the landing, but not enough to fall off. And the diagonal ensures that there isn't
466     * lava or anything that's !canWalkInto in that space, so it's technically safe, just a little sketchy.
467     * <p>
468     * Note: this is *not* related to the allowDiagonalDescend setting, that is a completely different thing.
469     */
470    public final Setting<Boolean> allowOvershootDiagonalDescend = new Setting<>(true);
471
472    /**
473     * If your goal is a GoalBlock in an unloaded chunk, assume it's far enough away that the Y coord
474     * doesn't matter yet, and replace it with a GoalXZ to the same place before calculating a path.
475     * Once a segment ends within chunk load range of the GoalBlock, it will go back to normal behavior
476     * of considering the Y coord. The reasoning is that if your X and Z are 10,000 blocks away,
477     * your Y coordinate's accuracy doesn't matter at all until you get much much closer.
478     */
479    public final Setting<Boolean> simplifyUnloadedYCoord = new Setting<>(true);
480
481    /**
482     * Whenever a block changes, repack the whole chunk that it's in
483     */
484    public final Setting<Boolean> repackOnAnyBlockChange = new Setting<>(true);
485
486    /**
487     * If a movement takes this many ticks more than its initial cost estimate, cancel it
488     */
489    public final Setting<Integer> movementTimeoutTicks = new Setting<>(100);
490
491    /**
492     * Pathing ends after this amount of time, but only if a path has been found
493     * <p>
494     * If no valid path (length above the minimum) has been found, pathing continues up until the failure timeout
495     */
496    public final Setting<Long> primaryTimeoutMS = new Setting<>(500L);
497
498    /**
499     * Pathing can never take longer than this, even if that means failing to find any path at all
500     */
501    public final Setting<Long> failureTimeoutMS = new Setting<>(2000L);
502
503    /**
504     * Planning ahead while executing a segment ends after this amount of time, but only if a path has been found
505     * <p>
506     * If no valid path (length above the minimum) has been found, pathing continues up until the failure timeout
507     */
508    public final Setting<Long> planAheadPrimaryTimeoutMS = new Setting<>(4000L);
509
510    /**
511     * Planning ahead while executing a segment can never take longer than this, even if that means failing to find any path at all
512     */
513    public final Setting<Long> planAheadFailureTimeoutMS = new Setting<>(5000L);
514
515    /**
516     * For debugging, consider nodes much much slower
517     */
518    public final Setting<Boolean> slowPath = new Setting<>(false);
519
520    /**
521     * Milliseconds between each node
522     */
523    public final Setting<Long> slowPathTimeDelayMS = new Setting<>(100L);
524
525    /**
526     * The alternative timeout number when slowPath is on
527     */
528    public final Setting<Long> slowPathTimeoutMS = new Setting<>(40000L);
529
530    /**
531     * The big one. Download all chunks in simplified 2-bit format and save them for better very-long-distance pathing.
532     */
533    public final Setting<Boolean> chunkCaching = new Setting<>(true);
534
535    /**
536     * On save, delete from RAM any cached regions that are more than 1024 blocks away from the player
537     * <p>
538     * Temporarily disabled
539     * <p>
540     * Temporarily reenabled
541     *
542     * @see <a href="https://github.com/cabaletta/baritone/issues/248">Issue #248</a>
543     */
544    public final Setting<Boolean> pruneRegionsFromRAM = new Setting<>(true);
545
546    /**
547     * Remember the contents of containers (chests, echests, furnaces)
548     * <p>
549     * Really buggy since the packet stuff is multithreaded badly thanks to brady
550     */
551    public final Setting<Boolean> containerMemory = new Setting<>(false);
552
553    /**
554     * Fill in blocks behind you
555     */
556    public final Setting<Boolean> backfill = new Setting<>(false);
557
558    /**
559     * Shows popup message in the upper right corner, similarly to when you make an advancement
560     */
561    public final Setting<Boolean> logAsToast = new Setting<>(false);
562
563    /**
564     * The time of how long the message in the pop-up will display
565     * <p>
566     * If below 1000L (1sec), it's better to disable this
567     */
568    public final Setting<Long> toastTimer = new Setting<>(5000L);
569
570    /**
571     * Print all the debug messages to chat
572     */
573    public final Setting<Boolean> chatDebug = new Setting<>(false);
574
575    /**
576     * Allow chat based control of Baritone. Most likely should be disabled when Baritone is imported for use in
577     * something else
578     */
579    public final Setting<Boolean> chatControl = new Setting<>(true);
580
581    /**
582     * Some clients like Impact try to force chatControl to off, so here's a second setting to do it anyway
583     */
584    public final Setting<Boolean> chatControlAnyway = new Setting<>(false);
585
586    /**
587     * Render the path
588     */
589    public final Setting<Boolean> renderPath = new Setting<>(true);
590
591    /**
592     * Render the path as a line instead of a frickin thingy
593     */
594    public final Setting<Boolean> renderPathAsLine = new Setting<>(false);
595
596    /**
597     * Render the goal
598     */
599    public final Setting<Boolean> renderGoal = new Setting<>(true);
600
601    /**
602     * Render the goal as a sick animated thingy instead of just a box
603     * (also controls animation of GoalXZ if {@link #renderGoalXZBeacon} is enabled)
604     */
605    public final Setting<Boolean> renderGoalAnimated = new Setting<>(true);
606
607    /**
608     * Render selection boxes
609     */
610    public final Setting<Boolean> renderSelectionBoxes = new Setting<>(true);
611
612    /**
613     * Ignore depth when rendering the goal
614     */
615    public final Setting<Boolean> renderGoalIgnoreDepth = new Setting<>(true);
616
617    /**
618     * Renders X/Z type Goals with the vanilla beacon beam effect. Combining this with
619     * {@link #renderGoalIgnoreDepth} will cause strange render clipping.
620     */
621    public final Setting<Boolean> renderGoalXZBeacon = new Setting<>(false);
622
623    /**
624     * Ignore depth when rendering the selection boxes (to break, to place, to walk into)
625     */
626    public final Setting<Boolean> renderSelectionBoxesIgnoreDepth = new Setting<>(true);
627
628    /**
629     * Ignore depth when rendering the path
630     */
631    public final Setting<Boolean> renderPathIgnoreDepth = new Setting<>(true);
632
633    /**
634     * Line width of the path when rendered, in pixels
635     */
636    public final Setting<Float> pathRenderLineWidthPixels = new Setting<>(5F);
637
638    /**
639     * Line width of the goal when rendered, in pixels
640     */
641    public final Setting<Float> goalRenderLineWidthPixels = new Setting<>(3F);
642
643    /**
644     * Start fading out the path at 20 movements ahead, and stop rendering it entirely 30 movements ahead.
645     * Improves FPS.
646     */
647    public final Setting<Boolean> fadePath = new Setting<>(false);
648
649    /**
650     * Move without having to force the client-sided rotations
651     */
652    public final Setting<Boolean> freeLook = new Setting<>(true);
653
654    /**
655     * Will cause some minor behavioral differences to ensure that Baritone works on anticheats.
656     * <p>
657     * At the moment this will silently set the player's rotations when using freeLook so you're not sprinting in
658     * directions other than forward, which is picken up by more "advanced" anticheats like AAC, but not NCP.
659     */
660    public final Setting<Boolean> antiCheatCompatibility = new Setting<>(true);
661
662    /**
663     * Exclusively use cached chunks for pathing
664     * <p>
665     * Never turn this on
666     */
667    public final Setting<Boolean> pathThroughCachedOnly = new Setting<>(false);
668
669    /**
670     * Continue sprinting while in water
671     */
672    public final Setting<Boolean> sprintInWater = new Setting<>(true);
673
674    /**
675     * When GetToBlockProcess or MineProcess fails to calculate a path, instead of just giving up, mark the closest instance
676     * of that block as "unreachable" and go towards the next closest. GetToBlock expands this search to the whole "vein"; MineProcess does not.
677     * This is because MineProcess finds individual impossible blocks (like one block in a vein that has gravel on top then lava, so it can't break)
678     * Whereas GetToBlock should blacklist the whole "vein" if it can't get to any of them.
679     */
680    public final Setting<Boolean> blacklistClosestOnFailure = new Setting<>(true);
681
682    /**
683     * 😎 Render cached chunks as semitransparent. Doesn't work with OptiFine 😭 Rarely randomly crashes, see <a href="https://github.com/cabaletta/baritone/issues/327">this issue</a>.
684     * <p>
685     * Can be very useful on servers with low render distance. After enabling, you may need to reload the world in order for it to have an effect
686     * (e.g. disconnect and reconnect, enter then exit the nether, die and respawn, etc). This may literally kill your FPS and CPU because
687     * every chunk gets recompiled twice as much as normal, since the cached version comes into range, then the normal one comes from the server for real.
688     * <p>
689     * Note that flowing water is cached as AVOID, which is rendered as lava. As you get closer, you may therefore see lava falls being replaced with water falls.
690     * <p>
691     * SOLID is rendered as stone in the overworld, netherrack in the nether, and end stone in the end
692     */
693    public final Setting<Boolean> renderCachedChunks = new Setting<>(false);
694
695    /**
696     * 0.0f = not visible, fully transparent (instead of setting this to 0, turn off renderCachedChunks)
697     * 1.0f = fully opaque
698     */
699    public final Setting<Float> cachedChunksOpacity = new Setting<>(0.5f);
700
701    /**
702     * Whether or not to allow you to run Baritone commands with the prefix
703     */
704    public final Setting<Boolean> prefixControl = new Setting<>(true);
705
706    /**
707     * The command prefix for chat control
708     */
709    public final Setting<String> prefix = new Setting<>("#");
710
711    /**
712     * Use a short Baritone prefix [B] instead of [Baritone] when logging to chat
713     */
714    public final Setting<Boolean> shortBaritonePrefix = new Setting<>(false);
715
716    /**
717     * Echo commands to chat when they are run
718     */
719    public final Setting<Boolean> echoCommands = new Setting<>(true);
720
721    /**
722     * Censor coordinates in goals and block positions
723     */
724    public final Setting<Boolean> censorCoordinates = new Setting<>(false);
725
726    /**
727     * Censor arguments to ran commands, to hide, for example, coordinates to #goal
728     */
729    public final Setting<Boolean> censorRanCommands = new Setting<>(false);
730
731    /**
732     * Stop using tools just before they are going to break.
733     */
734    public final Setting<Boolean> itemSaver = new Setting<>(false);
735
736    /**
737     * Durability to leave on the tool when using itemSaver
738     */
739    public final Setting<Integer> itemSaverThreshold = new Setting<>(10);
740
741    /**
742     * Always prefer silk touch tools over regular tools. This will not sacrifice speed, but it will always prefer silk
743     * touch tools over other tools of the same speed. This includes always choosing ANY silk touch tool over your hand.
744     */
745    public final Setting<Boolean> preferSilkTouch = new Setting<>(false);
746
747    /**
748     * Don't stop walking forward when you need to break blocks in your way
749     */
750    public final Setting<Boolean> walkWhileBreaking = new Setting<>(true);
751
752    /**
753     * When a new segment is calculated that doesn't overlap with the current one, but simply begins where the current segment ends,
754     * splice it on and make a longer combined path. If this setting is off, any planned segment will not be spliced and will instead
755     * be the "next path" in PathingBehavior, and will only start after this one ends. Turning this off hurts planning ahead,
756     * because the next segment will exist even if it's very short.
757     *
758     * @see #planningTickLookahead
759     */
760    public final Setting<Boolean> splicePath = new Setting<>(true);
761
762    /**
763     * If we are more than 300 movements into the current path, discard the oldest segments, as they are no longer useful
764     */
765    public final Setting<Integer> maxPathHistoryLength = new Setting<>(300);
766
767    /**
768     * If the current path is too long, cut off this many movements from the beginning.
769     */
770    public final Setting<Integer> pathHistoryCutoffAmount = new Setting<>(50);
771
772    /**
773     * Rescan for the goal once every 5 ticks.
774     * Set to 0 to disable.
775     */
776    public final Setting<Integer> mineGoalUpdateInterval = new Setting<>(5);
777
778    /**
779     * After finding this many instances of the target block in the cache, it will stop expanding outward the chunk search.
780     */
781    public final Setting<Integer> maxCachedWorldScanCount = new Setting<>(10);
782
783    /**
784     * Sets the minimum y level whilst mining - set to 0 to turn off.
785     */
786    public final Setting<Integer> minYLevelWhileMining = new Setting<>(0);
787
788    /**
789     * This will only allow baritone to mine exposed ores, can be used to stop ore obfuscators on servers that use them.
790     */
791    public final Setting<Boolean> allowOnlyExposedOres = new Setting<>(false);
792
793    /**
794     * When allowOnlyExposedOres is enabled this is the distance around to search.
795     * <p>
796     * It is recommended to keep this value low, as it dramatically increases calculation times.
797     */
798    public final Setting<Integer> allowOnlyExposedOresDistance = new Setting<>(1);
799
800    /**
801     * When GetToBlock or non-legit Mine doesn't know any locations for the desired block, explore randomly instead of giving up.
802     */
803    public final Setting<Boolean> exploreForBlocks = new Setting<>(true);
804
805    /**
806     * While exploring the world, offset the closest unloaded chunk by this much in both axes.
807     * <p>
808     * This can result in more efficient loading, if you set this to the render distance.
809     */
810    public final Setting<Integer> worldExploringChunkOffset = new Setting<>(0);
811
812    /**
813     * Take the 10 closest chunks, even if they aren't strictly tied for distance metric from origin.
814     */
815    public final Setting<Integer> exploreChunkSetMinimumSize = new Setting<>(10);
816
817    /**
818     * Attempt to maintain Y coordinate while exploring
819     * <p>
820     * -1 to disable
821     */
822    public final Setting<Integer> exploreMaintainY = new Setting<>(64);
823
824    /**
825     * Replant normal Crops while farming and leave cactus and sugarcane to regrow
826     */
827    public final Setting<Boolean> replantCrops = new Setting<>(true);
828
829    /**
830     * Replant nether wart while farming. This setting only has an effect when replantCrops is also enabled
831     */
832    public final Setting<Boolean> replantNetherWart = new Setting<>(false);
833
834    /**
835     * When the cache scan gives less blocks than the maximum threshold (but still above zero), scan the main world too.
836     * <p>
837     * Only if you have a beefy CPU and automatically mine blocks that are in cache
838     */
839    public final Setting<Boolean> extendCacheOnThreshold = new Setting<>(false);
840
841    /**
842     * Don't consider the next layer in builder until the current one is done
843     */
844    public final Setting<Boolean> buildInLayers = new Setting<>(false);
845
846    /**
847     * false = build from bottom to top
848     * <p>
849     * true = build from top to bottom
850     */
851    public final Setting<Boolean> layerOrder = new Setting<>(false);
852
853    /**
854     * How high should the individual layers be?
855     */
856    public final Setting<Integer> layerHeight = new Setting<>(1);
857
858    /**
859     * Start building the schematic at a specific layer.
860     * Can help on larger builds when schematic wants to break things its already built
861     */
862    public final Setting<Integer> startAtLayer = new Setting<>(0);
863
864    /**
865     * If a layer is unable to be constructed, just skip it.
866     */
867    public final Setting<Boolean> skipFailedLayers = new Setting<>(false);
868
869    /**
870     * Only build the selected part of schematics
871     */
872     public final Setting<Boolean> buildOnlySelection = new Setting<>(false);
873
874    /**
875     * How far to move before repeating the build. 0 to disable repeating on a certain axis, 0,0,0 to disable entirely
876     */
877    public final Setting<Vec3i> buildRepeat = new Setting<>(new Vec3i(0, 0, 0));
878
879    /**
880     * How many times to buildrepeat. -1 for infinite.
881     */
882    public final Setting<Integer> buildRepeatCount = new Setting<>(-1);
883
884    /**
885     * Don't notify schematics that they are moved.
886     * e.g. replacing will replace the same spots for every repetition
887     * Mainly for backward compatibility.
888     */
889    public final Setting<Boolean> buildRepeatSneaky = new Setting<>(true);
890
891    /**
892     * Allow standing above a block while mining it, in BuilderProcess
893     * <p>
894     * Experimental
895     */
896    public final Setting<Boolean> breakFromAbove = new Setting<>(false);
897
898    /**
899     * As well as breaking from above, set a goal to up and to the side of all blocks to break.
900     * <p>
901     * Never turn this on without also turning on breakFromAbove.
902     */
903    public final Setting<Boolean> goalBreakFromAbove = new Setting<>(false);
904
905    /**
906     * Build in map art mode, which makes baritone only care about the top block in each column
907     */
908    public final Setting<Boolean> mapArtMode = new Setting<>(false);
909
910    /**
911     * Override builder's behavior to not attempt to correct blocks that are currently water
912     */
913    public final Setting<Boolean> okIfWater = new Setting<>(false);
914
915    /**
916     * The set of incorrect blocks can never grow beyond this size
917     */
918    public final Setting<Integer> incorrectSize = new Setting<>(100);
919
920    /**
921     * Multiply the cost of breaking a block that's correct in the builder's schematic by this coefficient
922     */
923    public final Setting<Double> breakCorrectBlockPenaltyMultiplier = new Setting<>(10d);
924
925    /**
926     * When this setting is true, build a schematic with the highest X coordinate being the origin, instead of the lowest
927     */
928    public final Setting<Boolean> schematicOrientationX = new Setting<>(false);
929
930    /**
931     * When this setting is true, build a schematic with the highest Y coordinate being the origin, instead of the lowest
932     */
933    public final Setting<Boolean> schematicOrientationY = new Setting<>(false);
934
935    /**
936     * When this setting is true, build a schematic with the highest Z coordinate being the origin, instead of the lowest
937     */
938    public final Setting<Boolean> schematicOrientationZ = new Setting<>(false);
939
940    /**
941     * The fallback used by the build command when no extension is specified. This may be useful if schematics of a
942     * particular format are used often, and the user does not wish to have to specify the extension with every usage.
943     */
944    public final Setting<String> schematicFallbackExtension = new Setting<>("schematic");
945
946    /**
947     * Distance to scan every tick for updates. Expanding this beyond player reach distance (i.e. setting it to 6 or above)
948     * is only necessary in very large schematics where rescanning the whole thing is costly.
949     */
950    public final Setting<Integer> builderTickScanRadius = new Setting<>(5);
951
952    /**
953     * While mining, should it also consider dropped items of the correct type as a pathing destination (as well as ore blocks)?
954     */
955    public final Setting<Boolean> mineScanDroppedItems = new Setting<>(true);
956
957    /**
958     * While mining, wait this number of milliseconds after mining an ore to see if it will drop an item
959     * instead of immediately going onto the next one
960     * <p>
961     * Thanks Louca
962     */
963    public final Setting<Long> mineDropLoiterDurationMSThanksLouca = new Setting<>(250L);
964
965    /**
966     * Trim incorrect positions too far away, helps performance but hurts reliability in very large schematics
967     */
968    public final Setting<Boolean> distanceTrim = new Setting<>(true);
969
970    /**
971     * Cancel the current path if the goal has changed, and the path originally ended in the goal but doesn't anymore.
972     * <p>
973     * Currently only runs when either MineBehavior or FollowBehavior is active.
974     * <p>
975     * For example, if Baritone is doing "mine iron_ore", the instant it breaks the ore (and it becomes air), that location
976     * is no longer a goal. This means that if this setting is true, it will stop there. If this setting were off, it would
977     * continue with its path, and walk into that location. The tradeoff is if this setting is true, it mines ores much faster
978     * since it doesn't waste any time getting into locations that no longer contain ores, but on the other hand, it misses
979     * some drops, and continues on without ever picking them up.
980     * <p>
981     * Also on cosmic prisons this should be set to true since you don't actually mine the ore it just gets replaced with stone.
982     */
983    public final Setting<Boolean> cancelOnGoalInvalidation = new Setting<>(true);
984
985    /**
986     * The "axis" command (aka GoalAxis) will go to a axis, or diagonal axis, at this Y level.
987     */
988    public final Setting<Integer> axisHeight = new Setting<>(120);
989
990    /**
991     * Disconnect from the server upon arriving at your goal
992     */
993    public final Setting<Boolean> disconnectOnArrival = new Setting<>(false);
994
995    /**
996     * Disallow MineBehavior from using X-Ray to see where the ores are. Turn this option on to force it to mine "legit"
997     * where it will only mine an ore once it can actually see it, so it won't do or know anything that a normal player
998     * couldn't. If you don't want it to look like you're X-Raying, turn this on
999     * This will always explore, regardless of exploreForBlocks
1000     */
1001    public final Setting<Boolean> legitMine = new Setting<>(false);
1002
1003    /**
1004     * What Y level to go to for legit strip mining
1005     */
1006    public final Setting<Integer> legitMineYLevel = new Setting<>(11);
1007
1008    /**
1009     * Magically see ores that are separated diagonally from existing ores. Basically like mining around the ores that it finds
1010     * in case there's one there touching it diagonally, except it checks it un-legit-ly without having the mine blocks to see it.
1011     * You can decide whether this looks plausible or not.
1012     * <p>
1013     * This is disabled because it results in some weird behavior. For example, it can """see""" the top block of a vein of iron_ore
1014     * through a lava lake. This isn't an issue normally since it won't consider anything touching lava, so it just ignores it.
1015     * However, this setting expands that and allows it to see the entire vein so it'll mine under the lava lake to get the iron that
1016     * it can reach without mining blocks adjacent to lava. This really defeats the purpose of legitMine since a player could never
1017     * do that lol, so thats one reason why its disabled
1018     */
1019    public final Setting<Boolean> legitMineIncludeDiagonals = new Setting<>(false);
1020
1021    /**
1022     * When mining block of a certain type, try to mine two at once instead of one.
1023     * If the block above is also a goal block, set GoalBlock instead of GoalTwoBlocks
1024     * If the block below is also a goal block, set GoalBlock to the position one down instead of GoalTwoBlocks
1025     */
1026    public final Setting<Boolean> forceInternalMining = new Setting<>(true);
1027
1028    /**
1029     * Modification to the previous setting, only has effect if forceInternalMining is true
1030     * If true, only apply the previous setting if the block adjacent to the goal isn't air.
1031     */
1032    public final Setting<Boolean> internalMiningAirException = new Setting<>(true);
1033
1034    /**
1035     * The actual GoalNear is set this distance away from the entity you're following
1036     * <p>
1037     * For example, set followOffsetDistance to 5 and followRadius to 0 to always stay precisely 5 blocks north of your follow target.
1038     */
1039    public final Setting<Double> followOffsetDistance = new Setting<>(0D);
1040
1041    /**
1042     * The actual GoalNear is set in this direction from the entity you're following. This value is in degrees.
1043     */
1044    public final Setting<Float> followOffsetDirection = new Setting<>(0F);
1045
1046    /**
1047     * The radius (for the GoalNear) of how close to your target position you actually have to be
1048     */
1049    public final Setting<Integer> followRadius = new Setting<>(3);
1050
1051    /**
1052     * Turn this on if your exploration filter is enormous, you don't want it to check if it's done,
1053     * and you are just fine with it just hanging on completion
1054     */
1055    public final Setting<Boolean> disableCompletionCheck = new Setting<>(false);
1056
1057    /**
1058     * Cached chunks (regardless of if they're in RAM or saved to disk) expire and are deleted after this number of seconds
1059     * -1 to disable
1060     * <p>
1061     * I would highly suggest leaving this setting disabled (-1).
1062     * <p>
1063     * The only valid reason I can think of enable this setting is if you are extremely low on disk space and you play on multiplayer,
1064     * and can't take (average) 300kb saved for every 512x512 area. (note that more complicated terrain is less compressible and will take more space)
1065     * <p>
1066     * However, simply discarding old chunks because they are old is inadvisable. Baritone is extremely good at correcting
1067     * itself and its paths as it learns new information, as new chunks load. There is no scenario in which having an
1068     * incorrect cache can cause Baritone to get stuck, take damage, or perform any action it wouldn't otherwise, everything
1069     * is rechecked once the real chunk is in range.
1070     * <p>
1071     * Having a robust cache greatly improves long distance pathfinding, as it's able to go around large scale obstacles
1072     * before they're in render distance. In fact, when the chunkCaching setting is disabled and Baritone starts anew
1073     * every time, or when you enter a completely new and very complicated area, it backtracks far more often because it
1074     * has to build up that cache from scratch. But after it's gone through an area just once, the next time will have zero
1075     * backtracking, since the entire area is now known and cached.
1076     */
1077    public final Setting<Long> cachedChunksExpirySeconds = new Setting<>(-1L);
1078
1079    /**
1080     * The function that is called when Baritone will log to chat. This function can be added to
1081     * via {@link Consumer#andThen(Consumer)} or it can completely be overriden via setting
1082     * {@link Setting#value};
1083     */
1084    public final Setting<Consumer<ITextComponent>> logger = new Setting<>(Minecraft.getMinecraft().ingameGUI.getChatGUI()::printChatMessage);
1085
1086    /**
1087     * The function that is called when Baritone will send a desktop notification. This function can be added to
1088     * via {@link Consumer#andThen(Consumer)} or it can completely be overriden via setting
1089     * {@link Setting#value};
1090     */
1091    public final Setting<BiConsumer<String, Boolean>> notifier = new Setting<>(NotificationHelper::notify);
1092
1093    /**
1094     * The function that is called when Baritone will show a toast. This function can be added to
1095     * via {@link Consumer#andThen(Consumer)} or it can completely be overriden via setting
1096     * {@link Setting#value};
1097     */
1098    public final Setting<BiConsumer<ITextComponent, ITextComponent>> toaster = new Setting<>(BaritoneToast::addOrUpdate);
1099
1100    /**
1101     * The size of the box that is rendered when the current goal is a GoalYLevel
1102     */
1103    public final Setting<Double> yLevelBoxSize = new Setting<>(15D);
1104
1105    /**
1106     * The color of the current path
1107     */
1108    public final Setting<Color> colorCurrentPath = new Setting<>(Color.RED);
1109
1110    /**
1111     * The color of the next path
1112     */
1113    public final Setting<Color> colorNextPath = new Setting<>(Color.MAGENTA);
1114
1115    /**
1116     * The color of the blocks to break
1117     */
1118    public final Setting<Color> colorBlocksToBreak = new Setting<>(Color.RED);
1119
1120    /**
1121     * The color of the blocks to place
1122     */
1123    public final Setting<Color> colorBlocksToPlace = new Setting<>(Color.GREEN);
1124
1125    /**
1126     * The color of the blocks to walk into
1127     */
1128    public final Setting<Color> colorBlocksToWalkInto = new Setting<>(Color.MAGENTA);
1129
1130    /**
1131     * The color of the best path so far
1132     */
1133    public final Setting<Color> colorBestPathSoFar = new Setting<>(Color.BLUE);
1134
1135    /**
1136     * The color of the path to the most recent considered node
1137     */
1138    public final Setting<Color> colorMostRecentConsidered = new Setting<>(Color.CYAN);
1139
1140    /**
1141     * The color of the goal box
1142     */
1143    public final Setting<Color> colorGoalBox = new Setting<>(Color.GREEN);
1144
1145    /**
1146     * The color of the goal box when it's inverted
1147     */
1148    public final Setting<Color> colorInvertedGoalBox = new Setting<>(Color.RED);
1149
1150    /**
1151     * The color of all selections
1152     */
1153    public final Setting<Color> colorSelection = new Setting<>(Color.CYAN);
1154
1155    /**
1156     * The color of the selection pos 1
1157     */
1158    public final Setting<Color> colorSelectionPos1 = new Setting<>(Color.BLACK);
1159
1160    /**
1161     * The color of the selection pos 2
1162     */
1163    public final Setting<Color> colorSelectionPos2 = new Setting<>(Color.ORANGE);
1164
1165    /**
1166     * The opacity of the selection. 0 is completely transparent, 1 is completely opaque
1167     */
1168    public final Setting<Float> selectionOpacity = new Setting<>(.5f);
1169
1170    /**
1171     * Line width of the goal when rendered, in pixels
1172     */
1173    public final Setting<Float> selectionLineWidth = new Setting<>(2F);
1174
1175    /**
1176     * Render selections
1177     */
1178    public final Setting<Boolean> renderSelection = new Setting<>(true);
1179
1180    /**
1181     * Ignore depth when rendering selections
1182     */
1183    public final Setting<Boolean> renderSelectionIgnoreDepth = new Setting<>(true);
1184
1185    /**
1186     * Render selection corners
1187     */
1188    public final Setting<Boolean> renderSelectionCorners = new Setting<>(true);
1189
1190    /**
1191     * Use sword to mine.
1192     */
1193    public final Setting<Boolean> useSwordToMine = new Setting<>(true);
1194
1195    /**
1196     * Desktop notifications
1197     */
1198    public final Setting<Boolean> desktopNotifications = new Setting<>(false);
1199
1200    /**
1201     * Desktop notification on path complete
1202     */
1203    public final Setting<Boolean> notificationOnPathComplete = new Setting<>(true);
1204
1205    /**
1206     * Desktop notification on farm fail
1207     */
1208    public final Setting<Boolean> notificationOnFarmFail = new Setting<>(true);
1209
1210    /**
1211     * Desktop notification on build finished
1212     */
1213    public final Setting<Boolean> notificationOnBuildFinished = new Setting<>(true);
1214
1215    /**
1216     * Desktop notification on explore finished
1217     */
1218    public final Setting<Boolean> notificationOnExploreFinished = new Setting<>(true);
1219
1220    /**
1221     * Desktop notification on mine fail
1222     */
1223    public final Setting<Boolean> notificationOnMineFail = new Setting<>(true);
1224
1225    /**
1226     * A map of lowercase setting field names to their respective setting
1227     */
1228    public final Map<String, Setting<?>> byLowerName;
1229
1230    /**
1231     * A list of all settings
1232     */
1233    public final List<Setting<?>> allSettings;
1234
1235    public final Map<Setting<?>, Type> settingTypes;
1236
1237    public final class Setting<T> {
1238
1239        public T value;
1240        public final T defaultValue;
1241        private String name;
1242
1243        @SuppressWarnings("unchecked")
1244        private Setting(T value) {
1245            if (value == null) {
1246                throw new IllegalArgumentException("Cannot determine value type class from null");
1247            }
1248            this.value = value;
1249            this.defaultValue = value;
1250        }
1251
1252        /**
1253         * Deprecated! Please use .value directly instead
1254         *
1255         * @return the current setting value
1256         */
1257        @Deprecated
1258        public final T get() {
1259            return value;
1260        }
1261
1262        public final String getName() {
1263            return name;
1264        }
1265
1266        public Class<T> getValueClass() {
1267            // noinspection unchecked
1268            return (Class<T>) TypeUtils.resolveBaseClass(getType());
1269        }
1270
1271        @Override
1272        public String toString() {
1273            return SettingsUtil.settingToString(this);
1274        }
1275
1276        /**
1277         * Reset this setting to its default value
1278         */
1279        public void reset() {
1280            value = defaultValue;
1281        }
1282
1283        public final Type getType() {
1284            return settingTypes.get(this);
1285        }
1286    }
1287
1288    // here be dragons
1289
1290    Settings() {
1291        Field[] temp = getClass().getFields();
1292
1293        Map<String, Setting<?>> tmpByName = new HashMap<>();
1294        List<Setting<?>> tmpAll = new ArrayList<>();
1295        Map<Setting<?>, Type> tmpSettingTypes = new HashMap<>();
1296
1297        try {
1298            for (Field field : temp) {
1299                if (field.getType().equals(Setting.class)) {
1300                    Setting<?> setting = (Setting<?>) field.get(this);
1301                    String name = field.getName();
1302                    setting.name = name;
1303                    name = name.toLowerCase();
1304                    if (tmpByName.containsKey(name)) {
1305                        throw new IllegalStateException("Duplicate setting name");
1306                    }
1307                    tmpByName.put(name, setting);
1308                    tmpAll.add(setting);
1309                    tmpSettingTypes.put(setting, ((ParameterizedType) field.getGenericType()).getActualTypeArguments()[0]);
1310                }
1311            }
1312        } catch (IllegalAccessException e) {
1313            throw new IllegalStateException(e);
1314        }
1315        byLowerName = Collections.unmodifiableMap(tmpByName);
1316        allSettings = Collections.unmodifiableList(tmpAll);
1317        settingTypes = Collections.unmodifiableMap(tmpSettingTypes);
1318    }
1319
1320    @SuppressWarnings("unchecked")
1321    public <T> List<Setting<T>> getAllValuesByType(Class<T> cla$$) {
1322        List<Setting<T>> result = new ArrayList<>();
1323        for (Setting<?> setting : allSettings) {
1324            if (setting.getValueClass().equals(cla$$)) {
1325                result.add((Setting<T>) setting);
1326            }
1327        }
1328        return result;
1329    }
1330}