| 1 | package net.minecraft.client;
|
| 2 |
|
| 3 | import com.google.common.base.MoreObjects;
|
| 4 | import com.google.common.base.Splitter;
|
| 5 | import com.google.common.collect.ImmutableList;
|
| 6 | import com.google.common.collect.Lists;
|
| 7 | import com.google.common.collect.Sets;
|
| 8 | import com.google.common.io.Files;
|
| 9 | import com.google.gson.Gson;
|
| 10 | import com.google.gson.JsonElement;
|
| 11 | import com.google.gson.reflect.TypeToken;
|
| 12 | import com.mojang.blaze3d.platform.InputConstants;
|
| 13 | import com.mojang.blaze3d.platform.MacosUtil;
|
| 14 | import com.mojang.blaze3d.platform.Window;
|
| 15 | import com.mojang.blaze3d.systems.RenderSystem;
|
| 16 | import com.mojang.datafixers.util.Pair;
|
| 17 | import com.mojang.logging.LogUtils;
|
| 18 | import com.mojang.serialization.Codec;
|
| 19 | import com.mojang.serialization.JsonOps;
|
| 20 | import java.io.BufferedReader;
|
| 21 | import java.io.File;
|
| 22 | import java.io.FileOutputStream;
|
| 23 | import java.io.OutputStreamWriter;
|
| 24 | import java.io.PrintWriter;
|
| 25 | import java.nio.charset.StandardCharsets;
|
| 26 | import java.util.ArrayList;
|
| 27 | import java.util.Arrays;
|
| 28 | import java.util.Comparator;
|
| 29 | import java.util.EnumSet;
|
| 30 | import java.util.Iterator;
|
| 31 | import java.util.List;
|
| 32 | import java.util.Locale;
|
| 33 | import java.util.Map;
|
| 34 | import java.util.Objects;
|
| 35 | import java.util.Optional;
|
| 36 | import java.util.Set;
|
| 37 | import java.util.function.Consumer;
|
| 38 | import java.util.function.Function;
|
| 39 | import java.util.stream.Collectors;
|
| 40 | import java.util.stream.Stream;
|
| 41 | import net.fabricmc.api.EnvType;
|
| 42 | import net.fabricmc.api.Environment;
|
| 43 | import net.minecraft.SharedConstants;
|
| 44 | import net.minecraft.client.gui.components.ChatComponent;
|
| 45 | import net.minecraft.client.gui.components.Tooltip;
|
| 46 | import net.minecraft.client.gui.screens.options.OptionsSubScreen;
|
| 47 | import net.minecraft.client.input.InputQuirks;
|
| 48 | import net.minecraft.client.player.LocalPlayer;
|
| 49 | import net.minecraft.client.renderer.extract.LevelExtractor;
|
| 50 | import net.minecraft.client.resources.sounds.SimpleSoundInstance;
|
| 51 | import net.minecraft.client.sounds.MusicManager;
|
| 52 | import net.minecraft.client.sounds.SoundEngine;
|
| 53 | import net.minecraft.client.sounds.SoundManager;
|
| 54 | import net.minecraft.client.sounds.SoundPreviewHandler;
|
| 55 | import net.minecraft.client.tutorial.TutorialSteps;
|
| 56 | import net.minecraft.nbt.CompoundTag;
|
| 57 | import net.minecraft.nbt.StringTag;
|
| 58 | import net.minecraft.nbt.Tag;
|
| 59 | import net.minecraft.network.chat.CommonComponents;
|
| 60 | import net.minecraft.network.chat.Component;
|
| 61 | import net.minecraft.server.level.ClientInformation;
|
| 62 | import net.minecraft.server.level.ParticleStatus;
|
| 63 | import net.minecraft.server.packs.repository.Pack;
|
| 64 | import net.minecraft.server.packs.repository.PackRepository;
|
| 65 | import net.minecraft.sounds.SoundEvents;
|
| 66 | import net.minecraft.sounds.SoundSource;
|
| 67 | import net.minecraft.util.ARGB;
|
| 68 | import net.minecraft.util.GsonHelper;
|
| 69 | import net.minecraft.util.LenientJsonParser;
|
| 70 | import net.minecraft.util.Mth;
|
| 71 | import net.minecraft.util.Util;
|
| 72 | import net.minecraft.util.Util.OS;
|
| 73 | import net.minecraft.util.datafix.DataFixTypes;
|
| 74 | import net.minecraft.world.entity.HumanoidArm;
|
| 75 | import net.minecraft.world.entity.player.ChatVisiblity;
|
| 76 | import net.minecraft.world.entity.player.PlayerModelPart;
|
| 77 | import org.jspecify.annotations.Nullable;
|
| 78 | import org.slf4j.Logger;
|
| 79 |
|
| 80 | @Environment(EnvType.CLIENT)
|
| 81 | public class Options {
|
| 82 | private static final Logger LOGGER = LogUtils.getLogger();
|
| 83 | private static final Gson GSON = new Gson();
|
| 84 | private static final TypeToken<List<String>> LIST_OF_STRINGS_TYPE = new TypeToken<List<String>>() {};
|
| 85 | public static final int RENDER_DISTANCE_SHORT = 4;
|
| 86 | public static final int RENDER_DISTANCE_FAR = 12;
|
| 87 | public static final int RENDER_DISTANCE_REALLY_FAR = 16;
|
| 88 | public static final int RENDER_DISTANCE_EXTREME = 32;
|
| 89 | private static final Splitter OPTION_SPLITTER = Splitter.on(':').limit(2);
|
| 90 | private static final String DEFAULT_SOUND_DEVICE = "";
|
| 91 | private static final Component TOOLTIP_NEEDS_RESTART = Component.translatable("options.needsRestart");
|
| 92 | private static final Component ACCESSIBILITY_TOOLTIP_DARK_MOJANG_BACKGROUND = Component.translatable("options.darkMojangStudiosBackgroundColor.tooltip");
|
| 93 | private final OptionInstance<Boolean> darkMojangStudiosBackground = OptionInstance.createBoolean(
|
| 94 | "options.darkMojangStudiosBackgroundColor", OptionInstance.cachedConstantTooltip(ACCESSIBILITY_TOOLTIP_DARK_MOJANG_BACKGROUND), false
|
| 95 | );
|
| 96 | private static final Component ACCESSIBILITY_TOOLTIP_HIDE_LIGHTNING_FLASHES = Component.translatable("options.hideLightningFlashes.tooltip");
|
| 97 | private final OptionInstance<Boolean> hideLightningFlash = OptionInstance.createBoolean(
|
| 98 | "options.hideLightningFlashes", OptionInstance.cachedConstantTooltip(ACCESSIBILITY_TOOLTIP_HIDE_LIGHTNING_FLASHES), false
|
| 99 | );
|
| 100 | private static final Component ACCESSIBILITY_TOOLTIP_HIDE_SPLASH_TEXTS = Component.translatable("options.hideSplashTexts.tooltip");
|
| 101 | private final OptionInstance<Boolean> hideSplashTexts = OptionInstance.createBoolean(
|
| 102 | "options.hideSplashTexts", OptionInstance.cachedConstantTooltip(ACCESSIBILITY_TOOLTIP_HIDE_SPLASH_TEXTS), false
|
| 103 | );
|
| 104 | private final OptionInstance<Double> sensitivity = new OptionInstance<>("options.sensitivity", OptionInstance.noTooltip(), (caption, value) -> {
|
| 105 | if (value == 0.0) {
|
| 106 | return genericValueLabel(caption, Component.translatable("options.sensitivity.min"));
|
| 107 | } else {
|
| 108 | return value == 1.0 ? genericValueLabel(caption, Component.translatable("options.sensitivity.max")) : percentValueLabel(caption, 2.0 * value);
|
| 109 | }
|
| 110 | }, OptionInstance.UnitDouble.INSTANCE, 0.5, OptionInstance.NO_ACTION);
|
| 111 | private final OptionInstance<Integer> renderDistance;
|
| 112 | private final OptionInstance<Integer> simulationDistance;
|
| 113 | private int serverRenderDistance = 0;
|
| 114 | private final OptionInstance<Double> entityDistanceScaling = new OptionInstance<>(
|
| 115 | "options.entityDistanceScaling",
|
| 116 | OptionInstance.noTooltip(),
|
| 117 | Options::percentValueLabel,
|
| 118 | new OptionInstance.IntRange(2, 20).xmap(value -> value / 4.0, value -> (int)(value * 4.0), true),
|
| 119 | Codec.doubleRange(0.5, 5.0),
|
| 120 | 1.0,
|
| 121 | var1 -> this.setGraphicsPresetToCustom()
|
| 122 | );
|
| 123 | public static final int UNLIMITED_FRAMERATE_CUTOFF = 260;
|
| 124 | private final OptionInstance<Integer> framerateLimit = new OptionInstance<>(
|
| 125 | "options.framerateLimit",
|
| 126 | OptionInstance.noTooltip(),
|
| 127 | (caption, value) -> value == 260
|
| 128 | ? genericValueLabel(caption, Component.translatable("options.framerateLimit.max"))
|
| 129 | : genericValueLabel(caption, Component.translatable("options.framerate", value)),
|
| 130 | new OptionInstance.IntRange(1, 26).xmap(value -> value * 10, value -> value / 10, true),
|
| 131 | Codec.intRange(10, 260),
|
| 132 | 120,
|
| 133 | value -> Minecraft.getInstance().getFramerateLimitTracker().setFramerateLimit(value)
|
| 134 | );
|
| 135 | private PreferredGraphicsApi preferredGraphicsBackendFromStartup = PreferredGraphicsApi.DEFAULT;
|
| 136 | private static final Component GRAPHICS_API_TOOLTIP = Component.translatable("options.graphicsApi.tooltip");
|
| 137 | private static final Component GRAPHICS_API_TOOLTIP_VULKAN = Component.translatable("options.graphicsApi.tooltip.vulkan");
|
| 138 | private final OptionInstance<PreferredGraphicsApi> preferredGraphicsBackend = new OptionInstance<>(
|
| 139 | "options.graphicsApi",
|
| 140 | value -> {
|
| 141 | List<Component> tooltipLines = new ArrayList<>();
|
| 142 | if (value != this.preferredGraphicsBackendFromStartup) {
|
| 143 | tooltipLines.add(TOOLTIP_NEEDS_RESTART);
|
| 144 | tooltipLines.add(CommonComponents.EMPTY);
|
| 145 | }
|
| 146 |
|
| 147 | tooltipLines.add(GRAPHICS_API_TOOLTIP);
|
| 148 | if (value == PreferredGraphicsApi.VULKAN) {
|
| 149 | tooltipLines.add(CommonComponents.EMPTY);
|
| 150 | tooltipLines.add(GRAPHICS_API_TOOLTIP_VULKAN);
|
| 151 | }
|
| 152 |
|
| 153 | return Tooltip.create(CommonComponents.joinLines(tooltipLines));
|
| 154 | },
|
| 155 | (caption, value) -> ((PreferredGraphicsApi)value).caption(),
|
| 156 | new OptionInstance.Enum<>(List.of(PreferredGraphicsApi.values()), PreferredGraphicsApi.CODEC),
|
| 157 | PreferredGraphicsApi.CODEC,
|
| 158 | PreferredGraphicsApi.DEFAULT,
|
| 159 | OptionInstance.NO_ACTION
|
| 160 | );
|
| 161 | private boolean isApplyingGraphicsPreset;
|
| 162 | private final OptionInstance<GraphicsPreset> graphicsPreset = new OptionInstance<>(
|
| 163 | "options.graphics.preset",
|
| 164 | OptionInstance.cachedConstantTooltip(Component.translatable("options.graphics.preset.tooltip")),
|
| 165 | (caption, value) -> genericValueLabel(caption, Component.translatable(value.getKey())),
|
| 166 | new OptionInstance.SliderableEnum<>(List.of(GraphicsPreset.values()), GraphicsPreset.CODEC),
|
| 167 | GraphicsPreset.CODEC,
|
| 168 | GraphicsPreset.FANCY,
|
| 169 | this::applyGraphicsPreset
|
| 170 | );
|
| 171 | private static final Component INACTIVITY_FPS_LIMIT_TOOLTIP_MINIMIZED = Component.translatable("options.inactivityFpsLimit.minimized.tooltip");
|
| 172 | private static final Component INACTIVITY_FPS_LIMIT_TOOLTIP_AFK = Component.translatable("options.inactivityFpsLimit.afk.tooltip");
|
| 173 | private final OptionInstance<InactivityFpsLimit> inactivityFpsLimit = new OptionInstance<>(
|
| 174 | "options.inactivityFpsLimit",
|
| 175 | value -> {
|
| 176 | return switch (value) {
|
| 177 | case MINIMIZED -> Tooltip.create(INACTIVITY_FPS_LIMIT_TOOLTIP_MINIMIZED);
|
| 178 | case AFK -> Tooltip.create(INACTIVITY_FPS_LIMIT_TOOLTIP_AFK);
|
| 179 | };
|
| 180 | },
|
| 181 | (caption, value) -> ((InactivityFpsLimit)value).caption(),
|
| 182 | new OptionInstance.Enum<>(Arrays.asList(InactivityFpsLimit.values()), InactivityFpsLimit.CODEC),
|
| 183 | InactivityFpsLimit.AFK,
|
| 184 | OptionInstance.NO_ACTION
|
| 185 | );
|
| 186 | private final OptionInstance<CloudStatus> cloudStatus = new OptionInstance<>(
|
| 187 | "options.renderClouds",
|
| 188 | OptionInstance.noTooltip(),
|
| 189 | (caption, value) -> value.caption(),
|
| 190 | new OptionInstance.Enum<>(
|
| 191 | Arrays.asList(CloudStatus.values()), Codec.withAlternative(CloudStatus.CODEC, Codec.BOOL, b -> b ? CloudStatus.FANCY : CloudStatus.OFF)
|
| 192 | ),
|
| 193 | CloudStatus.FANCY,
|
| 194 | var1 -> this.setGraphicsPresetToCustom()
|
| 195 | );
|
| 196 | private final OptionInstance<Integer> cloudRange = new OptionInstance<>(
|
| 197 | "options.renderCloudsDistance",
|
| 198 | OptionInstance.noTooltip(),
|
| 199 | (caption, value) -> genericValueLabel(caption, Component.translatable("options.chunks", value)),
|
| 200 | new OptionInstance.IntRange(2, 128, true),
|
| 201 | 128,
|
| 202 | var1 -> {
|
| 203 | operateOnLevelExtractor(LevelExtractor::allChanged);
|
| 204 | this.setGraphicsPresetToCustom();
|
| 205 | }
|
| 206 | );
|
| 207 | private static final Component GRAPHICS_TOOLTIP_WEATHER_RADIUS = Component.translatable("options.weatherRadius.tooltip");
|
| 208 | private final OptionInstance<Integer> weatherRadius = new OptionInstance<>(
|
| 209 | "options.weatherRadius",
|
| 210 | OptionInstance.cachedConstantTooltip(GRAPHICS_TOOLTIP_WEATHER_RADIUS),
|
| 211 | (caption, value) -> genericValueLabel(caption, Component.translatable("options.blocks", value)),
|
| 212 | new OptionInstance.IntRange(3, 10, true),
|
| 213 | 10,
|
| 214 | var1 -> this.setGraphicsPresetToCustom()
|
| 215 | );
|
| 216 | private static final Component GRAPHICS_TOOLTIP_CUTOUT_LEAVES = Component.translatable("options.cutoutLeaves.tooltip");
|
| 217 | private final OptionInstance<Boolean> cutoutLeaves = OptionInstance.createBoolean(
|
| 218 | "options.cutoutLeaves", OptionInstance.cachedConstantTooltip(GRAPHICS_TOOLTIP_CUTOUT_LEAVES), true, var1 -> {
|
| 219 | operateOnLevelExtractor(LevelExtractor::allChanged);
|
| 220 | this.setGraphicsPresetToCustom();
|
| 221 | }
|
| 222 | );
|
| 223 | private static final Component GRAPHICS_TOOLTIP_VIGNETTE = Component.translatable("options.vignette.tooltip");
|
| 224 | private final OptionInstance<Boolean> vignette = OptionInstance.createBoolean(
|
| 225 | "options.vignette", OptionInstance.cachedConstantTooltip(GRAPHICS_TOOLTIP_VIGNETTE), true
|
| 226 | );
|
| 227 | private static final Component GRAPHICS_TOOLTIP_IMPROVED_TRANSPARENCY = Component.translatable("options.improvedTransparency.oit.tooltip");
|
| 228 | private final OptionInstance<Boolean> improvedTransparency = OptionInstance.createBoolean(
|
| 229 | "options.improvedTransparency", OptionInstance.cachedConstantTooltip(GRAPHICS_TOOLTIP_IMPROVED_TRANSPARENCY), false, value -> {
|
| 230 | operateOnLevelExtractor(LevelExtractor::allChanged);
|
| 231 | this.setGraphicsPresetToCustom();
|
| 232 | }
|
| 233 | );
|
| 234 | private final OptionInstance<Boolean> ambientOcclusion = OptionInstance.createBoolean("options.ao", true, var1 -> {
|
| 235 | operateOnLevelExtractor(LevelExtractor::allChanged);
|
| 236 | this.setGraphicsPresetToCustom();
|
| 237 | });
|
| 238 | private static final Component GRAPHICS_TOOLTIP_CHUNK_FADE = Component.translatable("options.chunkFade.tooltip");
|
| 239 | private final OptionInstance<Double> chunkSectionFadeInTime = new OptionInstance<>(
|
| 240 | "options.chunkFade",
|
| 241 | OptionInstance.cachedConstantTooltip(GRAPHICS_TOOLTIP_CHUNK_FADE),
|
| 242 | (caption, value) -> value <= 0.0
|
| 243 | ? Component.translatable("options.chunkFade.none")
|
| 244 | : Component.translatable("options.chunkFade.seconds", String.format(Locale.ROOT, "%.2f", value)),
|
| 245 | new OptionInstance.IntRange(0, 40).xmap(value -> value / 20.0, value -> (int)(value * 20.0), true),
|
| 246 | Codec.doubleRange(0.0, 2.0),
|
| 247 | 0.75,
|
| 248 | OptionInstance.NO_ACTION
|
| 249 | );
|
| 250 | private static final Component PRIORITIZE_CHUNK_TOOLTIP_NONE = Component.translatable("options.prioritizeChunkUpdates.none.tooltip");
|
| 251 | private static final Component PRIORITIZE_CHUNK_TOOLTIP_PLAYER_AFFECTED = Component.translatable("options.prioritizeChunkUpdates.byPlayer.tooltip");
|
| 252 | private static final Component PRIORITIZE_CHUNK_TOOLTIP_NEARBY = Component.translatable("options.prioritizeChunkUpdates.nearby.tooltip");
|
| 253 | private final OptionInstance<PrioritizeChunkUpdates> prioritizeChunkUpdates = new OptionInstance<>(
|
| 254 | "options.prioritizeChunkUpdates",
|
| 255 | value -> {
|
| 256 | return switch (value) {
|
| 257 | case NONE -> Tooltip.create(PRIORITIZE_CHUNK_TOOLTIP_NONE);
|
| 258 | case PLAYER_AFFECTED -> Tooltip.create(PRIORITIZE_CHUNK_TOOLTIP_PLAYER_AFFECTED);
|
| 259 | case NEARBY -> Tooltip.create(PRIORITIZE_CHUNK_TOOLTIP_NEARBY);
|
| 260 | };
|
| 261 | },
|
| 262 | (caption, value) -> value.caption(),
|
| 263 | new OptionInstance.Enum<>(Arrays.asList(PrioritizeChunkUpdates.values()), PrioritizeChunkUpdates.LEGACY_CODEC),
|
| 264 | PrioritizeChunkUpdates.NONE,
|
| 265 | var1 -> this.setGraphicsPresetToCustom()
|
| 266 | );
|
| 267 | public List<String> resourcePacks = Lists.newArrayList();
|
| 268 | public List<String> incompatibleResourcePacks = Lists.newArrayList();
|
| 269 | private final OptionInstance<ChatVisiblity> chatVisibility = new OptionInstance<>(
|
| 270 | "options.chat.visibility",
|
| 271 | OptionInstance.noTooltip(),
|
| 272 | (caption, value) -> value.caption(),
|
| 273 | new OptionInstance.Enum<>(Arrays.asList(ChatVisiblity.values()), ChatVisiblity.LEGACY_CODEC),
|
| 274 | ChatVisiblity.FULL,
|
| 275 | var0 -> {
|
| 276 | LocalPlayer player = Minecraft.getInstance().player;
|
| 277 | if (player != null) {
|
| 278 | player.refreshChatAbilities();
|
| 279 | }
|
| 280 | }
|
| 281 | );
|
| 282 | private final OptionInstance<Double> chatOpacity = new OptionInstance<>(
|
| 283 | "options.chat.opacity",
|
| 284 | OptionInstance.noTooltip(),
|
| 285 | (caption, value) -> percentValueLabel(caption, value * 0.9 + 0.1),
|
| 286 | OptionInstance.UnitDouble.INSTANCE,
|
| 287 | 1.0,
|
| 288 | var0 -> Minecraft.getInstance().gui.hud.getChat().rescaleChat()
|
| 289 | );
|
| 290 | private final OptionInstance<Double> chatLineSpacing = new OptionInstance<>(
|
| 291 | "options.chat.line_spacing", OptionInstance.noTooltip(), Options::percentValueLabel, OptionInstance.UnitDouble.INSTANCE, 0.0, OptionInstance.NO_ACTION
|
| 292 | );
|
| 293 | private static final Component MENU_BACKGROUND_BLURRINESS_TOOLTIP = Component.translatable("options.accessibility.menu_background_blurriness.tooltip");
|
| 294 | private static final int BLURRINESS_DEFAULT_VALUE = 5;
|
| 295 | private final OptionInstance<Integer> menuBackgroundBlurriness = new OptionInstance<>(
|
| 296 | "options.accessibility.menu_background_blurriness",
|
| 297 | OptionInstance.cachedConstantTooltip(MENU_BACKGROUND_BLURRINESS_TOOLTIP),
|
| 298 | Options::genericValueOrOffLabel,
|
| 299 | new OptionInstance.IntRange(0, 10),
|
| 300 | 5,
|
| 301 | var1 -> this.setGraphicsPresetToCustom()
|
| 302 | );
|
| 303 | private final OptionInstance<Double> textBackgroundOpacity = new OptionInstance<>(
|
| 304 | "options.accessibility.text_background_opacity",
|
| 305 | OptionInstance.noTooltip(),
|
| 306 | Options::percentValueLabel,
|
| 307 | OptionInstance.UnitDouble.INSTANCE,
|
| 308 | 0.5,
|
| 309 | var0 -> Minecraft.getInstance().gui.hud.getChat().rescaleChat()
|
| 310 | );
|
| 311 | private final OptionInstance<Double> panoramaSpeed = new OptionInstance<>(
|
| 312 | "options.accessibility.panorama_speed",
|
| 313 | OptionInstance.noTooltip(),
|
| 314 | Options::percentValueLabel,
|
| 315 | OptionInstance.UnitDouble.INSTANCE,
|
| 316 | 1.0,
|
| 317 | OptionInstance.NO_ACTION
|
| 318 | );
|
| 319 | private static final Component ACCESSIBILITY_TOOLTIP_CONTRAST_MODE = Component.translatable("options.accessibility.high_contrast.tooltip");
|
| 320 | private final OptionInstance<Boolean> highContrast = OptionInstance.createBoolean(
|
| 321 | "options.accessibility.high_contrast", OptionInstance.cachedConstantTooltip(ACCESSIBILITY_TOOLTIP_CONTRAST_MODE), false, value -> {
|
| 322 | PackRepository packRepo = Minecraft.getInstance().getResourcePackRepository();
|
| 323 | boolean isSelected = packRepo.getSelectedIds().contains("high_contrast");
|
| 324 | if (!isSelected && value) {
|
| 325 | if (packRepo.addPack("high_contrast")) {
|
| 326 | this.updateResourcePacks(packRepo);
|
| 327 | }
|
| 328 | } else if (isSelected && !value && packRepo.removePack("high_contrast")) {
|
| 329 | this.updateResourcePacks(packRepo);
|
| 330 | }
|
| 331 | }
|
| 332 | );
|
| 333 | private static final Component HIGH_CONTRAST_BLOCK_OUTLINE_TOOLTIP = Component.translatable("options.accessibility.high_contrast_block_outline.tooltip");
|
| 334 | private final OptionInstance<Boolean> highContrastBlockOutline = OptionInstance.createBoolean(
|
| 335 | "options.accessibility.high_contrast_block_outline", OptionInstance.cachedConstantTooltip(HIGH_CONTRAST_BLOCK_OUTLINE_TOOLTIP), false
|
| 336 | );
|
| 337 | private final OptionInstance<Boolean> narratorHotkey = OptionInstance.createBoolean(
|
| 338 | "options.accessibility.narrator_hotkey",
|
| 339 | OptionInstance.cachedConstantTooltip(
|
| 340 | InputQuirks.REPLACE_CTRL_KEY_WITH_CMD_KEY
|
| 341 | ? Component.translatable("options.accessibility.narrator_hotkey.mac.tooltip")
|
| 342 | : Component.translatable("options.accessibility.narrator_hotkey.tooltip")
|
| 343 | ),
|
| 344 | true
|
| 345 | );
|
| 346 | public @Nullable String fullscreenVideoModeString;
|
| 347 | public boolean hideServerAddress;
|
| 348 | public boolean advancedItemTooltips;
|
| 349 | public boolean pauseOnLostFocus = true;
|
| 350 | private final Set<PlayerModelPart> modelParts = EnumSet.allOf(PlayerModelPart.class);
|
| 351 | private final OptionInstance<HumanoidArm> mainHand = new OptionInstance<>(
|
| 352 | "options.mainHand",
|
| 353 | OptionInstance.noTooltip(),
|
| 354 | (caption, value) -> value.caption(),
|
| 355 | new OptionInstance.Enum<>(Arrays.asList(HumanoidArm.values()), HumanoidArm.CODEC),
|
| 356 | HumanoidArm.RIGHT,
|
| 357 | OptionInstance.NO_ACTION
|
| 358 | );
|
| 359 | public int overrideWidth;
|
| 360 | public int overrideHeight;
|
| 361 | private final OptionInstance<Double> chatScale = new OptionInstance<>(
|
| 362 | "options.chat.scale",
|
| 363 | OptionInstance.noTooltip(),
|
| 364 | (caption, value) -> value == 0.0 ? CommonComponents.optionStatus(caption, false) : percentValueLabel(caption, value),
|
| 365 | OptionInstance.UnitDouble.INSTANCE,
|
| 366 | 1.0,
|
| 367 | var0 -> Minecraft.getInstance().gui.hud.getChat().rescaleChat()
|
| 368 | );
|
| 369 | private final OptionInstance<Double> chatWidth = new OptionInstance<>(
|
| 370 | "options.chat.width",
|
| 371 | OptionInstance.noTooltip(),
|
| 372 | (caption, value) -> pixelValueLabel(caption, ChatComponent.getWidth(value)),
|
| 373 | OptionInstance.UnitDouble.INSTANCE,
|
| 374 | 1.0,
|
| 375 | var0 -> Minecraft.getInstance().gui.hud.getChat().rescaleChat()
|
| 376 | );
|
| 377 | private final OptionInstance<Double> chatHeightUnfocused = new OptionInstance<>(
|
| 378 | "options.chat.height.unfocused",
|
| 379 | OptionInstance.noTooltip(),
|
| 380 | (caption, value) -> pixelValueLabel(caption, ChatComponent.getHeight(value)),
|
| 381 | OptionInstance.UnitDouble.INSTANCE,
|
| 382 | ChatComponent.defaultUnfocusedPct(),
|
| 383 | var0 -> Minecraft.getInstance().gui.hud.getChat().rescaleChat()
|
| 384 | );
|
| 385 | private final OptionInstance<Double> chatHeightFocused = new OptionInstance<>(
|
| 386 | "options.chat.height.focused",
|
| 387 | OptionInstance.noTooltip(),
|
| 388 | (caption, value) -> pixelValueLabel(caption, ChatComponent.getHeight(value)),
|
| 389 | OptionInstance.UnitDouble.INSTANCE,
|
| 390 | 1.0,
|
| 391 | var0 -> Minecraft.getInstance().gui.hud.getChat().rescaleChat()
|
| 392 | );
|
| 393 | private final OptionInstance<Double> chatDelay = new OptionInstance<>(
|
| 394 | "options.chat.delay_instant",
|
| 395 | OptionInstance.noTooltip(),
|
| 396 | (caption, value) -> value <= 0.0
|
| 397 | ? Component.translatable("options.chat.delay_none")
|
| 398 | : Component.translatable("options.chat.delay", String.format(Locale.ROOT, "%.1f", value)),
|
| 399 | new OptionInstance.IntRange(0, 60).xmap(value -> value / 10.0, value -> (int)(value * 10.0), true),
|
| 400 | Codec.doubleRange(0.0, 6.0),
|
| 401 | 0.0,
|
| 402 | value -> Minecraft.getInstance().gui.chatListener().setMessageDelay(value)
|
| 403 | );
|
| 404 | private static final Component ACCESSIBILITY_TOOLTIP_NOTIFICATION_DISPLAY_TIME = Component.translatable("options.notifications.display_time.tooltip");
|
| 405 | private final OptionInstance<Double> notificationDisplayTime = new OptionInstance<>(
|
| 406 | "options.notifications.display_time",
|
| 407 | OptionInstance.cachedConstantTooltip(ACCESSIBILITY_TOOLTIP_NOTIFICATION_DISPLAY_TIME),
|
| 408 | (caption, value) -> genericValueLabel(caption, Component.translatable("options.multiplier", value)),
|
| 409 | new OptionInstance.IntRange(5, 100).xmap(value -> value / 10.0, value -> (int)(value * 10.0), true),
|
| 410 | Codec.doubleRange(0.5, 10.0),
|
| 411 | 1.0,
|
| 412 | OptionInstance.NO_ACTION
|
| 413 | );
|
| 414 | private final OptionInstance<Integer> mipmapLevels = new OptionInstance<>(
|
| 415 | "options.mipmapLevels",
|
| 416 | OptionInstance.noTooltip(),
|
| 417 | (caption, value) -> value == 0 ? CommonComponents.optionStatus(caption, false) : genericValueLabel(caption, value),
|
| 418 | new OptionInstance.IntRange(0, 4),
|
| 419 | 4,
|
| 420 | var1 -> this.setGraphicsPresetToCustom()
|
| 421 | );
|
| 422 | private static final Component GRAPHICS_TOOLTIP_ANISOTROPIC_FILTERING = Component.translatable("options.maxAnisotropy.tooltip");
|
| 423 | private final OptionInstance<Integer> maxAnisotropyBit = new OptionInstance<>(
|
| 424 | "options.maxAnisotropy",
|
| 425 | OptionInstance.cachedConstantTooltip(GRAPHICS_TOOLTIP_ANISOTROPIC_FILTERING),
|
| 426 | (caption, value) -> value == 0
|
| 427 | ? CommonComponents.optionStatus(caption, false)
|
| 428 | : genericValueLabel(caption, Component.translatable("options.multiplier", Integer.toString(1 << value))),
|
| 429 | new OptionInstance.IntRange(1, 3),
|
| 430 | 2,
|
| 431 | var1 -> {
|
| 432 | this.setGraphicsPresetToCustom();
|
| 433 | operateOnLevelExtractor(LevelExtractor::resetSampler);
|
| 434 | }
|
| 435 | );
|
| 436 | private static final Component FILTERING_NONE_TOOLTIP = Component.translatable("options.textureFiltering.none.tooltip");
|
| 437 | private static final Component FILTERING_RGSS_TOOLTIP = Component.translatable("options.textureFiltering.rgss.tooltip");
|
| 438 | private static final Component FILTERING_ANISOTROPIC_TOOLTIP = Component.translatable("options.textureFiltering.anisotropic.tooltip");
|
| 439 | private final OptionInstance<TextureFilteringMethod> textureFiltering = new OptionInstance<>(
|
| 440 | "options.textureFiltering",
|
| 441 | value -> {
|
| 442 | return switch (value) {
|
| 443 | case NONE -> Tooltip.create(FILTERING_NONE_TOOLTIP);
|
| 444 | case RGSS -> Tooltip.create(FILTERING_RGSS_TOOLTIP);
|
| 445 | case ANISOTROPIC -> Tooltip.create(FILTERING_ANISOTROPIC_TOOLTIP);
|
| 446 | };
|
| 447 | },
|
| 448 | (caption, value) -> value.caption(),
|
| 449 | new OptionInstance.Enum<>(Arrays.asList(TextureFilteringMethod.values()), TextureFilteringMethod.LEGACY_CODEC),
|
| 450 | TextureFilteringMethod.NONE,
|
| 451 | var1 -> {
|
| 452 | this.setGraphicsPresetToCustom();
|
| 453 | operateOnLevelExtractor(LevelExtractor::resetSampler);
|
| 454 | }
|
| 455 | );
|
| 456 | private boolean useNativeTransport = true;
|
| 457 | private final OptionInstance<AttackIndicatorStatus> attackIndicator = new OptionInstance<>(
|
| 458 | "options.attackIndicator",
|
| 459 | OptionInstance.noTooltip(),
|
| 460 | (caption, value) -> ((AttackIndicatorStatus)value).caption(),
|
| 461 | new OptionInstance.Enum<>(Arrays.asList(AttackIndicatorStatus.values()), AttackIndicatorStatus.LEGACY_CODEC),
|
| 462 | AttackIndicatorStatus.CROSSHAIR,
|
| 463 | OptionInstance.NO_ACTION
|
| 464 | );
|
| 465 | public TutorialSteps tutorialStep = TutorialSteps.MOVEMENT;
|
| 466 | public boolean joinedFirstServer = false;
|
| 467 | private final OptionInstance<Integer> biomeBlendRadius = new OptionInstance<>("options.biomeBlendRadius", OptionInstance.noTooltip(), (caption, value) -> {
|
| 468 | int dist = value * 2 + 1;
|
| 469 | return genericValueLabel(caption, Component.translatable("options.biomeBlendRadius." + dist));
|
| 470 | }, new OptionInstance.IntRange(0, 7, false), 2, var1 -> {
|
| 471 | operateOnLevelExtractor(LevelExtractor::allChanged);
|
| 472 | this.setGraphicsPresetToCustom();
|
| 473 | });
|
| 474 | private final OptionInstance<Double> mouseWheelSensitivity = new OptionInstance<>(
|
| 475 | "options.mouseWheelSensitivity",
|
| 476 | OptionInstance.noTooltip(),
|
| 477 | (caption, value) -> genericValueLabel(caption, Component.literal(String.format(Locale.ROOT, "%.2f", value))),
|
| 478 | new OptionInstance.IntRange(-200, 100).xmap(Options::logMouse, Options::unlogMouse, false),
|
| 479 | Codec.doubleRange(logMouse(-200), logMouse(100)),
|
| 480 | logMouse(0),
|
| 481 | OptionInstance.NO_ACTION
|
| 482 | );
|
| 483 | private static final Component ALLOW_CURSOR_CHANGES_TOOLTIP = Component.translatable("options.allowCursorChanges.tooltip");
|
| 484 | private final OptionInstance<Boolean> allowCursorChanges = OptionInstance.createBoolean(
|
| 485 | "options.allowCursorChanges", OptionInstance.cachedConstantTooltip(ALLOW_CURSOR_CHANGES_TOOLTIP), true, value -> {
|
| 486 | Window window = Minecraft.getInstance().getWindow();
|
| 487 | if (window != null) {
|
| 488 | window.setAllowCursorChanges(value);
|
| 489 | }
|
| 490 | }
|
| 491 | );
|
| 492 | private static final Component QUIT_SHORTCUTS_TOOLTIP = Component.translatable("options.quitShortcuts.tooltip");
|
| 493 | private final OptionInstance<Boolean> quitShortcuts = OptionInstance.createBoolean(
|
| 494 | "options.quitShortcuts", OptionInstance.cachedConstantTooltip(QUIT_SHORTCUTS_TOOLTIP), true, value -> {
|
| 495 | Window window = Minecraft.getInstance().getWindow();
|
| 496 | if (window != null) {
|
| 497 | window.setQuitShortcuts(value);
|
| 498 | }
|
| 499 | }
|
| 500 | );
|
| 501 | private static final Component CTRL_CLICK_EMULATES_RIGHT_CLICK_TOOLTIP = Component.translatable("options.ctrlClickEmulatesRightClick.tooltip");
|
| 502 | private final OptionInstance<Boolean> ctrlClickEmulatesRightClick = OptionInstance.createBoolean(
|
| 503 | "options.ctrlClickEmulatesRightClick",
|
| 504 | OptionInstance.cachedConstantTooltip(CTRL_CLICK_EMULATES_RIGHT_CLICK_TOOLTIP),
|
| 505 | false,
|
| 506 | MacosUtil::setCtrlClickEmulatesRightClick
|
| 507 | );
|
| 508 | public int glDebugVerbosity = 1;
|
| 509 | private final OptionInstance<Boolean> autoJump = OptionInstance.createBoolean("options.autoJump", false);
|
| 510 | private static final Component ACCESSIBILITY_TOOLTIP_ROTATE_WITH_MINECART = Component.translatable("options.rotateWithMinecart.tooltip");
|
| 511 | private final OptionInstance<Boolean> rotateWithMinecart = OptionInstance.createBoolean(
|
| 512 | "options.rotateWithMinecart", OptionInstance.cachedConstantTooltip(ACCESSIBILITY_TOOLTIP_ROTATE_WITH_MINECART), false
|
| 513 | );
|
| 514 | private final OptionInstance<Boolean> operatorItemsTab = OptionInstance.createBoolean("options.operatorItemsTab", false);
|
| 515 | private final OptionInstance<Boolean> autoSuggestions = OptionInstance.createBoolean("options.autoSuggestCommands", true);
|
| 516 | private final OptionInstance<Boolean> chatColors = OptionInstance.createBoolean("options.chat.color", true);
|
| 517 | private final OptionInstance<Boolean> chatLinks = OptionInstance.createBoolean("options.chat.links", true);
|
| 518 | private final OptionInstance<Boolean> chatLinksPrompt = OptionInstance.createBoolean("options.chat.links.prompt", true);
|
| 519 | private final OptionInstance<Boolean> enableVsync = OptionInstance.createBoolean(
|
| 520 | "options.vsync", true, var0 -> Minecraft.getInstance().invalidateSurfaceConfiguration()
|
| 521 | );
|
| 522 | private final OptionInstance<Boolean> entityShadows = OptionInstance.createBoolean(
|
| 523 | "options.entityShadows", OptionInstance.noTooltip(), true, var1 -> this.setGraphicsPresetToCustom()
|
| 524 | );
|
| 525 | private final OptionInstance<Boolean> forceUnicodeFont = OptionInstance.createBoolean("options.forceUnicodeFont", false, var0 -> updateFontOptions());
|
| 526 | private final OptionInstance<Boolean> japaneseGlyphVariants = OptionInstance.createBoolean(
|
| 527 | "options.japaneseGlyphVariants",
|
| 528 | OptionInstance.cachedConstantTooltip(Component.translatable("options.japaneseGlyphVariants.tooltip")),
|
| 529 | japaneseGlyphVariantsDefault(),
|
| 530 | var0 -> updateFontOptions()
|
| 531 | );
|
| 532 | private final OptionInstance<Boolean> invertXMouse = OptionInstance.createBoolean("options.invertMouseX", false);
|
| 533 | private final OptionInstance<Boolean> invertYMouse = OptionInstance.createBoolean("options.invertMouseY", false);
|
| 534 | private final OptionInstance<Boolean> discreteMouseScroll = OptionInstance.createBoolean("options.discrete_mouse_scroll", false);
|
| 535 | private static final Component REALMS_NOTIFICATIONS_TOOLTIP = Component.translatable("options.realmsNotifications.tooltip");
|
| 536 | private final OptionInstance<Boolean> realmsNotifications = OptionInstance.createBoolean(
|
| 537 | "options.realmsNotifications.button", OptionInstance.cachedConstantTooltip(REALMS_NOTIFICATIONS_TOOLTIP), true
|
| 538 | );
|
| 539 | private static final Component ALLOW_SERVER_LISTING_TOOLTIP = Component.translatable("options.allowServerListing.tooltip");
|
| 540 | private final OptionInstance<Boolean> allowServerListing = OptionInstance.createBoolean(
|
| 541 | "options.allowServerListing", OptionInstance.cachedConstantTooltip(ALLOW_SERVER_LISTING_TOOLTIP), true, OptionInstance.NO_ACTION
|
| 542 | );
|
| 543 | private final OptionInstance<Boolean> reducedDebugInfo = OptionInstance.createBoolean(
|
| 544 | "options.reducedDebugInfo", OptionInstance.noTooltip(), false, var0 -> Minecraft.getInstance().debugEntries.rebuildCurrentList()
|
| 545 | );
|
| 546 | private static final Component IN_GAME_NOTIFICATION_TOOLTIP = Component.translatable("options.inGameNotification.tooltip");
|
| 547 | private final OptionInstance<Boolean> inGameNotification = OptionInstance.createBoolean(
|
| 548 | "options.inGameNotification", OptionInstance.cachedConstantTooltip(IN_GAME_NOTIFICATION_TOOLTIP), false
|
| 549 | );
|
| 550 | private final OptionInstance<PresenceSharing> sharePresence = new OptionInstance<>(
|
| 551 | "options.sharePresence",
|
| 552 | value -> Tooltip.create(value.getTooltip()),
|
| 553 | (var0, value) -> value.getTranslation(),
|
| 554 | new OptionInstance.Enum<>(List.of(PresenceSharing.values()), PresenceSharing.CODEC),
|
| 555 | PresenceSharing.CODEC,
|
| 556 | PresenceSharing.ALL,
|
| 557 | var0 -> {}
|
| 558 | );
|
| 559 | private final Map<SoundSource, OptionInstance<Double>> soundSourceVolumes = Util.makeEnumMap(
|
| 560 | SoundSource.class, source -> this.createSoundSliderOptionInstance("soundCategory." + source.getName(), source)
|
| 561 | );
|
| 562 | private static final Component CLOSED_CAPTIONS_TOOLTIP = Component.translatable("options.showSubtitles.tooltip");
|
| 563 | private final OptionInstance<Boolean> showSubtitles = OptionInstance.createBoolean(
|
| 564 | "options.showSubtitles", OptionInstance.cachedConstantTooltip(CLOSED_CAPTIONS_TOOLTIP), false
|
| 565 | );
|
| 566 | private static final Component DIRECTIONAL_AUDIO_TOOLTIP_ON = Component.translatable("options.directionalAudio.on.tooltip");
|
| 567 | private static final Component DIRECTIONAL_AUDIO_TOOLTIP_OFF = Component.translatable("options.directionalAudio.off.tooltip");
|
| 568 | private final OptionInstance<Boolean> directionalAudio = OptionInstance.createBoolean(
|
| 569 | "options.directionalAudio", value -> value ? Tooltip.create(DIRECTIONAL_AUDIO_TOOLTIP_ON) : Tooltip.create(DIRECTIONAL_AUDIO_TOOLTIP_OFF), false, var0 -> {
|
| 570 | SoundManager soundManager = Minecraft.getInstance().getSoundManager();
|
| 571 | soundManager.reload();
|
| 572 | soundManager.play(SimpleSoundInstance.forUI(SoundEvents.UI_BUTTON_CLICK, 1.0F));
|
| 573 | }
|
| 574 | );
|
| 575 | private final OptionInstance<Boolean> backgroundForChatOnly = new OptionInstance<>(
|
| 576 | "options.accessibility.text_background",
|
| 577 | OptionInstance.noTooltip(),
|
| 578 | (caption, value) -> value
|
| 579 | ? Component.translatable("options.accessibility.text_background.chat")
|
| 580 | : Component.translatable("options.accessibility.text_background.everywhere"),
|
| 581 | OptionInstance.BOOLEAN_VALUES,
|
| 582 | true,
|
| 583 | OptionInstance.NO_ACTION
|
| 584 | );
|
| 585 | private final OptionInstance<Boolean> fullscreen = OptionInstance.createBoolean("options.fullscreen", false, value -> {
|
| 586 | Window window = Minecraft.getInstance().getWindow();
|
| 587 | if (window != null) {
|
| 588 | window.setFullscreen(value);
|
| 589 | }
|
| 590 | });
|
| 591 | private static final Component TOOLTIP_EXCLUSIVE_FULLSCREEN_ON = Component.translatable("options.exclusiveFullscreen.on.tooltip");
|
| 592 | private static final Component TOOLTIP_EXCLUSIVE_FULLSCREEN_OFF = Component.translatable("options.exclusiveFullscreen.off.tooltip");
|
| 593 | private final OptionInstance<Boolean> exclusiveFullscreen = OptionInstance.createBoolean(
|
| 594 | "options.exclusiveFullscreen",
|
| 595 | value -> Tooltip.create(value ? TOOLTIP_EXCLUSIVE_FULLSCREEN_ON : TOOLTIP_EXCLUSIVE_FULLSCREEN_OFF),
|
| 596 | false,
|
| 597 | value -> Minecraft.getInstance().getWindow().setExclusiveFullscreen(value)
|
| 598 | );
|
| 599 | private static final Component MAC_FULLSCREEN_MENU_VISIBILITY_TOOLTIP = Component.translatable("options.macFullscreenMenuVisibility.tooltip");
|
| 600 | private final OptionInstance<Boolean> macFullscreenMenuVisibility = OptionInstance.createBoolean(
|
| 601 | "options.macFullscreenMenuVisibility",
|
| 602 | OptionInstance.cachedConstantTooltip(MAC_FULLSCREEN_MENU_VISIBILITY_TOOLTIP),
|
| 603 | false,
|
| 604 | MacosUtil::setFullscreenMenuVisibility
|
| 605 | );
|
| 606 | private final OptionInstance<Boolean> bobView = OptionInstance.createBoolean("options.viewBobbing", true);
|
| 607 | private static final Component KEY_TOGGLE = Component.translatable("options.key.toggle");
|
| 608 | private static final Component KEY_HOLD = Component.translatable("options.key.hold");
|
| 609 | private final OptionInstance<Boolean> toggleCrouch = new OptionInstance<>(
|
| 610 | "key.sneak", OptionInstance.noTooltip(), (caption, value) -> value ? KEY_TOGGLE : KEY_HOLD, OptionInstance.BOOLEAN_VALUES, false, OptionInstance.NO_ACTION
|
| 611 | );
|
| 612 | private final OptionInstance<Boolean> toggleSprint = new OptionInstance<>(
|
| 613 | "key.sprint", OptionInstance.noTooltip(), (caption, value) -> value ? KEY_TOGGLE : KEY_HOLD, OptionInstance.BOOLEAN_VALUES, false, OptionInstance.NO_ACTION
|
| 614 | );
|
| 615 | private final OptionInstance<Boolean> toggleAttack = new OptionInstance<>(
|
| 616 | "key.attack", OptionInstance.noTooltip(), (caption, value) -> value ? KEY_TOGGLE : KEY_HOLD, OptionInstance.BOOLEAN_VALUES, false, OptionInstance.NO_ACTION
|
| 617 | );
|
| 618 | private final OptionInstance<Boolean> toggleUse = new OptionInstance<>(
|
| 619 | "key.use", OptionInstance.noTooltip(), (caption, value) -> value ? KEY_TOGGLE : KEY_HOLD, OptionInstance.BOOLEAN_VALUES, false, OptionInstance.NO_ACTION
|
| 620 | );
|
| 621 | private static final Component SPRINT_WINDOW_TOOLTIP = Component.translatable("options.sprintWindow.tooltip");
|
| 622 | private final OptionInstance<Integer> sprintWindow = new OptionInstance<>(
|
| 623 | "options.sprintWindow",
|
| 624 | OptionInstance.cachedConstantTooltip(SPRINT_WINDOW_TOOLTIP),
|
| 625 | (caption, value) -> value == 0
|
| 626 | ? genericValueLabel(caption, Component.translatable("options.off"))
|
| 627 | : genericValueLabel(caption, Component.translatable("options.value", value)),
|
| 628 | new OptionInstance.IntRange(0, 10),
|
| 629 | 7,
|
| 630 | OptionInstance.NO_ACTION
|
| 631 | );
|
| 632 | public boolean skipMultiplayerWarning;
|
| 633 | private static final Component CHAT_TOOLTIP_HIDE_MATCHED_NAMES = Component.translatable("options.hideMatchedNames.tooltip");
|
| 634 | private final OptionInstance<Boolean> hideMatchedNames = OptionInstance.createBoolean(
|
| 635 | "options.hideMatchedNames", OptionInstance.cachedConstantTooltip(CHAT_TOOLTIP_HIDE_MATCHED_NAMES), true
|
| 636 | );
|
| 637 | private final OptionInstance<Boolean> showAutosaveIndicator = OptionInstance.createBoolean("options.autosaveIndicator", true);
|
| 638 | private static final Component CHAT_TOOLTIP_ONLY_SHOW_SECURE = Component.translatable("options.onlyShowSecureChat.tooltip");
|
| 639 | private final OptionInstance<Boolean> onlyShowSecureChat = OptionInstance.createBoolean(
|
| 640 | "options.onlyShowSecureChat", OptionInstance.cachedConstantTooltip(CHAT_TOOLTIP_ONLY_SHOW_SECURE), false
|
| 641 | );
|
| 642 | private static final Component CHAT_TOOLTIP_SAVE_DRAFTS = Component.translatable("options.chat.drafts.tooltip");
|
| 643 | private final OptionInstance<Boolean> saveChatDrafts = OptionInstance.createBoolean(
|
| 644 | "options.chat.drafts", OptionInstance.cachedConstantTooltip(CHAT_TOOLTIP_SAVE_DRAFTS), false
|
| 645 | );
|
| 646 | public final KeyMapping keyUp = new KeyMapping("key.forward", 26, KeyMapping.Category.MOVEMENT);
|
| 647 | public final KeyMapping keyLeft = new KeyMapping("key.left", 4, KeyMapping.Category.MOVEMENT);
|
| 648 | public final KeyMapping keyDown = new KeyMapping("key.back", 22, KeyMapping.Category.MOVEMENT);
|
| 649 | public final KeyMapping keyRight = new KeyMapping("key.right", 7, KeyMapping.Category.MOVEMENT);
|
| 650 | public final KeyMapping keyJump = new KeyMapping("key.jump", 44, KeyMapping.Category.MOVEMENT);
|
| 651 | public final KeyMapping keyShift = new ToggleKeyMapping("key.sneak", 225, KeyMapping.Category.MOVEMENT, this.toggleCrouch::get, true);
|
| 652 | public final KeyMapping keySprint = new ToggleKeyMapping("key.sprint", 224, KeyMapping.Category.MOVEMENT, this.toggleSprint::get, true);
|
| 653 | public final KeyMapping keyInventory = new KeyMapping("key.inventory", 8, KeyMapping.Category.INVENTORY);
|
| 654 | public final KeyMapping keySwapOffhand = new KeyMapping("key.swapOffhand", 9, KeyMapping.Category.INVENTORY);
|
| 655 | public final KeyMapping keyDrop = new KeyMapping("key.drop", 20, KeyMapping.Category.INVENTORY);
|
| 656 | public final KeyMapping keyUse = new ToggleKeyMapping("key.use", InputConstants.Type.MOUSE, 3, KeyMapping.Category.GAMEPLAY, this.toggleUse::get, false);
|
| 657 | public final KeyMapping keyAttack = new ToggleKeyMapping(
|
| 658 | "key.attack", InputConstants.Type.MOUSE, 1, KeyMapping.Category.GAMEPLAY, this.toggleAttack::get, true
|
| 659 | );
|
| 660 | public final KeyMapping keyPickItem = new KeyMapping("key.pickItem", InputConstants.Type.MOUSE, 2, KeyMapping.Category.GAMEPLAY);
|
| 661 | public final KeyMapping keyChat = new KeyMapping("key.chat", 23, KeyMapping.Category.MULTIPLAYER);
|
| 662 | public final KeyMapping keyPlayerList = new KeyMapping("key.playerlist", 43, KeyMapping.Category.MULTIPLAYER);
|
| 663 | public final KeyMapping keyCommand = new KeyMapping("key.command", 56, KeyMapping.Category.MULTIPLAYER);
|
| 664 | public final KeyMapping keyFriends = new KeyMapping("key.friends", 18, KeyMapping.Category.MULTIPLAYER);
|
| 665 | public final KeyMapping keySocialInteractions = new KeyMapping("key.socialInteractions", 19, KeyMapping.Category.MULTIPLAYER);
|
| 666 | public final KeyMapping keyScreenshot = new KeyMapping("key.screenshot", 59, KeyMapping.Category.MISC);
|
| 667 | public final KeyMapping keyTogglePerspective = new KeyMapping("key.togglePerspective", 62, KeyMapping.Category.MISC);
|
| 668 | public final KeyMapping keySmoothCamera = new KeyMapping("key.smoothCamera", InputConstants.UNKNOWN.getValue(), KeyMapping.Category.MISC);
|
| 669 | public final KeyMapping keyFullscreen = new KeyMapping("key.fullscreen", 68, KeyMapping.Category.MISC);
|
| 670 | public final KeyMapping keyAdvancements = new KeyMapping("key.advancements", 15, KeyMapping.Category.MISC);
|
| 671 | public final KeyMapping keyQuickActions = new KeyMapping("key.quickActions", 10, KeyMapping.Category.MISC);
|
| 672 | public final KeyMapping keyToggleGui = new KeyMapping("key.toggleGui", 58, KeyMapping.Category.MISC);
|
| 673 | public final KeyMapping keyToggleSpectatorShaderEffects = new KeyMapping("key.toggleSpectatorShaderEffects", 61, KeyMapping.Category.MISC);
|
| 674 | public final KeyMapping[] keyHotbarSlots = new KeyMapping[]{
|
| 675 | new KeyMapping("key.hotbar.1", 30, KeyMapping.Category.INVENTORY),
|
| 676 | new KeyMapping("key.hotbar.2", 31, KeyMapping.Category.INVENTORY),
|
| 677 | new KeyMapping("key.hotbar.3", 32, KeyMapping.Category.INVENTORY),
|
| 678 | new KeyMapping("key.hotbar.4", 33, KeyMapping.Category.INVENTORY),
|
| 679 | new KeyMapping("key.hotbar.5", 34, KeyMapping.Category.INVENTORY),
|
| 680 | new KeyMapping("key.hotbar.6", 35, KeyMapping.Category.INVENTORY),
|
| 681 | new KeyMapping("key.hotbar.7", 36, KeyMapping.Category.INVENTORY),
|
| 682 | new KeyMapping("key.hotbar.8", 37, KeyMapping.Category.INVENTORY),
|
| 683 | new KeyMapping("key.hotbar.9", 38, KeyMapping.Category.INVENTORY)
|
| 684 | };
|
| 685 | public final KeyMapping keySaveHotbarActivator = new KeyMapping("key.saveToolbarActivator", 6, KeyMapping.Category.CREATIVE);
|
| 686 | public final KeyMapping keyLoadHotbarActivator = new KeyMapping("key.loadToolbarActivator", 27, KeyMapping.Category.CREATIVE);
|
| 687 | public final KeyMapping keySpectatorOutlines = new KeyMapping("key.spectatorOutlines", InputConstants.UNKNOWN.getValue(), KeyMapping.Category.SPECTATOR);
|
| 688 | public final KeyMapping keySpectatorHotbar = new KeyMapping("key.spectatorHotbar", InputConstants.Type.MOUSE, 2, KeyMapping.Category.SPECTATOR);
|
| 689 | public final KeyMapping keyDebugOverlay = new KeyMapping("key.debug.overlay", InputConstants.Type.KEYBOARD, 60, KeyMapping.Category.DEBUG, -2);
|
| 690 | public final KeyMapping keyDebugModifier = new KeyMapping("key.debug.modifier", InputConstants.Type.KEYBOARD, 60, KeyMapping.Category.DEBUG, -1);
|
| 691 | public final KeyMapping keyDebugCrash = new KeyMapping("key.debug.crash", InputConstants.Type.KEYBOARD, 6, KeyMapping.Category.DEBUG);
|
| 692 | public final KeyMapping keyDebugReloadChunk = new KeyMapping("key.debug.reloadChunk", InputConstants.Type.KEYBOARD, 4, KeyMapping.Category.DEBUG);
|
| 693 | public final KeyMapping keyDebugShowHitboxes = new KeyMapping("key.debug.showHitboxes", InputConstants.Type.KEYBOARD, 5, KeyMapping.Category.DEBUG);
|
| 694 | public final KeyMapping keyDebugClearChat = new KeyMapping("key.debug.clearChat", InputConstants.Type.KEYBOARD, 7, KeyMapping.Category.DEBUG);
|
| 695 | public final KeyMapping keyDebugShowChunkBorders = new KeyMapping("key.debug.showChunkBorders", InputConstants.Type.KEYBOARD, 10, KeyMapping.Category.DEBUG);
|
| 696 | public final KeyMapping keyDebugShowAdvancedTooltips = new KeyMapping(
|
| 697 | "key.debug.showAdvancedTooltips", InputConstants.Type.KEYBOARD, 11, KeyMapping.Category.DEBUG
|
| 698 | );
|
| 699 | public final KeyMapping keyDebugCopyRecreateCommand = new KeyMapping(
|
| 700 | "key.debug.copyRecreateCommand", InputConstants.Type.KEYBOARD, 12, KeyMapping.Category.DEBUG
|
| 701 | );
|
| 702 | public final KeyMapping keyDebugSpectate = new KeyMapping("key.debug.spectate", InputConstants.Type.KEYBOARD, 17, KeyMapping.Category.DEBUG);
|
| 703 | public final KeyMapping keyDebugSwitchGameMode = new KeyMapping("key.debug.switchGameMode", InputConstants.Type.KEYBOARD, 61, KeyMapping.Category.DEBUG);
|
| 704 | public final KeyMapping keyDebugDebugOptions = new KeyMapping("key.debug.debugOptions", InputConstants.Type.KEYBOARD, 63, KeyMapping.Category.DEBUG);
|
| 705 | public final KeyMapping keyDebugFocusPause = new KeyMapping("key.debug.focusPause", InputConstants.Type.KEYBOARD, 19, KeyMapping.Category.DEBUG);
|
| 706 | public final KeyMapping keyDebugDumpDynamicTextures = new KeyMapping(
|
| 707 | "key.debug.dumpDynamicTextures", InputConstants.Type.KEYBOARD, 22, KeyMapping.Category.DEBUG
|
| 708 | );
|
| 709 | public final KeyMapping keyDebugReloadResourcePacks = new KeyMapping(
|
| 710 | "key.debug.reloadResourcePacks", InputConstants.Type.KEYBOARD, 23, KeyMapping.Category.DEBUG
|
| 711 | );
|
| 712 | public final KeyMapping keyDebugProfiling = new KeyMapping("key.debug.profiling", InputConstants.Type.KEYBOARD, 15, KeyMapping.Category.DEBUG);
|
| 713 | public final KeyMapping keyDebugCopyLocation = new KeyMapping("key.debug.copyLocation", InputConstants.Type.KEYBOARD, 6, KeyMapping.Category.DEBUG);
|
| 714 | public final KeyMapping keyDebugDumpVersion = new KeyMapping("key.debug.dumpVersion", InputConstants.Type.KEYBOARD, 25, KeyMapping.Category.DEBUG);
|
| 715 | public final KeyMapping keyDebugPofilingChart = new KeyMapping("key.debug.profilingChart", InputConstants.Type.KEYBOARD, 30, KeyMapping.Category.DEBUG, 1);
|
| 716 | public final KeyMapping keyDebugFpsCharts = new KeyMapping("key.debug.fpsCharts", InputConstants.Type.KEYBOARD, 31, KeyMapping.Category.DEBUG, 2);
|
| 717 | public final KeyMapping keyDebugNetworkCharts = new KeyMapping("key.debug.networkCharts", InputConstants.Type.KEYBOARD, 32, KeyMapping.Category.DEBUG, 3);
|
| 718 | public final KeyMapping keyDebugLightmapTexture = new KeyMapping("key.debug.lightmapTexture", InputConstants.Type.KEYBOARD, 33, KeyMapping.Category.DEBUG, 4);
|
| 719 | public final KeyMapping keyDebugSwitchTranslucencyMode = new KeyMapping(
|
| 720 | "key.debug.improvedTransparency", InputConstants.Type.KEYBOARD, 27, KeyMapping.Category.DEBUG
|
| 721 | );
|
| 722 | public final KeyMapping[] debugKeys = new KeyMapping[]{
|
| 723 | this.keyDebugReloadChunk,
|
| 724 | this.keyDebugShowHitboxes,
|
| 725 | this.keyDebugClearChat,
|
| 726 | this.keyDebugCrash,
|
| 727 | this.keyDebugShowChunkBorders,
|
| 728 | this.keyDebugShowAdvancedTooltips,
|
| 729 | this.keyDebugCopyRecreateCommand,
|
| 730 | this.keyDebugSpectate,
|
| 731 | this.keyDebugSwitchGameMode,
|
| 732 | this.keyDebugDebugOptions,
|
| 733 | this.keyDebugFocusPause,
|
| 734 | this.keyDebugDumpDynamicTextures,
|
| 735 | this.keyDebugReloadResourcePacks,
|
| 736 | this.keyDebugProfiling,
|
| 737 | this.keyDebugCopyLocation,
|
| 738 | this.keyDebugDumpVersion,
|
| 739 | this.keyDebugPofilingChart,
|
| 740 | this.keyDebugFpsCharts,
|
| 741 | this.keyDebugNetworkCharts,
|
| 742 | this.keyDebugLightmapTexture,
|
| 743 | this.keyDebugSwitchTranslucencyMode
|
| 744 | };
|
| 745 | public final KeyMapping[] keyMappings = Stream.of(
|
| 746 | new KeyMapping[]{
|
| 747 | this.keyAttack,
|
| 748 | this.keyUse,
|
| 749 | this.keyUp,
|
| 750 | this.keyLeft,
|
| 751 | this.keyDown,
|
| 752 | this.keyRight,
|
| 753 | this.keyJump,
|
| 754 | this.keyShift,
|
| 755 | this.keySprint,
|
| 756 | this.keyDrop,
|
| 757 | this.keyInventory,
|
| 758 | this.keyChat,
|
| 759 | this.keyPlayerList,
|
| 760 | this.keyPickItem,
|
| 761 | this.keyCommand,
|
| 762 | this.keyFriends,
|
| 763 | this.keySocialInteractions,
|
| 764 | this.keyToggleGui,
|
| 765 | this.keyToggleSpectatorShaderEffects,
|
| 766 | this.keyScreenshot,
|
| 767 | this.keyTogglePerspective,
|
| 768 | this.keySmoothCamera,
|
| 769 | this.keyFullscreen,
|
| 770 | this.keySpectatorOutlines,
|
| 771 | this.keySpectatorHotbar,
|
| 772 | this.keySwapOffhand,
|
| 773 | this.keySaveHotbarActivator,
|
| 774 | this.keyLoadHotbarActivator,
|
| 775 | this.keyAdvancements,
|
| 776 | this.keyQuickActions,
|
| 777 | this.keyDebugOverlay,
|
| 778 | this.keyDebugModifier
|
| 779 | },
|
| 780 | this.keyHotbarSlots,
|
| 781 | this.debugKeys
|
| 782 | )
|
| 783 | .flatMap(Stream::of)
|
| 784 | .toArray(KeyMapping[]::new);
|
| 785 | protected Minecraft minecraft;
|
| 786 | private final File optionsFile;
|
| 787 | private CameraType cameraType = CameraType.FIRST_PERSON;
|
| 788 | public String lastMpIp = "";
|
| 789 | public boolean smoothCamera;
|
| 790 | private final OptionInstance<Integer> fov = new OptionInstance<>(
|
| 791 | "options.fov",
|
| 792 | OptionInstance.noTooltip(),
|
| 793 | (caption, value) -> {
|
| 794 | return switch (value) {
|
| 795 | case 70 -> genericValueLabel(caption, Component.translatable("options.fov.min"));
|
| 796 | case 110 -> genericValueLabel(caption, Component.translatable("options.fov.max"));
|
| 797 | default -> genericValueLabel(caption, value);
|
| 798 | };
|
| 799 | },
|
| 800 | new OptionInstance.IntRange(30, 110),
|
| 801 | Codec.DOUBLE.xmap(value -> (int)(value * 40.0 + 70.0), value -> (value.intValue() - 70.0) / 40.0),
|
| 802 | 70,
|
| 803 | OptionInstance.NO_ACTION
|
| 804 | );
|
| 805 | private static final Component TELEMETRY_TOOLTIP = Component.translatable(
|
| 806 | "options.telemetry.button.tooltip", Component.translatable("options.telemetry.state.minimal"), Component.translatable("options.telemetry.state.all")
|
| 807 | );
|
| 808 | private final OptionInstance<Boolean> telemetryOptInExtra = OptionInstance.createBoolean(
|
| 809 | "options.telemetry.button",
|
| 810 | OptionInstance.cachedConstantTooltip(TELEMETRY_TOOLTIP),
|
| 811 | (caption, value) -> {
|
| 812 | Minecraft minecraftx = Minecraft.getInstance();
|
| 813 | if (!minecraftx.allowsTelemetry()) {
|
| 814 | return Component.translatable("options.telemetry.state.none");
|
| 815 | } else {
|
| 816 | return value && minecraftx.extraTelemetryAvailable()
|
| 817 | ? Component.translatable("options.telemetry.state.all")
|
| 818 | : Component.translatable("options.telemetry.state.minimal");
|
| 819 | }
|
| 820 | },
|
| 821 | false,
|
| 822 | OptionInstance.NO_ACTION
|
| 823 | );
|
| 824 | private static final Component ACCESSIBILITY_TOOLTIP_SCREEN_EFFECT = Component.translatable("options.screenEffectScale.tooltip");
|
| 825 | private final OptionInstance<Double> screenEffectScale = new OptionInstance<>(
|
| 826 | "options.screenEffectScale",
|
| 827 | OptionInstance.cachedConstantTooltip(ACCESSIBILITY_TOOLTIP_SCREEN_EFFECT),
|
| 828 | Options::percentValueOrOffLabel,
|
| 829 | OptionInstance.UnitDouble.INSTANCE,
|
| 830 | 1.0,
|
| 831 | OptionInstance.NO_ACTION
|
| 832 | );
|
| 833 | private static final Component ACCESSIBILITY_TOOLTIP_FOV_EFFECT = Component.translatable("options.fovEffectScale.tooltip");
|
| 834 | private final OptionInstance<Double> fovEffectScale = new OptionInstance<>(
|
| 835 | "options.fovEffectScale",
|
| 836 | OptionInstance.cachedConstantTooltip(ACCESSIBILITY_TOOLTIP_FOV_EFFECT),
|
| 837 | Options::percentValueOrOffLabel,
|
| 838 | OptionInstance.UnitDouble.INSTANCE.xmap(Mth::square, Math::sqrt),
|
| 839 | Codec.doubleRange(0.0, 1.0),
|
| 840 | 1.0,
|
| 841 | OptionInstance.NO_ACTION
|
| 842 | );
|
| 843 | private static final Component ACCESSIBILITY_TOOLTIP_DARKNESS_EFFECT = Component.translatable("options.darknessEffectScale.tooltip");
|
| 844 | private final OptionInstance<Double> darknessEffectScale = new OptionInstance<>(
|
| 845 | "options.darknessEffectScale",
|
| 846 | OptionInstance.cachedConstantTooltip(ACCESSIBILITY_TOOLTIP_DARKNESS_EFFECT),
|
| 847 | Options::percentValueOrOffLabel,
|
| 848 | OptionInstance.UnitDouble.INSTANCE.xmap(Mth::square, Math::sqrt),
|
| 849 | 1.0,
|
| 850 | OptionInstance.NO_ACTION
|
| 851 | );
|
| 852 | private static final Component ACCESSIBILITY_TOOLTIP_GLINT_SPEED = Component.translatable("options.glintSpeed.tooltip");
|
| 853 | private final OptionInstance<Double> glintSpeed = new OptionInstance<>(
|
| 854 | "options.glintSpeed",
|
| 855 | OptionInstance.cachedConstantTooltip(ACCESSIBILITY_TOOLTIP_GLINT_SPEED),
|
| 856 | Options::percentValueOrOffLabel,
|
| 857 | OptionInstance.UnitDouble.INSTANCE,
|
| 858 | 0.5,
|
| 859 | OptionInstance.NO_ACTION
|
| 860 | );
|
| 861 | private static final Component ACCESSIBILITY_TOOLTIP_GLINT_STRENGTH = Component.translatable("options.glintStrength.tooltip");
|
| 862 | private final OptionInstance<Double> glintStrength = new OptionInstance<>(
|
| 863 | "options.glintStrength",
|
| 864 | OptionInstance.cachedConstantTooltip(ACCESSIBILITY_TOOLTIP_GLINT_STRENGTH),
|
| 865 | Options::percentValueOrOffLabel,
|
| 866 | OptionInstance.UnitDouble.INSTANCE,
|
| 867 | 0.75,
|
| 868 | OptionInstance.NO_ACTION
|
| 869 | );
|
| 870 | private static final Component ACCESSIBILITY_TOOLTIP_DAMAGE_TILT_STRENGTH = Component.translatable("options.damageTiltStrength.tooltip");
|
| 871 | private final OptionInstance<Double> damageTiltStrength = new OptionInstance<>(
|
| 872 | "options.damageTiltStrength",
|
| 873 | OptionInstance.cachedConstantTooltip(ACCESSIBILITY_TOOLTIP_DAMAGE_TILT_STRENGTH),
|
| 874 | Options::percentValueOrOffLabel,
|
| 875 | OptionInstance.UnitDouble.INSTANCE,
|
| 876 | 1.0,
|
| 877 | OptionInstance.NO_ACTION
|
| 878 | );
|
| 879 | private final OptionInstance<Double> gamma = new OptionInstance<>(
|
| 880 | "options.gamma",
|
| 881 | OptionInstance.noTooltip(),
|
| 882 | (caption, value) -> {
|
| 883 | int progressValueToDisplay = (int)(value * 100.0);
|
| 884 | if (progressValueToDisplay == 0) {
|
| 885 | return genericValueLabel(caption, Component.translatable("options.gamma.min"));
|
| 886 | } else if (progressValueToDisplay == 50) {
|
| 887 | return genericValueLabel(caption, Component.translatable("options.gamma.default"));
|
| 888 | } else {
|
| 889 | return progressValueToDisplay == 100
|
| 890 | ? genericValueLabel(caption, Component.translatable("options.gamma.max"))
|
| 891 | : genericValueLabel(caption, progressValueToDisplay);
|
| 892 | }
|
| 893 | },
|
| 894 | OptionInstance.UnitDouble.INSTANCE,
|
| 895 | 0.5,
|
| 896 | OptionInstance.NO_ACTION
|
| 897 | );
|
| 898 | public static final int AUTO_GUI_SCALE = 0;
|
| 899 | private static final int MAX_GUI_SCALE_INCLUSIVE = 2147483646;
|
| 900 | private final OptionInstance<Integer> guiScale = new OptionInstance<>(
|
| 901 | "options.guiScale",
|
| 902 | OptionInstance.noTooltip(),
|
| 903 | (caption, value) -> value == 0 ? Component.translatable("options.guiScale.auto") : Component.literal(Integer.toString(value)),
|
| 904 | new OptionInstance.ClampingLazyMaxIntRange(0, () -> {
|
| 905 | Minecraft minecraftx = Minecraft.getInstance();
|
| 906 | return !minecraftx.isRunning() ? 2147483646 : minecraftx.getWindow().calculateScale(0, minecraftx.isEnforceUnicode());
|
| 907 | }, 2147483646),
|
| 908 | 0,
|
| 909 | var1 -> this.minecraft.resizeGui()
|
| 910 | );
|
| 911 | public static final int DEBUG_GUI_SCALE_UNCHANGED = -1;
|
| 912 | private static final Component DEBUG_GUI_SCALE_TOOLTIP = Component.translatable("options.debugGuiScale.tooltip");
|
| 913 | private final OptionInstance<Integer> debugGuiScale = new OptionInstance<>(
|
| 914 | "options.guiScale", OptionInstance.cachedConstantTooltip(DEBUG_GUI_SCALE_TOOLTIP), (caption, value) -> {
|
| 915 | return switch (value) {
|
| 916 | case -1 -> Component.translatable("options.debugGuiScale.unchanged");
|
| 917 | case 0 -> Component.translatable("options.guiScale.auto");
|
| 918 | default -> Component.literal(Integer.toString(value));
|
| 919 | };
|
| 920 | }, new OptionInstance.ClampingLazyMaxIntRange(-1, () -> {
|
| 921 | Minecraft minecraftx = Minecraft.getInstance();
|
| 922 | return !minecraftx.isRunning() ? 2147483646 : minecraftx.getWindow().calculateScale(0, minecraftx.isEnforceUnicode());
|
| 923 | }, 2147483646), 0, var0 -> {}
|
| 924 | );
|
| 925 | private final OptionInstance<ParticleStatus> particles = new OptionInstance<>(
|
| 926 | "options.particles",
|
| 927 | OptionInstance.noTooltip(),
|
| 928 | (caption, value) -> value.caption(),
|
| 929 | new OptionInstance.Enum<>(Arrays.asList(ParticleStatus.values()), ParticleStatus.LEGACY_CODEC),
|
| 930 | ParticleStatus.ALL,
|
| 931 | var1 -> this.setGraphicsPresetToCustom()
|
| 932 | );
|
| 933 | private final OptionInstance<NarratorStatus> narrator = new OptionInstance<>(
|
| 934 | "options.narrator",
|
| 935 | OptionInstance.noTooltip(),
|
| 936 | (caption, value) -> this.minecraft.getNarrator().isActive() ? value.getName() : Component.translatable("options.narrator.notavailable"),
|
| 937 | new OptionInstance.Enum<>(Arrays.asList(NarratorStatus.values()), NarratorStatus.LEGACY_CODEC),
|
| 938 | NarratorStatus.OFF,
|
| 939 | value -> this.minecraft.getNarrator().updateNarratorStatus(value)
|
| 940 | );
|
| 941 | public String languageCode = "en_us";
|
| 942 | private final OptionInstance<String> soundDevice = new OptionInstance<>(
|
| 943 | "options.audioDevice",
|
| 944 | OptionInstance.noTooltip(),
|
| 945 | (caption, value) -> {
|
| 946 | if ("".equals(value)) {
|
| 947 | return Component.translatable("options.audioDevice.default");
|
| 948 | } else {
|
| 949 | return value.startsWith("OpenAL Soft on ") ? Component.literal(value.substring(SoundEngine.OPEN_AL_SOFT_PREFIX_LENGTH)) : Component.literal(value);
|
| 950 | }
|
| 951 | },
|
| 952 | new OptionInstance.LazyEnum<>(
|
| 953 | () -> Stream.concat(Stream.of(""), Minecraft.getInstance().getSoundManager().getAvailableSoundDevices().stream()).toList(),
|
| 954 | device -> Minecraft.getInstance().isRunning()
|
| 955 | && !isSoundDeviceDefault(device)
|
| 956 | && !Minecraft.getInstance().getSoundManager().getAvailableSoundDevices().contains(device)
|
| 957 | ? Optional.empty()
|
| 958 | : Optional.of(device),
|
| 959 | Codec.STRING
|
| 960 | ),
|
| 961 | "",
|
| 962 | var0 -> {
|
| 963 | SoundManager soundManager = Minecraft.getInstance().getSoundManager();
|
| 964 | soundManager.reload();
|
| 965 | soundManager.play(SimpleSoundInstance.forUI(SoundEvents.UI_BUTTON_CLICK, 1.0F));
|
| 966 | }
|
| 967 | );
|
| 968 | public boolean onboardAccessibility = true;
|
| 969 | private static final Component MUSIC_FREQUENCY_TOOLTIP = Component.translatable("options.music_frequency.tooltip");
|
| 970 | private final OptionInstance<MusicManager.MusicFrequency> musicFrequency = new OptionInstance<>(
|
| 971 | "options.music_frequency",
|
| 972 | OptionInstance.cachedConstantTooltip(MUSIC_FREQUENCY_TOOLTIP),
|
| 973 | (caption, value) -> value.caption(),
|
| 974 | new OptionInstance.Enum<>(Arrays.asList(MusicManager.MusicFrequency.values()), MusicManager.MusicFrequency.CODEC),
|
| 975 | MusicManager.MusicFrequency.DEFAULT,
|
| 976 | value -> Minecraft.getInstance().getMusicManager().setMinutesBetweenSongs(value)
|
| 977 | );
|
| 978 | private final OptionInstance<MusicToastDisplayState> musicToast = new OptionInstance<>(
|
| 979 | "options.musicToast",
|
| 980 | value -> Tooltip.create(value.tooltip()),
|
| 981 | (caption, value) -> value.text(),
|
| 982 | new OptionInstance.Enum<>(Arrays.asList(MusicToastDisplayState.values()), MusicToastDisplayState.CODEC),
|
| 983 | MusicToastDisplayState.NEVER,
|
| 984 | value -> this.minecraft.gui.toastManager().setMusicToastDisplayState(value)
|
| 985 | );
|
| 986 | public boolean syncWrites;
|
| 987 | public boolean startedCleanly = true;
|
| 988 |
|
| 989 | public static boolean isSoundDeviceDefault(final String deviceName) {
|
| 990 | return deviceName.equals("");
|
| 991 | }
|
| 992 |
|
| 993 | private static void operateOnLevelExtractor(final Consumer<LevelExtractor> consumer) {
|
| 994 | LevelExtractor levelExtractor = Minecraft.getInstance().levelExtractor;
|
| 995 | if (levelExtractor != null) {
|
| 996 | consumer.accept(levelExtractor);
|
| 997 | }
|
| 998 | }
|
| 999 |
|
| 1000 | public OptionInstance<Boolean> darkMojangStudiosBackground() {
|
| 1001 | return this.darkMojangStudiosBackground;
|
| 1002 | }
|
| 1003 |
|
| 1004 | public OptionInstance<Boolean> hideLightningFlash() {
|
| 1005 | return this.hideLightningFlash;
|
| 1006 | }
|
| 1007 |
|
| 1008 | public OptionInstance<Boolean> hideSplashTexts() {
|
| 1009 | return this.hideSplashTexts;
|
| 1010 | }
|
| 1011 |
|
| 1012 | public OptionInstance<Double> sensitivity() {
|
| 1013 | return this.sensitivity;
|
| 1014 | }
|
| 1015 |
|
| 1016 | public OptionInstance<Integer> renderDistance() {
|
| 1017 | return this.renderDistance;
|
| 1018 | }
|
| 1019 |
|
| 1020 | public OptionInstance<Integer> simulationDistance() {
|
| 1021 | return this.simulationDistance;
|
| 1022 | }
|
| 1023 |
|
| 1024 | public OptionInstance<Double> entityDistanceScaling() {
|
| 1025 | return this.entityDistanceScaling;
|
| 1026 | }
|
| 1027 |
|
| 1028 | public OptionInstance<Integer> framerateLimit() {
|
| 1029 | return this.framerateLimit;
|
| 1030 | }
|
| 1031 |
|
| 1032 | public OptionInstance<PreferredGraphicsApi> preferredGraphicsBackend() {
|
| 1033 | return this.preferredGraphicsBackend;
|
| 1034 | }
|
| 1035 |
|
| 1036 | public boolean isRestartRequiredToApplyVideoSettings() {
|
| 1037 | return this.preferredGraphicsBackend.get() != this.preferredGraphicsBackendFromStartup;
|
| 1038 | }
|
| 1039 |
|
| 1040 | public void applyGraphicsPreset(final GraphicsPreset value) {
|
| 1041 | this.isApplyingGraphicsPreset = true;
|
| 1042 | value.apply(this.minecraft);
|
| 1043 | this.isApplyingGraphicsPreset = false;
|
| 1044 | }
|
| 1045 |
|
| 1046 | public OptionInstance<GraphicsPreset> graphicsPreset() {
|
| 1047 | return this.graphicsPreset;
|
| 1048 | }
|
| 1049 |
|
| 1050 | public OptionInstance<InactivityFpsLimit> inactivityFpsLimit() {
|
| 1051 | return this.inactivityFpsLimit;
|
| 1052 | }
|
| 1053 |
|
| 1054 | public OptionInstance<CloudStatus> cloudStatus() {
|
| 1055 | return this.cloudStatus;
|
| 1056 | }
|
| 1057 |
|
| 1058 | public OptionInstance<Integer> cloudRange() {
|
| 1059 | return this.cloudRange;
|
| 1060 | }
|
| 1061 |
|
| 1062 | public OptionInstance<Integer> weatherRadius() {
|
| 1063 | return this.weatherRadius;
|
| 1064 | }
|
| 1065 |
|
| 1066 | public OptionInstance<Boolean> cutoutLeaves() {
|
| 1067 | return this.cutoutLeaves;
|
| 1068 | }
|
| 1069 |
|
| 1070 | public OptionInstance<Boolean> vignette() {
|
| 1071 | return this.vignette;
|
| 1072 | }
|
| 1073 |
|
| 1074 | public OptionInstance<Boolean> improvedTransparency() {
|
| 1075 | return this.improvedTransparency;
|
| 1076 | }
|
| 1077 |
|
| 1078 | public OptionInstance<Boolean> ambientOcclusion() {
|
| 1079 | return this.ambientOcclusion;
|
| 1080 | }
|
| 1081 |
|
| 1082 | public OptionInstance<Double> chunkSectionFadeInTime() {
|
| 1083 | return this.chunkSectionFadeInTime;
|
| 1084 | }
|
| 1085 |
|
| 1086 | public OptionInstance<PrioritizeChunkUpdates> prioritizeChunkUpdates() {
|
| 1087 | return this.prioritizeChunkUpdates;
|
| 1088 | }
|
| 1089 |
|
| 1090 | public void updateResourcePacks(final PackRepository packRepository) {
|
| 1091 | List<String> oldPacks = ImmutableList.copyOf(this.resourcePacks);
|
| 1092 | this.resourcePacks.clear();
|
| 1093 | this.incompatibleResourcePacks.clear();
|
| 1094 |
|
| 1095 | for (Pack entry : packRepository.getSelectedPacks()) {
|
| 1096 | if (!entry.isFixedPosition()) {
|
| 1097 | this.resourcePacks.add(entry.getId());
|
| 1098 | if (!entry.getCompatibility().isCompatible()) {
|
| 1099 | this.incompatibleResourcePacks.add(entry.getId());
|
| 1100 | }
|
| 1101 | }
|
| 1102 | }
|
| 1103 |
|
| 1104 | this.save();
|
| 1105 | List<String> newPacks = ImmutableList.copyOf(this.resourcePacks);
|
| 1106 | if (!newPacks.equals(oldPacks)) {
|
| 1107 | this.minecraft.reloadResourcePacks();
|
| 1108 | }
|
| 1109 | }
|
| 1110 |
|
| 1111 | public OptionInstance<ChatVisiblity> chatVisibility() {
|
| 1112 | return this.chatVisibility;
|
| 1113 | }
|
| 1114 |
|
| 1115 | public OptionInstance<Double> chatOpacity() {
|
| 1116 | return this.chatOpacity;
|
| 1117 | }
|
| 1118 |
|
| 1119 | public OptionInstance<Double> chatLineSpacing() {
|
| 1120 | return this.chatLineSpacing;
|
| 1121 | }
|
| 1122 |
|
| 1123 | public OptionInstance<Integer> menuBackgroundBlurriness() {
|
| 1124 | return this.menuBackgroundBlurriness;
|
| 1125 | }
|
| 1126 |
|
| 1127 | public int getMenuBackgroundBlurriness() {
|
| 1128 | return this.menuBackgroundBlurriness().get();
|
| 1129 | }
|
| 1130 |
|
| 1131 | public OptionInstance<Double> textBackgroundOpacity() {
|
| 1132 | return this.textBackgroundOpacity;
|
| 1133 | }
|
| 1134 |
|
| 1135 | public OptionInstance<Double> panoramaSpeed() {
|
| 1136 | return this.panoramaSpeed;
|
| 1137 | }
|
| 1138 |
|
| 1139 | public OptionInstance<Boolean> highContrast() {
|
| 1140 | return this.highContrast;
|
| 1141 | }
|
| 1142 |
|
| 1143 | public OptionInstance<Boolean> highContrastBlockOutline() {
|
| 1144 | return this.highContrastBlockOutline;
|
| 1145 | }
|
| 1146 |
|
| 1147 | public OptionInstance<Boolean> narratorHotkey() {
|
| 1148 | return this.narratorHotkey;
|
| 1149 | }
|
| 1150 |
|
| 1151 | public OptionInstance<HumanoidArm> mainHand() {
|
| 1152 | return this.mainHand;
|
| 1153 | }
|
| 1154 |
|
| 1155 | public OptionInstance<Double> chatScale() {
|
| 1156 | return this.chatScale;
|
| 1157 | }
|
| 1158 |
|
| 1159 | public OptionInstance<Double> chatWidth() {
|
| 1160 | return this.chatWidth;
|
| 1161 | }
|
| 1162 |
|
| 1163 | public OptionInstance<Double> chatHeightUnfocused() {
|
| 1164 | return this.chatHeightUnfocused;
|
| 1165 | }
|
| 1166 |
|
| 1167 | public OptionInstance<Double> chatHeightFocused() {
|
| 1168 | return this.chatHeightFocused;
|
| 1169 | }
|
| 1170 |
|
| 1171 | public OptionInstance<Double> chatDelay() {
|
| 1172 | return this.chatDelay;
|
| 1173 | }
|
| 1174 |
|
| 1175 | public OptionInstance<Double> notificationDisplayTime() {
|
| 1176 | return this.notificationDisplayTime;
|
| 1177 | }
|
| 1178 |
|
| 1179 | public OptionInstance<Integer> mipmapLevels() {
|
| 1180 | return this.mipmapLevels;
|
| 1181 | }
|
| 1182 |
|
| 1183 | public OptionInstance<Integer> maxAnisotropyBit() {
|
| 1184 | return this.maxAnisotropyBit;
|
| 1185 | }
|
| 1186 |
|
| 1187 | public int maxAnisotropyValue() {
|
| 1188 | return Math.min(1 << this.maxAnisotropyBit.get(), RenderSystem.getDevice().getDeviceInfo().limits().maxAnisotropy());
|
| 1189 | }
|
| 1190 |
|
| 1191 | public OptionInstance<TextureFilteringMethod> textureFiltering() {
|
| 1192 | return this.textureFiltering;
|
| 1193 | }
|
| 1194 |
|
| 1195 | public OptionInstance<AttackIndicatorStatus> attackIndicator() {
|
| 1196 | return this.attackIndicator;
|
| 1197 | }
|
| 1198 |
|
| 1199 | public OptionInstance<Integer> biomeBlendRadius() {
|
| 1200 | return this.biomeBlendRadius;
|
| 1201 | }
|
| 1202 |
|
| 1203 | private static double logMouse(final int value) {
|
| 1204 | return Math.pow(10.0, value / 100.0);
|
| 1205 | }
|
| 1206 |
|
| 1207 | private static int unlogMouse(final double value) {
|
| 1208 | return Mth.floor(Math.log10(value) * 100.0);
|
| 1209 | }
|
| 1210 |
|
| 1211 | public OptionInstance<Double> mouseWheelSensitivity() {
|
| 1212 | return this.mouseWheelSensitivity;
|
| 1213 | }
|
| 1214 |
|
| 1215 | public OptionInstance<Boolean> allowCursorChanges() {
|
| 1216 | return this.allowCursorChanges;
|
| 1217 | }
|
| 1218 |
|
| 1219 | public OptionInstance<Boolean> quitShortcuts() {
|
| 1220 | return this.quitShortcuts;
|
| 1221 | }
|
| 1222 |
|
| 1223 | public OptionInstance<Boolean> ctrlClickEmulatesRightClick() {
|
| 1224 | return this.ctrlClickEmulatesRightClick;
|
| 1225 | }
|
| 1226 |
|
| 1227 | public OptionInstance<Boolean> autoJump() {
|
| 1228 | return this.autoJump;
|
| 1229 | }
|
| 1230 |
|
| 1231 | public OptionInstance<Boolean> rotateWithMinecart() {
|
| 1232 | return this.rotateWithMinecart;
|
| 1233 | }
|
| 1234 |
|
| 1235 | public OptionInstance<Boolean> operatorItemsTab() {
|
| 1236 | return this.operatorItemsTab;
|
| 1237 | }
|
| 1238 |
|
| 1239 | public OptionInstance<Boolean> autoSuggestions() {
|
| 1240 | return this.autoSuggestions;
|
| 1241 | }
|
| 1242 |
|
| 1243 | public OptionInstance<Boolean> chatColors() {
|
| 1244 | return this.chatColors;
|
| 1245 | }
|
| 1246 |
|
| 1247 | public OptionInstance<Boolean> chatLinks() {
|
| 1248 | return this.chatLinks;
|
| 1249 | }
|
| 1250 |
|
| 1251 | public OptionInstance<Boolean> chatLinksPrompt() {
|
| 1252 | return this.chatLinksPrompt;
|
| 1253 | }
|
| 1254 |
|
| 1255 | public OptionInstance<Boolean> enableVsync() {
|
| 1256 | return this.enableVsync;
|
| 1257 | }
|
| 1258 |
|
| 1259 | public OptionInstance<Boolean> entityShadows() {
|
| 1260 | return this.entityShadows;
|
| 1261 | }
|
| 1262 |
|
| 1263 | private static void updateFontOptions() {
|
| 1264 | Minecraft instance = Minecraft.getInstance();
|
| 1265 | if (instance.getWindow() != null) {
|
| 1266 | instance.updateFontOptions();
|
| 1267 | instance.resizeGui();
|
| 1268 | }
|
| 1269 | }
|
| 1270 |
|
| 1271 | public OptionInstance<Boolean> forceUnicodeFont() {
|
| 1272 | return this.forceUnicodeFont;
|
| 1273 | }
|
| 1274 |
|
| 1275 | private static boolean japaneseGlyphVariantsDefault() {
|
| 1276 | return Locale.getDefault().getLanguage().equalsIgnoreCase("ja");
|
| 1277 | }
|
| 1278 |
|
| 1279 | public OptionInstance<Boolean> japaneseGlyphVariants() {
|
| 1280 | return this.japaneseGlyphVariants;
|
| 1281 | }
|
| 1282 |
|
| 1283 | public OptionInstance<Boolean> invertMouseX() {
|
| 1284 | return this.invertXMouse;
|
| 1285 | }
|
| 1286 |
|
| 1287 | public OptionInstance<Boolean> invertMouseY() {
|
| 1288 | return this.invertYMouse;
|
| 1289 | }
|
| 1290 |
|
| 1291 | public OptionInstance<Boolean> discreteMouseScroll() {
|
| 1292 | return this.discreteMouseScroll;
|
| 1293 | }
|
| 1294 |
|
| 1295 | public OptionInstance<Boolean> realmsNotifications() {
|
| 1296 | return this.realmsNotifications;
|
| 1297 | }
|
| 1298 |
|
| 1299 | public OptionInstance<Boolean> allowServerListing() {
|
| 1300 | return this.allowServerListing;
|
| 1301 | }
|
| 1302 |
|
| 1303 | public OptionInstance<Boolean> reducedDebugInfo() {
|
| 1304 | return this.reducedDebugInfo;
|
| 1305 | }
|
| 1306 |
|
| 1307 | public OptionInstance<Boolean> inGameNotification() {
|
| 1308 | return this.inGameNotification;
|
| 1309 | }
|
| 1310 |
|
| 1311 | public OptionInstance<PresenceSharing> sharePresence() {
|
| 1312 | return this.sharePresence;
|
| 1313 | }
|
| 1314 |
|
| 1315 | public final float getFinalSoundSourceVolume(final SoundSource source) {
|
| 1316 | return source == SoundSource.MASTER ? this.getSoundSourceVolume(source) : this.getSoundSourceVolume(source) * this.getSoundSourceVolume(SoundSource.MASTER);
|
| 1317 | }
|
| 1318 |
|
| 1319 | public final float getSoundSourceVolume(final SoundSource source) {
|
| 1320 | return this.getSoundSourceOptionInstance(source).get().floatValue();
|
| 1321 | }
|
| 1322 |
|
| 1323 | public final OptionInstance<Double> getSoundSourceOptionInstance(final SoundSource source) {
|
| 1324 | return Objects.requireNonNull(this.soundSourceVolumes.get(source));
|
| 1325 | }
|
| 1326 |
|
| 1327 | private OptionInstance<Double> createSoundSliderOptionInstance(final String captionId, final SoundSource category) {
|
| 1328 | return new OptionInstance<>(captionId, OptionInstance.noTooltip(), Options::percentValueOrOffLabel, OptionInstance.UnitDouble.INSTANCE, 1.0, value -> {
|
| 1329 | Minecraft minecraft = Minecraft.getInstance();
|
| 1330 | SoundManager soundManager = minecraft.getSoundManager();
|
| 1331 | if ((category == SoundSource.MASTER || category == SoundSource.MUSIC) && this.getFinalSoundSourceVolume(SoundSource.MUSIC) > 0.0F) {
|
| 1332 | minecraft.getMusicManager().showNowPlayingToastIfNeeded();
|
| 1333 | }
|
| 1334 |
|
| 1335 | soundManager.refreshCategoryVolume(category);
|
| 1336 | if (minecraft.level == null) {
|
| 1337 | SoundPreviewHandler.preview(soundManager, category, value.floatValue());
|
| 1338 | }
|
| 1339 | });
|
| 1340 | }
|
| 1341 |
|
| 1342 | public OptionInstance<Boolean> showSubtitles() {
|
| 1343 | return this.showSubtitles;
|
| 1344 | }
|
| 1345 |
|
| 1346 | public OptionInstance<Boolean> directionalAudio() {
|
| 1347 | return this.directionalAudio;
|
| 1348 | }
|
| 1349 |
|
| 1350 | public OptionInstance<Boolean> backgroundForChatOnly() {
|
| 1351 | return this.backgroundForChatOnly;
|
| 1352 | }
|
| 1353 |
|
| 1354 | public OptionInstance<Boolean> fullscreen() {
|
| 1355 | return this.fullscreen;
|
| 1356 | }
|
| 1357 |
|
| 1358 | public OptionInstance<Boolean> exclusiveFullscreen() {
|
| 1359 | return this.exclusiveFullscreen;
|
| 1360 | }
|
| 1361 |
|
| 1362 | public OptionInstance<Boolean> macFullscreenMenuVisibility() {
|
| 1363 | return this.macFullscreenMenuVisibility;
|
| 1364 | }
|
| 1365 |
|
| 1366 | public OptionInstance<Boolean> bobView() {
|
| 1367 | return this.bobView;
|
| 1368 | }
|
| 1369 |
|
| 1370 | public OptionInstance<Boolean> toggleCrouch() {
|
| 1371 | return this.toggleCrouch;
|
| 1372 | }
|
| 1373 |
|
| 1374 | public OptionInstance<Boolean> toggleSprint() {
|
| 1375 | return this.toggleSprint;
|
| 1376 | }
|
| 1377 |
|
| 1378 | public OptionInstance<Boolean> toggleAttack() {
|
| 1379 | return this.toggleAttack;
|
| 1380 | }
|
| 1381 |
|
| 1382 | public OptionInstance<Boolean> toggleUse() {
|
| 1383 | return this.toggleUse;
|
| 1384 | }
|
| 1385 |
|
| 1386 | public OptionInstance<Integer> sprintWindow() {
|
| 1387 | return this.sprintWindow;
|
| 1388 | }
|
| 1389 |
|
| 1390 | public OptionInstance<Boolean> hideMatchedNames() {
|
| 1391 | return this.hideMatchedNames;
|
| 1392 | }
|
| 1393 |
|
| 1394 | public OptionInstance<Boolean> showAutosaveIndicator() {
|
| 1395 | return this.showAutosaveIndicator;
|
| 1396 | }
|
| 1397 |
|
| 1398 | public OptionInstance<Boolean> onlyShowSecureChat() {
|
| 1399 | return this.onlyShowSecureChat;
|
| 1400 | }
|
| 1401 |
|
| 1402 | public OptionInstance<Boolean> saveChatDrafts() {
|
| 1403 | return this.saveChatDrafts;
|
| 1404 | }
|
| 1405 |
|
| 1406 | private void setGraphicsPresetToCustom() {
|
| 1407 | if (!this.isApplyingGraphicsPreset) {
|
| 1408 | this.graphicsPreset.set(GraphicsPreset.CUSTOM);
|
| 1409 | if (this.minecraft.gui.screen() instanceof OptionsSubScreen optionsSubScreen) {
|
| 1410 | optionsSubScreen.resetOption(this.graphicsPreset);
|
| 1411 | }
|
| 1412 | }
|
| 1413 | }
|
| 1414 |
|
| 1415 | public OptionInstance<Integer> fov() {
|
| 1416 | return this.fov;
|
| 1417 | }
|
| 1418 |
|
| 1419 | public OptionInstance<Boolean> telemetryOptInExtra() {
|
| 1420 | return this.telemetryOptInExtra;
|
| 1421 | }
|
| 1422 |
|
| 1423 | public OptionInstance<Double> screenEffectScale() {
|
| 1424 | return this.screenEffectScale;
|
| 1425 | }
|
| 1426 |
|
| 1427 | public OptionInstance<Double> fovEffectScale() {
|
| 1428 | return this.fovEffectScale;
|
| 1429 | }
|
| 1430 |
|
| 1431 | public OptionInstance<Double> darknessEffectScale() {
|
| 1432 | return this.darknessEffectScale;
|
| 1433 | }
|
| 1434 |
|
| 1435 | public OptionInstance<Double> glintSpeed() {
|
| 1436 | return this.glintSpeed;
|
| 1437 | }
|
| 1438 |
|
| 1439 | public OptionInstance<Double> glintStrength() {
|
| 1440 | return this.glintStrength;
|
| 1441 | }
|
| 1442 |
|
| 1443 | public OptionInstance<Double> damageTiltStrength() {
|
| 1444 | return this.damageTiltStrength;
|
| 1445 | }
|
| 1446 |
|
| 1447 | public OptionInstance<Double> gamma() {
|
| 1448 | return this.gamma;
|
| 1449 | }
|
| 1450 |
|
| 1451 | public OptionInstance<Integer> guiScale() {
|
| 1452 | return this.guiScale;
|
| 1453 | }
|
| 1454 |
|
| 1455 | public OptionInstance<Integer> debugGuiScale() {
|
| 1456 | return this.debugGuiScale;
|
| 1457 | }
|
| 1458 |
|
| 1459 | public OptionInstance<ParticleStatus> particles() {
|
| 1460 | return this.particles;
|
| 1461 | }
|
| 1462 |
|
| 1463 | public OptionInstance<NarratorStatus> narrator() {
|
| 1464 | return this.narrator;
|
| 1465 | }
|
| 1466 |
|
| 1467 | public OptionInstance<String> soundDevice() {
|
| 1468 | return this.soundDevice;
|
| 1469 | }
|
| 1470 |
|
| 1471 | public void onboardingAccessibilityFinished() {
|
| 1472 | this.onboardAccessibility = false;
|
| 1473 | this.save();
|
| 1474 | }
|
| 1475 |
|
| 1476 | public OptionInstance<MusicManager.MusicFrequency> musicFrequency() {
|
| 1477 | return this.musicFrequency;
|
| 1478 | }
|
| 1479 |
|
| 1480 | public OptionInstance<MusicToastDisplayState> musicToast() {
|
| 1481 | return this.musicToast;
|
| 1482 | }
|
| 1483 |
|
| 1484 | public Options(final Minecraft minecraft, final File workingDirectory) {
|
| 1485 | this.minecraft = minecraft;
|
| 1486 | this.optionsFile = new File(workingDirectory, "options.txt");
|
| 1487 | boolean largeDistances = Runtime.getRuntime().maxMemory() >= 1000000000L;
|
| 1488 | this.renderDistance = new OptionInstance<>(
|
| 1489 | "options.renderDistance",
|
| 1490 | OptionInstance.noTooltip(),
|
| 1491 | (caption, value) -> genericValueLabel(caption, Component.translatable("options.chunks", value)),
|
| 1492 | new OptionInstance.IntRange(2, largeDistances ? 32 : 16, false),
|
| 1493 | 12,
|
| 1494 | var1 -> this.setGraphicsPresetToCustom()
|
| 1495 | );
|
| 1496 | this.simulationDistance = new OptionInstance<>(
|
| 1497 | "options.simulationDistance",
|
| 1498 | OptionInstance.noTooltip(),
|
| 1499 | (caption, value) -> genericValueLabel(caption, Component.translatable("options.chunks", value)),
|
| 1500 | new OptionInstance.IntRange(SharedConstants.DEBUG_ALLOW_LOW_SIM_DISTANCE ? 2 : 5, largeDistances ? 32 : 16, false),
|
| 1501 | 12,
|
| 1502 | var1 -> this.setGraphicsPresetToCustom()
|
| 1503 | );
|
| 1504 | this.syncWrites = Util.getPlatform() == OS.WINDOWS;
|
| 1505 | this.load();
|
| 1506 | }
|
| 1507 |
|
| 1508 | public float getBackgroundOpacity(final float defaultOpacity) {
|
| 1509 | return this.backgroundForChatOnly.get() ? defaultOpacity : this.textBackgroundOpacity().get().floatValue();
|
| 1510 | }
|
| 1511 |
|
| 1512 | public int getBackgroundColor(final float defaultOpacity) {
|
| 1513 | return ARGB.colorFromFloat(this.getBackgroundOpacity(defaultOpacity), 0.0F, 0.0F, 0.0F);
|
| 1514 | }
|
| 1515 |
|
| 1516 | public int getBackgroundColor(final int defaultColor) {
|
| 1517 | return this.backgroundForChatOnly.get() ? defaultColor : ARGB.colorFromFloat(this.textBackgroundOpacity.get().floatValue(), 0.0F, 0.0F, 0.0F);
|
| 1518 | }
|
| 1519 |
|
| 1520 | private void processDumpedOptions(final Options.OptionAccess access) {
|
| 1521 | access.process("ao", this.ambientOcclusion);
|
| 1522 | access.process("biomeBlendRadius", this.biomeBlendRadius);
|
| 1523 | access.process("chunkSectionFadeInTime", this.chunkSectionFadeInTime);
|
| 1524 | access.process("cutoutLeaves", this.cutoutLeaves);
|
| 1525 | access.process("enableVsync", this.enableVsync);
|
| 1526 | access.process("entityDistanceScaling", this.entityDistanceScaling);
|
| 1527 | access.process("entityShadows", this.entityShadows);
|
| 1528 | access.process("forceUnicodeFont", this.forceUnicodeFont);
|
| 1529 | access.process("japaneseGlyphVariants", this.japaneseGlyphVariants);
|
| 1530 | access.process("fov", this.fov);
|
| 1531 | access.process("fovEffectScale", this.fovEffectScale);
|
| 1532 | access.process("darknessEffectScale", this.darknessEffectScale);
|
| 1533 | access.process("glintSpeed", this.glintSpeed);
|
| 1534 | access.process("glintStrength", this.glintStrength);
|
| 1535 | access.process("preferredGraphicsBackend", this.preferredGraphicsBackend);
|
| 1536 | access.process("graphicsPreset", this.graphicsPreset);
|
| 1537 | access.process("prioritizeChunkUpdates", this.prioritizeChunkUpdates);
|
| 1538 | access.process("fullscreen", this.fullscreen);
|
| 1539 | access.process("exclusiveFullscreen", this.exclusiveFullscreen);
|
| 1540 | access.process("macFullscreenMenuVisibility", this.macFullscreenMenuVisibility);
|
| 1541 | access.process("gamma", this.gamma);
|
| 1542 | access.process("guiScale", this.guiScale);
|
| 1543 | access.process("debugGuiScale", this.debugGuiScale);
|
| 1544 | access.process("maxAnisotropyBit", this.maxAnisotropyBit);
|
| 1545 | access.process("textureFiltering", this.textureFiltering);
|
| 1546 | access.process("maxFps", this.framerateLimit);
|
| 1547 | access.process("improvedTransparency", this.improvedTransparency);
|
| 1548 | access.process("inactivityFpsLimit", this.inactivityFpsLimit);
|
| 1549 | access.process("mipmapLevels", this.mipmapLevels);
|
| 1550 | access.process("narrator", this.narrator);
|
| 1551 | access.process("particles", this.particles);
|
| 1552 | access.process("reducedDebugInfo", this.reducedDebugInfo);
|
| 1553 | access.process("renderClouds", this.cloudStatus);
|
| 1554 | access.process("cloudRange", this.cloudRange);
|
| 1555 | access.process("renderDistance", this.renderDistance);
|
| 1556 | access.process("simulationDistance", this.simulationDistance);
|
| 1557 | access.process("screenEffectScale", this.screenEffectScale);
|
| 1558 | access.process("soundDevice", this.soundDevice);
|
| 1559 | access.process("vignette", this.vignette);
|
| 1560 | access.process("weatherRadius", this.weatherRadius);
|
| 1561 | }
|
| 1562 |
|
| 1563 | private void processOptions(final Options.FieldAccess access) {
|
| 1564 | this.processDumpedOptions(access);
|
| 1565 | access.process("autoJump", this.autoJump);
|
| 1566 | access.process("rotateWithMinecart", this.rotateWithMinecart);
|
| 1567 | access.process("operatorItemsTab", this.operatorItemsTab);
|
| 1568 | access.process("autoSuggestions", this.autoSuggestions);
|
| 1569 | access.process("chatColors", this.chatColors);
|
| 1570 | access.process("chatLinks", this.chatLinks);
|
| 1571 | access.process("chatLinksPrompt", this.chatLinksPrompt);
|
| 1572 | access.process("discrete_mouse_scroll", this.discreteMouseScroll);
|
| 1573 | access.process("invertXMouse", this.invertXMouse);
|
| 1574 | access.process("invertYMouse", this.invertYMouse);
|
| 1575 | access.process("realmsNotifications", this.realmsNotifications);
|
| 1576 | access.process("showSubtitles", this.showSubtitles);
|
| 1577 | access.process("directionalAudio", this.directionalAudio);
|
| 1578 | access.process("bobView", this.bobView);
|
| 1579 | access.process("toggleCrouch", this.toggleCrouch);
|
| 1580 | access.process("toggleSprint", this.toggleSprint);
|
| 1581 | access.process("toggleAttack", this.toggleAttack);
|
| 1582 | access.process("toggleUse", this.toggleUse);
|
| 1583 | access.process("sprintWindow", this.sprintWindow);
|
| 1584 | access.process("darkMojangStudiosBackground", this.darkMojangStudiosBackground);
|
| 1585 | access.process("hideLightningFlashes", this.hideLightningFlash);
|
| 1586 | access.process("hideSplashTexts", this.hideSplashTexts);
|
| 1587 | access.process("mouseSensitivity", this.sensitivity);
|
| 1588 | access.process("damageTiltStrength", this.damageTiltStrength);
|
| 1589 | access.process("highContrast", this.highContrast);
|
| 1590 | access.process("highContrastBlockOutline", this.highContrastBlockOutline);
|
| 1591 | access.process("narratorHotkey", this.narratorHotkey);
|
| 1592 | this.resourcePacks = access.process("resourcePacks", this.resourcePacks, Options::readListOfStrings, GSON::toJson);
|
| 1593 | this.incompatibleResourcePacks = access.process("incompatibleResourcePacks", this.incompatibleResourcePacks, Options::readListOfStrings, GSON::toJson);
|
| 1594 | this.lastMpIp = access.process("lastServer", this.lastMpIp);
|
| 1595 | this.languageCode = access.process("lang", this.languageCode);
|
| 1596 | access.process("chatVisibility", this.chatVisibility);
|
| 1597 | access.process("chatOpacity", this.chatOpacity);
|
| 1598 | access.process("chatLineSpacing", this.chatLineSpacing);
|
| 1599 | access.process("textBackgroundOpacity", this.textBackgroundOpacity);
|
| 1600 | access.process("backgroundForChatOnly", this.backgroundForChatOnly);
|
| 1601 | this.hideServerAddress = access.process("hideServerAddress", this.hideServerAddress);
|
| 1602 | this.advancedItemTooltips = access.process("advancedItemTooltips", this.advancedItemTooltips);
|
| 1603 | this.pauseOnLostFocus = access.process("pauseOnLostFocus", this.pauseOnLostFocus);
|
| 1604 | this.overrideWidth = access.process("overrideWidth", this.overrideWidth);
|
| 1605 | this.overrideHeight = access.process("overrideHeight", this.overrideHeight);
|
| 1606 | access.process("chatHeightFocused", this.chatHeightFocused);
|
| 1607 | access.process("chatDelay", this.chatDelay);
|
| 1608 | access.process("chatHeightUnfocused", this.chatHeightUnfocused);
|
| 1609 | access.process("chatScale", this.chatScale);
|
| 1610 | access.process("chatWidth", this.chatWidth);
|
| 1611 | access.process("notificationDisplayTime", this.notificationDisplayTime);
|
| 1612 | this.useNativeTransport = access.process("useNativeTransport", this.useNativeTransport);
|
| 1613 | access.process("mainHand", this.mainHand);
|
| 1614 | access.process("attackIndicator", this.attackIndicator);
|
| 1615 | this.tutorialStep = access.process("tutorialStep", this.tutorialStep, TutorialSteps::getByName, TutorialSteps::getName);
|
| 1616 | access.process("mouseWheelSensitivity", this.mouseWheelSensitivity);
|
| 1617 | access.process("allowCursorChanges", this.allowCursorChanges);
|
| 1618 | access.process("quitShortcuts", this.quitShortcuts);
|
| 1619 | access.process("ctrlClickEmulatesRightClick", this.ctrlClickEmulatesRightClick);
|
| 1620 | this.glDebugVerbosity = access.process("glDebugVerbosity", this.glDebugVerbosity);
|
| 1621 | this.skipMultiplayerWarning = access.process("skipMultiplayerWarning", this.skipMultiplayerWarning);
|
| 1622 | access.process("hideMatchedNames", this.hideMatchedNames);
|
| 1623 | this.joinedFirstServer = access.process("joinedFirstServer", this.joinedFirstServer);
|
| 1624 | this.syncWrites = access.process("syncChunkWrites", this.syncWrites);
|
| 1625 | access.process("showAutosaveIndicator", this.showAutosaveIndicator);
|
| 1626 | access.process("allowServerListing", this.allowServerListing);
|
| 1627 | access.process("inGameNotification", this.inGameNotification);
|
| 1628 | access.process("sharePresence", this.sharePresence);
|
| 1629 | access.process("onlyShowSecureChat", this.onlyShowSecureChat);
|
| 1630 | access.process("saveChatDrafts", this.saveChatDrafts);
|
| 1631 | access.process("panoramaScrollSpeed", this.panoramaSpeed);
|
| 1632 | access.process("telemetryOptInExtra", this.telemetryOptInExtra);
|
| 1633 | this.onboardAccessibility = access.process("onboardAccessibility", this.onboardAccessibility);
|
| 1634 | access.process("menuBackgroundBlurriness", this.menuBackgroundBlurriness);
|
| 1635 | this.startedCleanly = access.process("startedCleanly", this.startedCleanly);
|
| 1636 | access.process("musicToast", this.musicToast);
|
| 1637 | access.process("musicFrequency", this.musicFrequency);
|
| 1638 |
|
| 1639 | for (KeyMapping keyMapping : this.keyMappings) {
|
| 1640 | String currentValue = keyMapping.saveString();
|
| 1641 | String newValue = access.process("key_" + keyMapping.getName(), currentValue);
|
| 1642 | if (!currentValue.equals(newValue)) {
|
| 1643 | try {
|
| 1644 | keyMapping.setKey(InputConstants.getKey(newValue));
|
| 1645 | } catch (IllegalArgumentException e) {
|
| 1646 | LOGGER.warn("Invalid keyMapping {} = {}, unbinding", keyMapping.getName(), newValue, e);
|
| 1647 | keyMapping.setKey(InputConstants.UNKNOWN);
|
| 1648 | }
|
| 1649 | }
|
| 1650 | }
|
| 1651 |
|
| 1652 | for (SoundSource source : SoundSource.values()) {
|
| 1653 | access.process("soundCategory_" + source.getName(), this.soundSourceVolumes.get(source));
|
| 1654 | }
|
| 1655 |
|
| 1656 | for (PlayerModelPart part : PlayerModelPart.values()) {
|
| 1657 | boolean wasEnabled = this.modelParts.contains(part);
|
| 1658 | boolean isEnabled = access.process("modelPart_" + part.getId(), wasEnabled);
|
| 1659 | if (isEnabled != wasEnabled) {
|
| 1660 | this.setModelPart(part, isEnabled);
|
| 1661 | }
|
| 1662 | }
|
| 1663 | }
|
| 1664 |
|
| 1665 | public void load() {
|
| 1666 | try {
|
| 1667 | if (!this.optionsFile.exists()) {
|
| 1668 | return;
|
| 1669 | }
|
| 1670 |
|
| 1671 | CompoundTag rawOptions = new CompoundTag();
|
| 1672 |
|
| 1673 | try (BufferedReader reader = Files.newReader(this.optionsFile, StandardCharsets.UTF_8)) {
|
| 1674 | reader.lines().forEach(line -> {
|
| 1675 | try {
|
| 1676 | Iterator<String> iterator = OPTION_SPLITTER.split(line).iterator();
|
| 1677 | rawOptions.putString(iterator.next(), iterator.next());
|
| 1678 | } catch (Exception ignored) {
|
| 1679 | LOGGER.warn("Skipping bad option: {}", line);
|
| 1680 | }
|
| 1681 | });
|
| 1682 | }
|
| 1683 |
|
| 1684 | final CompoundTag options = this.dataFix(rawOptions);
|
| 1685 | this.processOptions(
|
| 1686 | new Options.FieldAccess() {
|
| 1687 | private @Nullable String getValue(final String name) {
|
| 1688 | Tag tag = options.get(name);
|
| 1689 | if (tag == null) {
|
| 1690 | return null;
|
| 1691 | } else if (tag instanceof StringTag(String var7)) {
|
| 1692 | return var7;
|
| 1693 | } else {
|
| 1694 | throw new IllegalStateException("Cannot read field of wrong type, expected string: " + tag);
|
| 1695 | }
|
| 1696 | }
|
| 1697 |
|
| 1698 | @Override
|
| 1699 | public <T> void process(final String name, final OptionInstance<T> option) {
|
| 1700 | String result = this.getValue(name);
|
| 1701 | if (result != null) {
|
| 1702 | JsonElement element = LenientJsonParser.parse(result.isEmpty() ? "\"\"" : result);
|
| 1703 | option.codec()
|
| 1704 | .parse(JsonOps.INSTANCE, element)
|
| 1705 | .ifError(error -> Options.LOGGER.error("Error parsing option value {} for option {}: {}", result, option, error.message()))
|
| 1706 | .ifSuccess(option::set);
|
| 1707 | }
|
| 1708 | }
|
| 1709 |
|
| 1710 | @Override
|
| 1711 | public int process(final String name, final int current) {
|
| 1712 | String result = this.getValue(name);
|
| 1713 | if (result != null) {
|
| 1714 | try {
|
| 1715 | return Integer.parseInt(result);
|
| 1716 | } catch (NumberFormatException e) {
|
| 1717 | Options.LOGGER.warn("Invalid integer value for option {} = {}", name, result, e);
|
| 1718 | }
|
| 1719 | }
|
| 1720 |
|
| 1721 | return current;
|
| 1722 | }
|
| 1723 |
|
| 1724 | @Override
|
| 1725 | public boolean process(final String name, final boolean current) {
|
| 1726 | String result = this.getValue(name);
|
| 1727 | return result != null ? Options.isTrue(result) : current;
|
| 1728 | }
|
| 1729 |
|
| 1730 | @Override
|
| 1731 | public String process(final String name, final String current) {
|
| 1732 | return MoreObjects.firstNonNull(this.getValue(name), current);
|
| 1733 | }
|
| 1734 |
|
| 1735 | @Override
|
| 1736 | public float process(final String name, final float current) {
|
| 1737 | String result = this.getValue(name);
|
| 1738 | if (result == null) {
|
| 1739 | return current;
|
| 1740 | }
|
| 1741 |
|
| 1742 | if (Options.isTrue(result)) {
|
| 1743 | return 1.0F;
|
| 1744 | }
|
| 1745 |
|
| 1746 | if (Options.isFalse(result)) {
|
| 1747 | return 0.0F;
|
| 1748 | }
|
| 1749 |
|
| 1750 | try {
|
| 1751 | return Float.parseFloat(result);
|
| 1752 | } catch (NumberFormatException e) {
|
| 1753 | Options.LOGGER.warn("Invalid floating point value for option {} = {}", name, result, e);
|
| 1754 | return current;
|
| 1755 | }
|
| 1756 | }
|
| 1757 |
|
| 1758 | @Override
|
| 1759 | public <T> T process(final String name, final T current, final Function<String, T> reader, final Function<T, String> writer) {
|
| 1760 | String rawResult = this.getValue(name);
|
| 1761 | return rawResult == null ? current : reader.apply(rawResult);
|
| 1762 | }
|
| 1763 | }
|
| 1764 | );
|
| 1765 | options.getString("fullscreenResolution").ifPresent(fullscreenResolution -> this.fullscreenVideoModeString = fullscreenResolution);
|
| 1766 | KeyMapping.resetMapping();
|
| 1767 | } catch (Exception e) {
|
| 1768 | LOGGER.error("Failed to load options", e);
|
| 1769 | }
|
| 1770 |
|
| 1771 | this.preferredGraphicsBackendFromStartup = this.preferredGraphicsBackend.get();
|
| 1772 | }
|
| 1773 |
|
| 1774 | private static boolean isTrue(final String value) {
|
| 1775 | return "true".equals(value);
|
| 1776 | }
|
| 1777 |
|
| 1778 | private static boolean isFalse(final String value) {
|
| 1779 | return "false".equals(value);
|
| 1780 | }
|
| 1781 |
|
| 1782 | private CompoundTag dataFix(final CompoundTag tag) {
|
| 1783 | int version = 0;
|
| 1784 |
|
| 1785 | try {
|
| 1786 | version = tag.getString("version").map(Integer::parseInt).orElse(0);
|
| 1787 | } catch (RuntimeException var4) {
|
| 1788 | }
|
| 1789 |
|
| 1790 | return DataFixTypes.OPTIONS.updateToCurrentVersion(this.minecraft.getFixerUpper(), tag, version);
|
| 1791 | }
|
| 1792 |
|
| 1793 | public void save() {
|
| 1794 | try (final PrintWriter writer = new PrintWriter(new OutputStreamWriter(new FileOutputStream(this.optionsFile), StandardCharsets.UTF_8))) {
|
| 1795 | writer.println("version:" + SharedConstants.getCurrentVersion().dataVersion().version());
|
| 1796 | this.processOptions(
|
| 1797 | new Options.FieldAccess() {
|
| 1798 | public void writePrefix(final String name) {
|
| 1799 | writer.print(name);
|
| 1800 | writer.print(':');
|
| 1801 | }
|
| 1802 |
|
| 1803 | @Override
|
| 1804 | public <T> void process(final String name, final OptionInstance<T> option) {
|
| 1805 | option.codec()
|
| 1806 | .encodeStart(JsonOps.INSTANCE, option.get())
|
| 1807 | .ifError(error -> Options.LOGGER.error("Error saving option {}: {}", option, error.message()))
|
| 1808 | .ifSuccess(element -> {
|
| 1809 | this.writePrefix(name);
|
| 1810 | writer.println(Options.GSON.toJson(element));
|
| 1811 | });
|
| 1812 | }
|
| 1813 |
|
| 1814 | @Override
|
| 1815 | public int process(final String name, final int value) {
|
| 1816 | this.writePrefix(name);
|
| 1817 | writer.println(value);
|
| 1818 | return value;
|
| 1819 | }
|
| 1820 |
|
| 1821 | @Override
|
| 1822 | public boolean process(final String name, final boolean value) {
|
| 1823 | this.writePrefix(name);
|
| 1824 | writer.println(value);
|
| 1825 | return value;
|
| 1826 | }
|
| 1827 |
|
| 1828 | @Override
|
| 1829 | public String process(final String name, final String value) {
|
| 1830 | this.writePrefix(name);
|
| 1831 | writer.println(value);
|
| 1832 | return value;
|
| 1833 | }
|
| 1834 |
|
| 1835 | @Override
|
| 1836 | public float process(final String name, final float value) {
|
| 1837 | this.writePrefix(name);
|
| 1838 | writer.println(value);
|
| 1839 | return value;
|
| 1840 | }
|
| 1841 |
|
| 1842 | @Override
|
| 1843 | public <T> T process(final String name, final T value, final Function<String, T> reader, final Function<T, String> converter) {
|
| 1844 | this.writePrefix(name);
|
| 1845 | writer.println(converter.apply(value));
|
| 1846 | return value;
|
| 1847 | }
|
| 1848 | }
|
| 1849 | );
|
| 1850 | String fullscreenVideoModeString = this.getFullscreenVideoModeString();
|
| 1851 | if (fullscreenVideoModeString != null) {
|
| 1852 | writer.println("fullscreenResolution:" + fullscreenVideoModeString);
|
| 1853 | }
|
| 1854 | } catch (Exception e) {
|
| 1855 | LOGGER.error("Failed to save options", e);
|
| 1856 | }
|
| 1857 |
|
| 1858 | this.broadcastOptions();
|
| 1859 | }
|
| 1860 |
|
| 1861 | private @Nullable String getFullscreenVideoModeString() {
|
| 1862 | Window window = this.minecraft.getWindow();
|
| 1863 | if (window == null) {
|
| 1864 | return this.fullscreenVideoModeString;
|
| 1865 | } else {
|
| 1866 | return window.getPreferredFullscreenVideoMode().isPresent() ? window.getPreferredFullscreenVideoMode().get().write() : null;
|
| 1867 | }
|
| 1868 | }
|
| 1869 |
|
| 1870 | public ClientInformation buildPlayerInformation() {
|
| 1871 | int parts = 0;
|
| 1872 |
|
| 1873 | for (PlayerModelPart part : this.modelParts) {
|
| 1874 | parts |= part.getMask();
|
| 1875 | }
|
| 1876 |
|
| 1877 | return new ClientInformation(
|
| 1878 | this.languageCode,
|
| 1879 | this.renderDistance.get(),
|
| 1880 | this.chatVisibility.get(),
|
| 1881 | this.chatColors.get(),
|
| 1882 | parts,
|
| 1883 | this.mainHand.get(),
|
| 1884 | this.minecraft.isTextFilteringEnabled(),
|
| 1885 | this.allowServerListing.get(),
|
| 1886 | this.particles.get()
|
| 1887 | );
|
| 1888 | }
|
| 1889 |
|
| 1890 | public void broadcastOptions() {
|
| 1891 | if (this.minecraft.player != null) {
|
| 1892 | this.minecraft.player.connection.broadcastClientInformation(this.buildPlayerInformation());
|
| 1893 | }
|
| 1894 | }
|
| 1895 |
|
| 1896 | public void setModelPart(final PlayerModelPart part, final boolean visible) {
|
| 1897 | if (visible) {
|
| 1898 | this.modelParts.add(part);
|
| 1899 | } else {
|
| 1900 | this.modelParts.remove(part);
|
| 1901 | }
|
| 1902 | }
|
| 1903 |
|
| 1904 | public boolean isModelPartEnabled(final PlayerModelPart part) {
|
| 1905 | return this.modelParts.contains(part);
|
| 1906 | }
|
| 1907 |
|
| 1908 | public CloudStatus getCloudStatus() {
|
| 1909 | return this.cloudStatus.get();
|
| 1910 | }
|
| 1911 |
|
| 1912 | public boolean useNativeTransport() {
|
| 1913 | return this.useNativeTransport;
|
| 1914 | }
|
| 1915 |
|
| 1916 | public void loadSelectedResourcePacks(final PackRepository repository) {
|
| 1917 | Set<String> selected = Sets.newLinkedHashSet();
|
| 1918 | Iterator<String> iterator = this.resourcePacks.iterator();
|
| 1919 |
|
| 1920 | while (iterator.hasNext()) {
|
| 1921 | String id = iterator.next();
|
| 1922 | Pack pack = repository.getPack(id);
|
| 1923 | if (pack == null && !id.startsWith("file/")) {
|
| 1924 | pack = repository.getPack("file/" + id);
|
| 1925 | }
|
| 1926 |
|
| 1927 | if (pack == null) {
|
| 1928 | LOGGER.warn("Removed resource pack {} from options because it doesn't seem to exist anymore", id);
|
| 1929 | iterator.remove();
|
| 1930 | } else if (!pack.getCompatibility().isCompatible() && !this.incompatibleResourcePacks.contains(id)) {
|
| 1931 | LOGGER.warn("Removed resource pack {} from options because it is no longer compatible", id);
|
| 1932 | iterator.remove();
|
| 1933 | } else if (pack.getCompatibility().isCompatible() && this.incompatibleResourcePacks.contains(id)) {
|
| 1934 | LOGGER.info("Removed resource pack {} from incompatibility list because it's now compatible", id);
|
| 1935 | this.incompatibleResourcePacks.remove(id);
|
| 1936 | } else {
|
| 1937 | selected.add(pack.getId());
|
| 1938 | }
|
| 1939 | }
|
| 1940 |
|
| 1941 | repository.setSelected(selected);
|
| 1942 | }
|
| 1943 |
|
| 1944 | public CameraType getCameraType() {
|
| 1945 | return this.cameraType;
|
| 1946 | }
|
| 1947 |
|
| 1948 | public void setCameraType(final CameraType cameraType) {
|
| 1949 | this.cameraType = cameraType;
|
| 1950 | }
|
| 1951 |
|
| 1952 | private static List<String> readListOfStrings(final String value) {
|
| 1953 | List<String> result = GsonHelper.fromNullableJson(GSON, value, LIST_OF_STRINGS_TYPE);
|
| 1954 | return result != null ? result : Lists.newArrayList();
|
| 1955 | }
|
| 1956 |
|
| 1957 | public File getFile() {
|
| 1958 | return this.optionsFile;
|
| 1959 | }
|
| 1960 |
|
| 1961 | public String dumpOptionsForReport() {
|
| 1962 | final List<Pair<String, Object>> optionsForReport = new ArrayList<>();
|
| 1963 | this.processDumpedOptions(new Options.OptionAccess() {
|
| 1964 | @Override
|
| 1965 | public <T> void process(final String name, final OptionInstance<T> option) {
|
| 1966 | optionsForReport.add(Pair.of(name, option.get()));
|
| 1967 | }
|
| 1968 | });
|
| 1969 | optionsForReport.add(Pair.of("fullscreenResolution", String.valueOf(this.fullscreenVideoModeString)));
|
| 1970 | optionsForReport.add(Pair.of("glDebugVerbosity", this.glDebugVerbosity));
|
| 1971 | optionsForReport.add(Pair.of("overrideHeight", this.overrideHeight));
|
| 1972 | optionsForReport.add(Pair.of("overrideWidth", this.overrideWidth));
|
| 1973 | optionsForReport.add(Pair.of("syncChunkWrites", this.syncWrites));
|
| 1974 | optionsForReport.add(Pair.of("useNativeTransport", this.useNativeTransport));
|
| 1975 | optionsForReport.add(Pair.of("resourcePacks", this.resourcePacks));
|
| 1976 | return optionsForReport.stream()
|
| 1977 | .sorted(Comparator.comparing(Pair::getFirst))
|
| 1978 | .map(e -> e.getFirst() + ": " + e.getSecond())
|
| 1979 | .collect(Collectors.joining(System.lineSeparator()));
|
| 1980 | }
|
| 1981 |
|
| 1982 | public void setServerRenderDistance(final int serverRenderDistance) {
|
| 1983 | this.serverRenderDistance = serverRenderDistance;
|
| 1984 | }
|
| 1985 |
|
| 1986 | public int getEffectiveRenderDistance() {
|
| 1987 | return this.serverRenderDistance > 0 ? Math.min(this.renderDistance.get(), this.serverRenderDistance) : this.renderDistance.get();
|
| 1988 | }
|
| 1989 |
|
| 1990 | private static Component pixelValueLabel(final Component caption, final int value) {
|
| 1991 | return Component.translatable("options.pixel_value", caption, value);
|
| 1992 | }
|
| 1993 |
|
| 1994 | private static Component percentValueLabel(final Component caption, final double value) {
|
| 1995 | return Component.translatable("options.percent_value", caption, (int)(value * 100.0));
|
| 1996 | }
|
| 1997 |
|
| 1998 | public static Component genericValueLabel(final Component caption, final Component value) {
|
| 1999 | return Component.translatable("options.generic_value", caption, value);
|
| 2000 | }
|
| 2001 |
|
| 2002 | public static Component genericValueLabel(final Component caption, final int value) {
|
| 2003 | return genericValueLabel(caption, Component.literal(Integer.toString(value)));
|
| 2004 | }
|
| 2005 |
|
| 2006 | public static Component genericValueOrOffLabel(final Component caption, final int value) {
|
| 2007 | return value == 0 ? genericValueLabel(caption, CommonComponents.OPTION_OFF) : genericValueLabel(caption, value);
|
| 2008 | }
|
| 2009 |
|
| 2010 | private static Component percentValueOrOffLabel(final Component caption, final double value) {
|
| 2011 | return value == 0.0 ? genericValueLabel(caption, CommonComponents.OPTION_OFF) : percentValueLabel(caption, value);
|
| 2012 | }
|
| 2013 |
|
| 2014 | @Environment(EnvType.CLIENT)
|
| 2015 | private interface FieldAccess extends Options.OptionAccess {
|
| 2016 | int process(String name, int value);
|
| 2017 |
|
| 2018 | boolean process(String name, boolean value);
|
| 2019 |
|
| 2020 | String process(String name, String value);
|
| 2021 |
|
| 2022 | float process(String name, float value);
|
| 2023 |
|
| 2024 | <T> T process(String name, T value, Function<String, T> reader, Function<T, String> writer);
|
| 2025 | }
|
| 2026 |
|
| 2027 | @Environment(EnvType.CLIENT)
|
| 2028 | private interface OptionAccess {
|
| 2029 | <T> void process(String name, OptionInstance<T> option);
|
| 2030 | }
|
| 2031 | }
|
| 2032 |
|