]> git.lizzy.rs Git - BoundingBoxOutlineReloaded.git/blob - src/main/java/com/irtimaled/bbor/client/gui/SettingsScreen.java
Some settings changes
[BoundingBoxOutlineReloaded.git] / src / main / java / com / irtimaled / bbor / client / gui / SettingsScreen.java
1 package com.irtimaled.bbor.client.gui;
2
3 import com.irtimaled.bbor.client.ClientRenderer;
4 import com.irtimaled.bbor.client.config.ConfigManager;
5 import com.irtimaled.bbor.client.interop.ClientInterop;
6 import com.irtimaled.bbor.common.BoundingBoxType;
7 import net.minecraft.SharedConstants;
8 import net.minecraft.client.gui.screen.Screen;
9 import net.minecraft.client.gui.screen.narration.NarrationMessageBuilder;
10 import net.minecraft.client.resource.language.I18n;
11
12 public class SettingsScreen extends ListScreen {
13     private static final String pillagerOutpostVersionPattern = "(?:1\\.1[4-9]|1\\.[2-9][0-9]|18w(?:4[7-9]|5[0-9])|19w|2[0-9]w).*";
14     private static final String bastionRemnantVersionPattern = "(?:1\\.1[6-9]|1\\.[2-9][0-9]|20w(?:1[6-9]|[2-5][0-9])|2[1-9]w).*";
15     private static final String netherFossilVersionPattern = "(?:1\\.1[6-9]|1\\.[2-9][0-9]|20w(?:1[1-9]|[2-5][0-9])|2[1-9]w).*";
16
17     public static void show() {
18         ClientInterop.displayScreen(new SettingsScreen(null));
19     }
20
21     SettingsScreen(Screen lastScreen) {
22         super(lastScreen);
23     }
24
25     @Override
26     protected void onDoneClicked() {
27         ConfigManager.saveConfig();
28         super.onDoneClicked();
29     }
30
31     @Override
32     protected ControlList buildList(int top, int bottom) {
33         String version = SharedConstants.getGameVersion().getName();
34         ControlList controlList = new ControlList(this.width, this.height, top, bottom);
35         if (this.client.world != null) controlList.setTransparentBackground();
36
37         controlList
38                 .section(null,
39                         width -> new BoolButton(width, I18n.translate("bbor.options.active"), this.client.world != null) {
40                             @Override
41                             public void appendNarrations(NarrationMessageBuilder narrationMessageBuilder) {
42                                 this.appendDefaultNarrations(narrationMessageBuilder);
43                             }
44
45                             @Override
46                             public void onPressed() {
47                                 ClientRenderer.toggleActive();
48                             }
49
50                             @Override
51                             protected boolean getValue() {
52                                 return ClientRenderer.getActive();
53                             }
54                         },
55                         width -> new BoolSettingButton(width, I18n.translate("bbor.options.outerBoxOnly"), ConfigManager.outerBoxesOnly),
56                         width -> new BoolSettingButton(width, I18n.translate("bbor.options.fill"), ConfigManager.fill),
57                         width -> new IntSettingSlider(width, 0, 2, "bbor.options.fastRender", ConfigManager.fastRender)
58                                 .addDisplayValue(0, I18n.translate("bbor.options.fastRender.0"))
59                                 .addDisplayValue(1, I18n.translate("bbor.options.fastRender.1"))
60                                 .addDisplayValue(2, I18n.translate("bbor.options.fastRender.2")))
61                 .section(I18n.translate("bbor.features.spawnChunks"),
62                         width -> new BoundingBoxTypeButton(width, I18n.translate("bbor.features.spawnChunks"), BoundingBoxType.WorldSpawn),
63                         width -> new BoundingBoxTypeButton(width, I18n.translate("bbor.features.lazyChunks"), BoundingBoxType.LazySpawnChunks),
64                         width -> new MaxYSettingSlider(width, 39, ConfigManager.worldSpawnMaxY))
65                 .section(I18n.translate("bbor.features.slimeChunks"),
66                         width -> new BoundingBoxTypeButton(width, I18n.translate("bbor.features.slimeChunks"), BoundingBoxType.SlimeChunks),
67                         width -> new MaxYSettingSlider(width, 39, ConfigManager.slimeChunkMaxY))
68                 .section(I18n.translate("bbor.features.biomeBorders"),
69                         width -> new BoundingBoxTypeButton(width, I18n.translate("bbor.features.biomeBorders"), BoundingBoxType.BiomeBorder),
70                         width -> new MaxYSettingSlider(width, 1, ConfigManager.biomeBordersMaxY),
71                         width -> new IntSettingSlider(width, 1, 6, "bbor.options.distance", ConfigManager.biomeBordersRenderDistance)
72                                 .addDisplayValue(1, I18n.translate("bbor.options.distance.nearest"))
73                                 .addDisplayValue(2, I18n.translate("bbor.options.distance.nearer"))
74                                 .addDisplayValue(3, I18n.translate("bbor.options.distance.normal"))
75                                 .addDisplayValue(4, I18n.translate("bbor.options.distance.farther"))
76                                 .addDisplayValue(5, I18n.translate("bbor.options.distance.far"))
77                                 .addDisplayValue(6, I18n.translate("bbor.options.distance.veryFar")))
78                 .section(I18n.translate("bbor.features.flowerForests"),
79                         width -> new BoundingBoxTypeButton(width, I18n.translate("bbor.features.flowerForests"), BoundingBoxType.FlowerForest),
80                         width -> new IntSettingSlider(width, 1, 6, "bbor.options.distance", ConfigManager.flowerForestsRenderDistance)
81                                 .addDisplayValue(1, I18n.translate("bbor.options.distance.nearest"))
82                                 .addDisplayValue(2, I18n.translate("bbor.options.distance.nearer"))
83                                 .addDisplayValue(3, I18n.translate("bbor.options.distance.normal"))
84                                 .addDisplayValue(4, I18n.translate("bbor.options.distance.farther"))
85                                 .addDisplayValue(5, I18n.translate("bbor.options.distance.far"))
86                                 .addDisplayValue(6, I18n.translate("bbor.options.distance.veryFar")))
87                 .section(I18n.translate("bbor.features.bedrockCeilingBlocks"),
88                         width -> new BoundingBoxTypeButton(width, I18n.translate("bbor.features.bedrockCeilingBlocks"), BoundingBoxType.BedrockCeiling))
89                 .section(I18n.translate("bbor.features.mobSpawners"),
90                         width -> new BoundingBoxTypeButton(width, I18n.translate("bbor.features.mobSpawners"), BoundingBoxType.MobSpawner),
91                         width -> new BoolSettingButton(width, I18n.translate("bbor.features.mobSpawners.spawnArea"), ConfigManager.renderMobSpawnerSpawnArea),
92                         width -> new BoolSettingButton(width, I18n.translate("bbor.features.mobSpawners.activationLines"), ConfigManager.renderMobSpawnerActivationLines))
93                 .section(I18n.translate("bbor.sections.beaconsAndConduits"),
94                         width -> new BoundingBoxTypeButton(width, I18n.translate("bbor.features.beacons"), BoundingBoxType.Beacon),
95                         width -> new BoundingBoxTypeButton(width, I18n.translate("bbor.features.conduits"), BoundingBoxType.Conduit),
96                         width -> new BoolSettingButton(width, I18n.translate("bbor.features.conduits.mobHarmArea"), ConfigManager.renderConduitMobHarmArea))
97                 .section(I18n.translate("bbor.features.spawnableBlocks"),
98                         width -> new BoundingBoxTypeButton(width, I18n.translate("bbor.features.spawnableBlocks"), BoundingBoxType.SpawnableBlocks),
99                         width -> new IntSettingSlider(width, 1, 3, "bbor.options.distance.y", ConfigManager.spawnableBlocksRenderHeight)
100                                 .addDisplayValue(1, "2")
101                                 .addDisplayValue(2, "4")
102                                 .addDisplayValue(3, "8"),
103                         width -> new IntSettingSlider(width, 1, 3, "bbor.options.distance.xz", ConfigManager.spawnableBlocksRenderWidth)
104                                 .addDisplayValue(1, "8")
105                                 .addDisplayValue(2, "16")
106                                 .addDisplayValue(3, "32"))
107                 .section(I18n.translate("bbor.features.spawningSpheres"),
108                         width -> new BoundingBoxTypeButton(width, I18n.translate("bbor.features.spawningSpheres"), BoundingBoxType.AFKSphere),
109                         width -> new BoolSettingButton(width, I18n.translate("bbor.features.spawnableBlocks"), ConfigManager.renderAFKSpawnableBlocks))
110                 .section(I18n.translate("bbor.tabs.structures"),
111                         width -> new BoundingBoxTypeButton(width, I18n.translate("bbor.structures.desertTemples"), BoundingBoxType.DesertTemple),
112                         width -> new BoundingBoxTypeButton(width, I18n.translate("bbor.structures.jungleTemples"), BoundingBoxType.JungleTemple),
113                         width -> new BoundingBoxTypeButton(width, I18n.translate("bbor.structures.witchHuts"), BoundingBoxType.WitchHut),
114                         width -> new BoundingBoxTypeButton(width, I18n.translate("bbor.structures.mansions"), BoundingBoxType.Mansion),
115                         width -> new BoundingBoxTypeButton(width, I18n.translate("bbor.structures.monuments"), BoundingBoxType.OceanMonument),
116                         width -> new BoundingBoxTypeButton(width, I18n.translate("bbor.structures.igloos"), BoundingBoxType.Igloo),
117                         width -> new BoundingBoxTypeButton(width, I18n.translate("bbor.structures.oceanRuins"), BoundingBoxType.OceanRuin),
118                         width -> new BoundingBoxTypeButton(width, I18n.translate("bbor.structures.buriedTreasure"), BoundingBoxType.BuriedTreasure),
119                         width -> new BoundingBoxTypeButton(width, I18n.translate("bbor.structures.shipwrecks"), BoundingBoxType.Shipwreck),
120                         width -> new BoundingBoxTypeButton(width, I18n.translate("bbor.structures.strongholds"), BoundingBoxType.Stronghold),
121                         width -> new BoundingBoxTypeButton(width, I18n.translate("bbor.structures.mineshafts"), BoundingBoxType.MineShaft),
122                         width -> new BoundingBoxTypeButton(width, I18n.translate("bbor.structures.villages"), BoundingBoxType.Village),
123                         width -> version.matches(pillagerOutpostVersionPattern) ? new BoundingBoxTypeButton(width, I18n.translate("bbor.structures.pillagerOutposts"), BoundingBoxType.PillagerOutpost) : null,
124                         width -> version.matches(bastionRemnantVersionPattern) ? new BoundingBoxTypeButton(width, I18n.translate("bbor.structures.ruinedPortal"), BoundingBoxType.RuinedPortal) : null,
125                         width -> new BoundingBoxTypeButton(width, I18n.translate("bbor.structures.fortresses"), BoundingBoxType.NetherFortress),
126                         width -> version.matches(netherFossilVersionPattern) ? new BoundingBoxTypeButton(width, I18n.translate("bbor.structures.netherFossils"), BoundingBoxType.NetherFossil) : null,
127                         width -> version.matches(bastionRemnantVersionPattern) ? new BoundingBoxTypeButton(width, I18n.translate("bbor.structures.bastionRemnants"), BoundingBoxType.BastionRemnant) : null,
128                         width -> new BoundingBoxTypeButton(width, I18n.translate("bbor.structures.endCities"), BoundingBoxType.EndCity));
129         return controlList;
130     }
131 }