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