GameSettings .java

net.minecraft.client.settings.GameSettings (class): members: showInventoryAchievementHint, incompatibleResourcePacks, keyBindStreamPauseUnpause, clouds.

net.minecraft.client.settingsclass1,407 linesclient56.8 KB

API Surface (32)

Type[] getActualTypeArguments()
Type getRawType()
Type getOwnerType()
String getKeyDisplayString(int key)
boolean isKeyDown(KeyBinding key)
void setOptionKeyBinding(KeyBinding key, int keyCode)
void setOptionFloatValue(GameSettings.Options settingsOption, float value)
void setOptionValue(GameSettings.Options settingsOption, int value)
float getOptionFloatValue(GameSettings.Options settingOption)
boolean getOptionOrdinalValue(GameSettings.Options settingOption)
String getKeyBinding(GameSettings.Options settingOption)
void loadOptions()
void saveOptions()
float getSoundLevel(SoundCategory sndCategory)
void setSoundLevel(SoundCategory sndCategory, float soundLevel)
void sendSettingsToServer()
Set<EnumPlayerModelParts> getModelParts()
void setModelPartEnabled(EnumPlayerModelParts modelPart, boolean enable)
void switchModelPartEnabled(EnumPlayerModelParts modelPart)
int shouldRenderClouds()
boolean isUsingNativeTransport()
GameSettings.Options getEnumOptions(int ordinal)
boolean getEnumFloat()
boolean getEnumBoolean()
int returnEnumOrdinal()
String getEnumString()
float getValueMax()
void setValueMax(float value)
float normalizeValue(float value)
float denormalizeValue(float value)
float snapToStepClamp(float value)
float snapToStep(float value)

Fields & Constants (107)

logger
gson
typeListString
GUISCALES
PARTICLES
AMBIENT_OCCLUSIONS
STREAM_COMPRESSIONS
STREAM_CHAT_MODES
STREAM_CHAT_FILTER_MODES
STREAM_MIC_MODES
CLOUDS_TYPES
mouseSensitivity
invertMouse
renderDistanceChunks
viewBobbing
anaglyph
fboEnable
limitFramerate
clouds
fancyGraphics
ambientOcclusion
resourcePacks
incompatibleResourcePacks
chatVisibility
chatColours
chatLinks
chatLinksPrompt
chatOpacity
snooperEnabled
fullScreen
enableVsync
useVbo
allowBlockAlternatives
reducedDebugInfo
hideServerAddress

…and 72 more (see full source).

String literals (246)

"options.guiScale.auto"
"options.guiScale.small"
"options.guiScale.normal"
"options.guiScale.large"
"options.particles.all"
"options.particles.decreased"
"options.particles.minimal"
"options.ao.off"
"options.ao.min"
"options.ao.max"
"options.stream.compression.low"
"options.stream.compression.medium"
"options.stream.compression.high"
"options.stream.chat.enabled.streaming"
"options.stream.chat.enabled.always"
"options.stream.chat.enabled.never"
"options.stream.chat.userFilter.all"
"options.stream.chat.userFilter.subs"
"options.stream.chat.userFilter.mods"
"options.stream.mic_toggle.mute"
"options.stream.mic_toggle.talk"
"options.off"
"options.graphics.fast"
"options.graphics.fancy"

Same Package (1)

Full Source

GameSettings.java1407 lines · MCP 1.8.9 · verbatimOriginal ↗
1
package net.minecraft.client.settings;
2
3
import com.google.common.collect.ImmutableSet;
4
import com.google.common.collect.Lists;
5
import com.google.common.collect.Maps;
6
import com.google.common.collect.Sets;
7
import com.google.gson.Gson;
8
import java.io.BufferedReader;
9
import java.io.File;
10
import java.io.FileReader;
11
import java.io.FileWriter;
12
import java.io.PrintWriter;
13
import java.lang.reflect.ParameterizedType;
14
import java.lang.reflect.Type;
15
import java.util.List;
16
import java.util.Map;
17
import java.util.Set;
18
import net.minecraft.client.Minecraft;
19
import net.minecraft.client.audio.SoundCategory;
20
import net.minecraft.client.gui.GuiNewChat;
21
import net.minecraft.client.renderer.texture.TextureMap;
22
import net.minecraft.client.resources.I18n;
23
import net.minecraft.client.stream.TwitchStream;
24
import net.minecraft.entity.player.EntityPlayer;
25
import net.minecraft.entity.player.EnumPlayerModelParts;
26
import net.minecraft.network.play.client.C15PacketClientSettings;
27
import net.minecraft.util.MathHelper;
28
import net.minecraft.world.EnumDifficulty;
29
import org.apache.commons.lang3.ArrayUtils;
30
import org.apache.logging.log4j.LogManager;
31
import org.apache.logging.log4j.Logger;
32
import org.lwjgl.input.Keyboard;
33
import org.lwjgl.input.Mouse;
34
import org.lwjgl.opengl.Display;
35
36
public class GameSettings
37
{
38
    private static final Logger logger = LogManager.getLogger();
39
    private static final Gson gson = new Gson();
40
    private static final ParameterizedType typeListString = new ParameterizedType()
41
    {
42
        public Type[] getActualTypeArguments()
43
        {
44
            return new Type[] {String.class};
45
        }
46
        public Type getRawType()
47
        {
48
            return List.class;
49
        }
50
        public Type getOwnerType()
51
        {
52
            return null;
53
        }
54
    };
55
56
    /** GUI scale values */
57
    private static final String[] GUISCALES = new String[] {"options.guiScale.auto", "options.guiScale.small", "options.guiScale.normal", "options.guiScale.large"};
58
    private static final String[] PARTICLES = new String[] {"options.particles.all", "options.particles.decreased", "options.particles.minimal"};
59
    private static final String[] AMBIENT_OCCLUSIONS = new String[] {"options.ao.off", "options.ao.min", "options.ao.max"};
60
    private static final String[] STREAM_COMPRESSIONS = new String[] {"options.stream.compression.low", "options.stream.compression.medium", "options.stream.compression.high"};
61
    private static final String[] STREAM_CHAT_MODES = new String[] {"options.stream.chat.enabled.streaming", "options.stream.chat.enabled.always", "options.stream.chat.enabled.never"};
62
    private static final String[] STREAM_CHAT_FILTER_MODES = new String[] {"options.stream.chat.userFilter.all", "options.stream.chat.userFilter.subs", "options.stream.chat.userFilter.mods"};
63
    private static final String[] STREAM_MIC_MODES = new String[] {"options.stream.mic_toggle.mute", "options.stream.mic_toggle.talk"};
64
    private static final String[] CLOUDS_TYPES = new String[] {"options.off", "options.graphics.fast", "options.graphics.fancy"};
65
    public float mouseSensitivity = 0.5F;
66
    public boolean invertMouse;
67
    public int renderDistanceChunks = -1;
68
    public boolean viewBobbing = true;
69
    public boolean anaglyph;
70
    public boolean fboEnable = true;
71
    public int limitFramerate = 120;
72
73
    /** Clouds flag */
74
    public int clouds = 2;
75
    public boolean fancyGraphics = true;
76
77
    /** Smooth Lighting */
78
    public int ambientOcclusion = 2;
79
    public List<String> resourcePacks = Lists.<String>newArrayList();
80
    public List<String> incompatibleResourcePacks = Lists.<String>newArrayList();
81
    public EntityPlayer.EnumChatVisibility chatVisibility = EntityPlayer.EnumChatVisibility.FULL;
82
    public boolean chatColours = true;
83
    public boolean chatLinks = true;
84
    public boolean chatLinksPrompt = true;
85
    public float chatOpacity = 1.0F;
86
    public boolean snooperEnabled = true;
87
    public boolean fullScreen;
88
    public boolean enableVsync = true;
89
    public boolean useVbo = false;
90
    public boolean allowBlockAlternatives = true;
91
    public boolean reducedDebugInfo = false;
92
    public boolean hideServerAddress;
93
94
    /**
95
     * Whether to show advanced information on item tooltips, toggled by F3+H
96
     */
97
    public boolean advancedItemTooltips;
98
99
    /** Whether to pause when the game loses focus, toggled by F3+P */
100
    public boolean pauseOnLostFocus = true;
101
    private final Set<EnumPlayerModelParts> setModelParts = Sets.newHashSet(EnumPlayerModelParts.values());
102
    public boolean touchscreen;
103
    public int overrideWidth;
104
    public int overrideHeight;
105
    public boolean heldItemTooltips = true;
106
    public float chatScale = 1.0F;
107
    public float chatWidth = 1.0F;
108
    public float chatHeightUnfocused = 0.44366196F;
109
    public float chatHeightFocused = 1.0F;
110
    public boolean showInventoryAchievementHint = true;
111
    public int mipmapLevels = 4;
112
    private Map<SoundCategory, Float> mapSoundLevels = Maps.newEnumMap(SoundCategory.class);
113
    public float streamBytesPerPixel = 0.5F;
114
    public float streamMicVolume = 1.0F;
115
    public float streamGameVolume = 1.0F;
116
    public float streamKbps = 0.5412844F;
117
    public float streamFps = 0.31690142F;
118
    public int streamCompression = 1;
119
    public boolean streamSendMetadata = true;
120
    public String streamPreferredServer = "";
121
    public int streamChatEnabled = 0;
122
    public int streamChatUserFilter = 0;
123
    public int streamMicToggleBehavior = 0;
124
    public boolean useNativeTransport = true;
125
    public boolean entityShadows = true;
126
    public boolean realmsNotifications = true;
127
    public KeyBinding keyBindForward = new KeyBinding("key.forward", 17, "key.categories.movement");
128
    public KeyBinding keyBindLeft = new KeyBinding("key.left", 30, "key.categories.movement");
129
    public KeyBinding keyBindBack = new KeyBinding("key.back", 31, "key.categories.movement");
130
    public KeyBinding keyBindRight = new KeyBinding("key.right", 32, "key.categories.movement");
131
    public KeyBinding keyBindJump = new KeyBinding("key.jump", 57, "key.categories.movement");
132
    public KeyBinding keyBindSneak = new KeyBinding("key.sneak", 42, "key.categories.movement");
133
    public KeyBinding keyBindSprint = new KeyBinding("key.sprint", 29, "key.categories.movement");
134
    public KeyBinding keyBindInventory = new KeyBinding("key.inventory", 18, "key.categories.inventory");
135
    public KeyBinding keyBindUseItem = new KeyBinding("key.use", -99, "key.categories.gameplay");
136
    public KeyBinding keyBindDrop = new KeyBinding("key.drop", 16, "key.categories.gameplay");
137
    public KeyBinding keyBindAttack = new KeyBinding("key.attack", -100, "key.categories.gameplay");
138
    public KeyBinding keyBindPickBlock = new KeyBinding("key.pickItem", -98, "key.categories.gameplay");
139
    public KeyBinding keyBindChat = new KeyBinding("key.chat", 20, "key.categories.multiplayer");
140
    public KeyBinding keyBindPlayerList = new KeyBinding("key.playerlist", 15, "key.categories.multiplayer");
141
    public KeyBinding keyBindCommand = new KeyBinding("key.command", 53, "key.categories.multiplayer");
142
    public KeyBinding keyBindScreenshot = new KeyBinding("key.screenshot", 60, "key.categories.misc");
143
    public KeyBinding keyBindTogglePerspective = new KeyBinding("key.togglePerspective", 63, "key.categories.misc");
144
    public KeyBinding keyBindSmoothCamera = new KeyBinding("key.smoothCamera", 0, "key.categories.misc");
145
    public KeyBinding keyBindFullscreen = new KeyBinding("key.fullscreen", 87, "key.categories.misc");
146
    public KeyBinding keyBindSpectatorOutlines = new KeyBinding("key.spectatorOutlines", 0, "key.categories.misc");
147
    public KeyBinding keyBindStreamStartStop = new KeyBinding("key.streamStartStop", 64, "key.categories.stream");
148
    public KeyBinding keyBindStreamPauseUnpause = new KeyBinding("key.streamPauseUnpause", 65, "key.categories.stream");
149
    public KeyBinding keyBindStreamCommercials = new KeyBinding("key.streamCommercial", 0, "key.categories.stream");
150
    public KeyBinding keyBindStreamToggleMic = new KeyBinding("key.streamToggleMic", 0, "key.categories.stream");
151
    public KeyBinding[] keyBindsHotbar = new KeyBinding[] {new KeyBinding("key.hotbar.1", 2, "key.categories.inventory"), new KeyBinding("key.hotbar.2", 3, "key.categories.inventory"), new KeyBinding("key.hotbar.3", 4, "key.categories.inventory"), new KeyBinding("key.hotbar.4", 5, "key.categories.inventory"), new KeyBinding("key.hotbar.5", 6, "key.categories.inventory"), new KeyBinding("key.hotbar.6", 7, "key.categories.inventory"), new KeyBinding("key.hotbar.7", 8, "key.categories.inventory"), new KeyBinding("key.hotbar.8", 9, "key.categories.inventory"), new KeyBinding("key.hotbar.9", 10, "key.categories.inventory")};
152
    public KeyBinding[] keyBindings;
153
    protected Minecraft mc;
154
    private File optionsFile;
155
    public EnumDifficulty difficulty;
156
    public boolean hideGUI;
157
    public int thirdPersonView;
158
159
    /** true if debug info should be displayed instead of version */
160
    public boolean showDebugInfo;
161
    public boolean showDebugProfilerChart;
162
    public boolean showLagometer;
163
164
    /** The lastServer string. */
165
    public String lastServer;
166
167
    /** Smooth Camera Toggle */
168
    public boolean smoothCamera;
169
    public boolean debugCamEnable;
170
    public float fovSetting;
171
    public float gammaSetting;
172
    public float saturation;
173
174
    /** GUI scale */
175
    public int guiScale;
176
177
    /** Determines amount of particles. 0 = All, 1 = Decreased, 2 = Minimal */
178
    public int particleSetting;
179
180
    /** Game settings language */
181
    public String language;
182
    public boolean forceUnicodeFont;
183
184
    public GameSettings(Minecraft mcIn, File optionsFileIn)
185
    {
186
        this.keyBindings = (KeyBinding[])ArrayUtils.addAll(new KeyBinding[] {this.keyBindAttack, this.keyBindUseItem, this.keyBindForward, this.keyBindLeft, this.keyBindBack, this.keyBindRight, this.keyBindJump, this.keyBindSneak, this.keyBindSprint, this.keyBindDrop, this.keyBindInventory, this.keyBindChat, this.keyBindPlayerList, this.keyBindPickBlock, this.keyBindCommand, this.keyBindScreenshot, this.keyBindTogglePerspective, this.keyBindSmoothCamera, this.keyBindStreamStartStop, this.keyBindStreamPauseUnpause, this.keyBindStreamCommercials, this.keyBindStreamToggleMic, this.keyBindFullscreen, this.keyBindSpectatorOutlines}, this.keyBindsHotbar);
187
        this.difficulty = EnumDifficulty.NORMAL;
188
        this.lastServer = "";
189
        this.fovSetting = 70.0F;
190
        this.language = "en_US";
191
        this.forceUnicodeFont = false;
192
        this.mc = mcIn;
193
        this.optionsFile = new File(optionsFileIn, "options.txt");
194
195
        if (mcIn.isJava64bit() && Runtime.getRuntime().maxMemory() >= 1000000000L)
196
        {
197
            GameSettings.Options.RENDER_DISTANCE.setValueMax(32.0F);
198
        }
199
        else
200
        {
201
            GameSettings.Options.RENDER_DISTANCE.setValueMax(16.0F);
202
        }
203
204
        this.renderDistanceChunks = mcIn.isJava64bit() ? 12 : 8;
205
        this.loadOptions();
206
    }
207
208
    public GameSettings()
209
    {
210
        this.keyBindings = (KeyBinding[])ArrayUtils.addAll(new KeyBinding[] {this.keyBindAttack, this.keyBindUseItem, this.keyBindForward, this.keyBindLeft, this.keyBindBack, this.keyBindRight, this.keyBindJump, this.keyBindSneak, this.keyBindSprint, this.keyBindDrop, this.keyBindInventory, this.keyBindChat, this.keyBindPlayerList, this.keyBindPickBlock, this.keyBindCommand, this.keyBindScreenshot, this.keyBindTogglePerspective, this.keyBindSmoothCamera, this.keyBindStreamStartStop, this.keyBindStreamPauseUnpause, this.keyBindStreamCommercials, this.keyBindStreamToggleMic, this.keyBindFullscreen, this.keyBindSpectatorOutlines}, this.keyBindsHotbar);
211
        this.difficulty = EnumDifficulty.NORMAL;
212
        this.lastServer = "";
213
        this.fovSetting = 70.0F;
214
        this.language = "en_US";
215
        this.forceUnicodeFont = false;
216
    }
217
218
    /**
219
     * Represents a key or mouse button as a string. Args: key
220
     *  
221
     * @param key The key to display
222
     */
223
    public static String getKeyDisplayString(int key)
224
    {
225
        return key < 0 ? I18n.format("key.mouseButton", new Object[] {Integer.valueOf(key + 101)}): (key < 256 ? Keyboard.getKeyName(key) : String.format("%c", new Object[] {Character.valueOf((char)(key - 256))}).toUpperCase());
226
    }
227
228
    /**
229
     * Returns whether the specified key binding is currently being pressed.
230
     *  
231
     * @param key The key tested
232
     */
233
    public static boolean isKeyDown(KeyBinding key)
234
    {
235
        return key.getKeyCode() == 0 ? false : (key.getKeyCode() < 0 ? Mouse.isButtonDown(key.getKeyCode() + 100) : Keyboard.isKeyDown(key.getKeyCode()));
236
    }
237
238
    /**
239
     * Sets a key binding and then saves all settings.
240
     *  
241
     * @param key The key that the option will be set
242
     * @param keyCode The option (keycode) to set.
243
     */
244
    public void setOptionKeyBinding(KeyBinding key, int keyCode)
245
    {
246
        key.setKeyCode(keyCode);
247
        this.saveOptions();
248
    }
249
250
    /**
251
     * If the specified option is controlled by a slider (float value), this will set the float value.
252
     *  
253
     * @param settingsOption The option to set to a value
254
     * @param value The value that the option will take
255
     */
256
    public void setOptionFloatValue(GameSettings.Options settingsOption, float value)
257
    {
258
        if (settingsOption == GameSettings.Options.SENSITIVITY)
259
        {
260
            this.mouseSensitivity = value;
261
        }
262
263
        if (settingsOption == GameSettings.Options.FOV)
264
        {
265
            this.fovSetting = value;
266
        }
267
268
        if (settingsOption == GameSettings.Options.GAMMA)
269
        {
270
            this.gammaSetting = value;
271
        }
272
273
        if (settingsOption == GameSettings.Options.FRAMERATE_LIMIT)
274
        {
275
            this.limitFramerate = (int)value;
276
        }
277
278
        if (settingsOption == GameSettings.Options.CHAT_OPACITY)
279
        {
280
            this.chatOpacity = value;
281
            this.mc.ingameGUI.getChatGUI().refreshChat();
282
        }
283
284
        if (settingsOption == GameSettings.Options.CHAT_HEIGHT_FOCUSED)
285
        {
286
            this.chatHeightFocused = value;
287
            this.mc.ingameGUI.getChatGUI().refreshChat();
288
        }
289
290
        if (settingsOption == GameSettings.Options.CHAT_HEIGHT_UNFOCUSED)
291
        {
292
            this.chatHeightUnfocused = value;
293
            this.mc.ingameGUI.getChatGUI().refreshChat();
294
        }
295
296
        if (settingsOption == GameSettings.Options.CHAT_WIDTH)
297
        {
298
            this.chatWidth = value;
299
            this.mc.ingameGUI.getChatGUI().refreshChat();
300
        }
301
302
        if (settingsOption == GameSettings.Options.CHAT_SCALE)
303
        {
304
            this.chatScale = value;
305
            this.mc.ingameGUI.getChatGUI().refreshChat();
306
        }
307
308
        if (settingsOption == GameSettings.Options.MIPMAP_LEVELS)
309
        {
310
            int i = this.mipmapLevels;
311
            this.mipmapLevels = (int)value;
312
313
            if ((float)i != value)
314
            {
315
                this.mc.getTextureMapBlocks().setMipmapLevels(this.mipmapLevels);
316
                this.mc.getTextureManager().bindTexture(TextureMap.locationBlocksTexture);
317
                this.mc.getTextureMapBlocks().setBlurMipmapDirect(false, this.mipmapLevels > 0);
318
                this.mc.scheduleResourcesRefresh();
319
            }
320
        }
321
322
        if (settingsOption == GameSettings.Options.BLOCK_ALTERNATIVES)
323
        {
324
            this.allowBlockAlternatives = !this.allowBlockAlternatives;
325
            this.mc.renderGlobal.loadRenderers();
326
        }
327
328
        if (settingsOption == GameSettings.Options.RENDER_DISTANCE)
329
        {
330
            this.renderDistanceChunks = (int)value;
331
            this.mc.renderGlobal.setDisplayListEntitiesDirty();
332
        }
333
334
        if (settingsOption == GameSettings.Options.STREAM_BYTES_PER_PIXEL)
335
        {
336
            this.streamBytesPerPixel = value;
337
        }
338
339
        if (settingsOption == GameSettings.Options.STREAM_VOLUME_MIC)
340
        {
341
            this.streamMicVolume = value;
342
            this.mc.getTwitchStream().updateStreamVolume();
343
        }
344
345
        if (settingsOption == GameSettings.Options.STREAM_VOLUME_SYSTEM)
346
        {
347
            this.streamGameVolume = value;
348
            this.mc.getTwitchStream().updateStreamVolume();
349
        }
350
351
        if (settingsOption == GameSettings.Options.STREAM_KBPS)
352
        {
353
            this.streamKbps = value;
354
        }
355
356
        if (settingsOption == GameSettings.Options.STREAM_FPS)
357
        {
358
            this.streamFps = value;
359
        }
360
    }
361
362
    /**
363
     * For non-float options. Toggles the option on/off, or cycles through the list i.e. render distances.
364
     *  
365
     * @param settingsOption The option to set to a value
366
     * @param value The value that the option will take
367
     */
368
    public void setOptionValue(GameSettings.Options settingsOption, int value)
369
    {
370
        if (settingsOption == GameSettings.Options.INVERT_MOUSE)
371
        {
372
            this.invertMouse = !this.invertMouse;
373
        }
374
375
        if (settingsOption == GameSettings.Options.GUI_SCALE)
376
        {
377
            this.guiScale = this.guiScale + value & 3;
378
        }
379
380
        if (settingsOption == GameSettings.Options.PARTICLES)
381
        {
382
            this.particleSetting = (this.particleSetting + value) % 3;
383
        }
384
385
        if (settingsOption == GameSettings.Options.VIEW_BOBBING)
386
        {
387
            this.viewBobbing = !this.viewBobbing;
388
        }
389
390
        if (settingsOption == GameSettings.Options.RENDER_CLOUDS)
391
        {
392
            this.clouds = (this.clouds + value) % 3;
393
        }
394
395
        if (settingsOption == GameSettings.Options.FORCE_UNICODE_FONT)
396
        {
397
            this.forceUnicodeFont = !this.forceUnicodeFont;
398
            this.mc.fontRendererObj.setUnicodeFlag(this.mc.getLanguageManager().isCurrentLocaleUnicode() || this.forceUnicodeFont);
399
        }
400
401
        if (settingsOption == GameSettings.Options.FBO_ENABLE)
402
        {
403
            this.fboEnable = !this.fboEnable;
404
        }
405
406
        if (settingsOption == GameSettings.Options.ANAGLYPH)
407
        {
408
            this.anaglyph = !this.anaglyph;
409
            this.mc.refreshResources();
410
        }
411
412
        if (settingsOption == GameSettings.Options.GRAPHICS)
413
        {
414
            this.fancyGraphics = !this.fancyGraphics;
415
            this.mc.renderGlobal.loadRenderers();
416
        }
417
418
        if (settingsOption == GameSettings.Options.AMBIENT_OCCLUSION)
419
        {
420
            this.ambientOcclusion = (this.ambientOcclusion + value) % 3;
421
            this.mc.renderGlobal.loadRenderers();
422
        }
423
424
        if (settingsOption == GameSettings.Options.CHAT_VISIBILITY)
425
        {
426
            this.chatVisibility = EntityPlayer.EnumChatVisibility.getEnumChatVisibility((this.chatVisibility.getChatVisibility() + value) % 3);
427
        }
428
429
        if (settingsOption == GameSettings.Options.STREAM_COMPRESSION)
430
        {
431
            this.streamCompression = (this.streamCompression + value) % 3;
432
        }
433
434
        if (settingsOption == GameSettings.Options.STREAM_SEND_METADATA)
435
        {
436
            this.streamSendMetadata = !this.streamSendMetadata;
437
        }
438
439
        if (settingsOption == GameSettings.Options.STREAM_CHAT_ENABLED)
440
        {
441
            this.streamChatEnabled = (this.streamChatEnabled + value) % 3;
442
        }
443
444
        if (settingsOption == GameSettings.Options.STREAM_CHAT_USER_FILTER)
445
        {
446
            this.streamChatUserFilter = (this.streamChatUserFilter + value) % 3;
447
        }
448
449
        if (settingsOption == GameSettings.Options.STREAM_MIC_TOGGLE_BEHAVIOR)
450
        {
451
            this.streamMicToggleBehavior = (this.streamMicToggleBehavior + value) % 2;
452
        }
453
454
        if (settingsOption == GameSettings.Options.CHAT_COLOR)
455
        {
456
            this.chatColours = !this.chatColours;
457
        }
458
459
        if (settingsOption == GameSettings.Options.CHAT_LINKS)
460
        {
461
            this.chatLinks = !this.chatLinks;
462
        }
463
464
        if (settingsOption == GameSettings.Options.CHAT_LINKS_PROMPT)
465
        {
466
            this.chatLinksPrompt = !this.chatLinksPrompt;
467
        }
468
469
        if (settingsOption == GameSettings.Options.SNOOPER_ENABLED)
470
        {
471
            this.snooperEnabled = !this.snooperEnabled;
472
        }
473
474
        if (settingsOption == GameSettings.Options.TOUCHSCREEN)
475
        {
476
            this.touchscreen = !this.touchscreen;
477
        }
478
479
        if (settingsOption == GameSettings.Options.USE_FULLSCREEN)
480
        {
481
            this.fullScreen = !this.fullScreen;
482
483
            if (this.mc.isFullScreen() != this.fullScreen)
484
            {
485
                this.mc.toggleFullscreen();
486
            }
487
        }
488
489
        if (settingsOption == GameSettings.Options.ENABLE_VSYNC)
490
        {
491
            this.enableVsync = !this.enableVsync;
492
            Display.setVSyncEnabled(this.enableVsync);
493
        }
494
495
        if (settingsOption == GameSettings.Options.USE_VBO)
496
        {
497
            this.useVbo = !this.useVbo;
498
            this.mc.renderGlobal.loadRenderers();
499
        }
500
501
        if (settingsOption == GameSettings.Options.BLOCK_ALTERNATIVES)
502
        {
503
            this.allowBlockAlternatives = !this.allowBlockAlternatives;
504
            this.mc.renderGlobal.loadRenderers();
505
        }
506
507
        if (settingsOption == GameSettings.Options.REDUCED_DEBUG_INFO)
508
        {
509
            this.reducedDebugInfo = !this.reducedDebugInfo;
510
        }
511
512
        if (settingsOption == GameSettings.Options.ENTITY_SHADOWS)
513
        {
514
            this.entityShadows = !this.entityShadows;
515
        }
516
517
        if (settingsOption == GameSettings.Options.REALMS_NOTIFICATIONS)
518
        {
519
            this.realmsNotifications = !this.realmsNotifications;
520
        }
521
522
        this.saveOptions();
523
    }
524
525
    public float getOptionFloatValue(GameSettings.Options settingOption)
526
    {
527
        return settingOption == GameSettings.Options.FOV ? this.fovSetting : (settingOption == GameSettings.Options.GAMMA ? this.gammaSetting : (settingOption == GameSettings.Options.SATURATION ? this.saturation : (settingOption == GameSettings.Options.SENSITIVITY ? this.mouseSensitivity : (settingOption == GameSettings.Options.CHAT_OPACITY ? this.chatOpacity : (settingOption == GameSettings.Options.CHAT_HEIGHT_FOCUSED ? this.chatHeightFocused : (settingOption == GameSettings.Options.CHAT_HEIGHT_UNFOCUSED ? this.chatHeightUnfocused : (settingOption == GameSettings.Options.CHAT_SCALE ? this.chatScale : (settingOption == GameSettings.Options.CHAT_WIDTH ? this.chatWidth : (settingOption == GameSettings.Options.FRAMERATE_LIMIT ? (float)this.limitFramerate : (settingOption == GameSettings.Options.MIPMAP_LEVELS ? (float)this.mipmapLevels : (settingOption == GameSettings.Options.RENDER_DISTANCE ? (float)this.renderDistanceChunks : (settingOption == GameSettings.Options.STREAM_BYTES_PER_PIXEL ? this.streamBytesPerPixel : (settingOption == GameSettings.Options.STREAM_VOLUME_MIC ? this.streamMicVolume : (settingOption == GameSettings.Options.STREAM_VOLUME_SYSTEM ? this.streamGameVolume : (settingOption == GameSettings.Options.STREAM_KBPS ? this.streamKbps : (settingOption == GameSettings.Options.STREAM_FPS ? this.streamFps : 0.0F))))))))))))))));
528
    }
529
530
    public boolean getOptionOrdinalValue(GameSettings.Options settingOption)
531
    {
532
        switch (settingOption)
533
        {
534
            case INVERT_MOUSE:
535
                return this.invertMouse;
536
537
            case VIEW_BOBBING:
538
                return this.viewBobbing;
539
540
            case ANAGLYPH:
541
                return this.anaglyph;
542
543
            case FBO_ENABLE:
544
                return this.fboEnable;
545
546
            case CHAT_COLOR:
547
                return this.chatColours;
548
549
            case CHAT_LINKS:
550
                return this.chatLinks;
551
552
            case CHAT_LINKS_PROMPT:
553
                return this.chatLinksPrompt;
554
555
            case SNOOPER_ENABLED:
556
                return this.snooperEnabled;
557
558
            case USE_FULLSCREEN:
559
                return this.fullScreen;
560
561
            case ENABLE_VSYNC:
562
                return this.enableVsync;
563
564
            case USE_VBO:
565
                return this.useVbo;
566
567
            case TOUCHSCREEN:
568
                return this.touchscreen;
569
570
            case STREAM_SEND_METADATA:
571
                return this.streamSendMetadata;
572
573
            case FORCE_UNICODE_FONT:
574
                return this.forceUnicodeFont;
575
576
            case BLOCK_ALTERNATIVES:
577
                return this.allowBlockAlternatives;
578
579
            case REDUCED_DEBUG_INFO:
580
                return this.reducedDebugInfo;
581
582
            case ENTITY_SHADOWS:
583
                return this.entityShadows;
584
585
            case REALMS_NOTIFICATIONS:
586
                return this.realmsNotifications;
587
588
            default:
589
                return false;
590
        }
591
    }
592
593
    /**
594
     * Returns the translation of the given index in the given String array. If the index is smaller than 0 or greater
595
     * than/equal to the length of the String array, it is changed to 0.
596
     *  
597
     * @param strArray The array of string containing the string to translate
598
     * @param index The index in the array of the string to translate
599
     */
600
    private static String getTranslation(String[] strArray, int index)
601
    {
602
        if (index < 0 || index >= strArray.length)
603
        {
604
            index = 0;
605
        }
606
607
        return I18n.format(strArray[index], new Object[0]);
608
    }
609
610
    /**
611
     * Gets a key binding.
612
     *  
613
     * @param settingOption The KeyBinding is generated from this option
614
     */
615
    public String getKeyBinding(GameSettings.Options settingOption)
616
    {
617
        String s = I18n.format(settingOption.getEnumString(), new Object[0]) + ": ";
618
619
        if (settingOption.getEnumFloat())
620
        {
621
            float f1 = this.getOptionFloatValue(settingOption);
622
            float f = settingOption.normalizeValue(f1);
623
            return settingOption == GameSettings.Options.SENSITIVITY ? (f == 0.0F ? s + I18n.format("options.sensitivity.min", new Object[0]) : (f == 1.0F ? s + I18n.format("options.sensitivity.max", new Object[0]) : s + (int)(f * 200.0F) + "%")) : (settingOption == GameSettings.Options.FOV ? (f1 == 70.0F ? s + I18n.format("options.fov.min", new Object[0]) : (f1 == 110.0F ? s + I18n.format("options.fov.max", new Object[0]) : s + (int)f1)) : (settingOption == GameSettings.Options.FRAMERATE_LIMIT ? (f1 == settingOption.valueMax ? s + I18n.format("options.framerateLimit.max", new Object[0]) : s + (int)f1 + " fps") : (settingOption == GameSettings.Options.RENDER_CLOUDS ? (f1 == settingOption.valueMin ? s + I18n.format("options.cloudHeight.min", new Object[0]) : s + ((int)f1 + 128)) : (settingOption == GameSettings.Options.GAMMA ? (f == 0.0F ? s + I18n.format("options.gamma.min", new Object[0]) : (f == 1.0F ? s + I18n.format("options.gamma.max", new Object[0]) : s + "+" + (int)(f * 100.0F) + "%")) : (settingOption == GameSettings.Options.SATURATION ? s + (int)(f * 400.0F) + "%" : (settingOption == GameSettings.Options.CHAT_OPACITY ? s + (int)(f * 90.0F + 10.0F) + "%" : (settingOption == GameSettings.Options.CHAT_HEIGHT_UNFOCUSED ? s + GuiNewChat.calculateChatboxHeight(f) + "px" : (settingOption == GameSettings.Options.CHAT_HEIGHT_FOCUSED ? s + GuiNewChat.calculateChatboxHeight(f) + "px" : (settingOption == GameSettings.Options.CHAT_WIDTH ? s + GuiNewChat.calculateChatboxWidth(f) + "px" : (settingOption == GameSettings.Options.RENDER_DISTANCE ? s + (int)f1 + " chunks" : (settingOption == GameSettings.Options.MIPMAP_LEVELS ? (f1 == 0.0F ? s + I18n.format("options.off", new Object[0]) : s + (int)f1) : (settingOption == GameSettings.Options.STREAM_FPS ? s + TwitchStream.formatStreamFps(f) + " fps" : (settingOption == GameSettings.Options.STREAM_KBPS ? s + TwitchStream.formatStreamKbps(f) + " Kbps" : (settingOption == GameSettings.Options.STREAM_BYTES_PER_PIXEL ? s + String.format("%.3f bpp", new Object[] {Float.valueOf(TwitchStream.formatStreamBps(f))}): (f == 0.0F ? s + I18n.format("options.off", new Object[0]) : s + (int)(f * 100.0F) + "%")))))))))))))));
624
        }
625
        else if (settingOption.getEnumBoolean())
626
        {
627
            boolean flag = this.getOptionOrdinalValue(settingOption);
628
            return flag ? s + I18n.format("options.on", new Object[0]) : s + I18n.format("options.off", new Object[0]);
629
        }
630
        else if (settingOption == GameSettings.Options.GUI_SCALE)
631
        {
632
            return s + getTranslation(GUISCALES, this.guiScale);
633
        }
634
        else if (settingOption == GameSettings.Options.CHAT_VISIBILITY)
635
        {
636
            return s + I18n.format(this.chatVisibility.getResourceKey(), new Object[0]);
637
        }
638
        else if (settingOption == GameSettings.Options.PARTICLES)
639
        {
640
            return s + getTranslation(PARTICLES, this.particleSetting);
641
        }
642
        else if (settingOption == GameSettings.Options.AMBIENT_OCCLUSION)
643
        {
644
            return s + getTranslation(AMBIENT_OCCLUSIONS, this.ambientOcclusion);
645
        }
646
        else if (settingOption == GameSettings.Options.STREAM_COMPRESSION)
647
        {
648
            return s + getTranslation(STREAM_COMPRESSIONS, this.streamCompression);
649
        }
650
        else if (settingOption == GameSettings.Options.STREAM_CHAT_ENABLED)
651
        {
652
            return s + getTranslation(STREAM_CHAT_MODES, this.streamChatEnabled);
653
        }
654
        else if (settingOption == GameSettings.Options.STREAM_CHAT_USER_FILTER)
655
        {
656
            return s + getTranslation(STREAM_CHAT_FILTER_MODES, this.streamChatUserFilter);
657
        }
658
        else if (settingOption == GameSettings.Options.STREAM_MIC_TOGGLE_BEHAVIOR)
659
        {
660
            return s + getTranslation(STREAM_MIC_MODES, this.streamMicToggleBehavior);
661
        }
662
        else if (settingOption == GameSettings.Options.RENDER_CLOUDS)
663
        {
664
            return s + getTranslation(CLOUDS_TYPES, this.clouds);
665
        }
666
        else if (settingOption == GameSettings.Options.GRAPHICS)
667
        {
668
            if (this.fancyGraphics)
669
            {
670
                return s + I18n.format("options.graphics.fancy", new Object[0]);
671
            }
672
            else
673
            {
674
                String s1 = "options.graphics.fast";
675
                return s + I18n.format("options.graphics.fast", new Object[0]);
676
            }
677
        }
678
        else
679
        {
680
            return s;
681
        }
682
    }
683
684
    /**
685
     * Loads the options from the options file. It appears that this has replaced the previous 'loadOptions'
686
     */
687
    public void loadOptions()
688
    {
689
        try
690
        {
691
            if (!this.optionsFile.exists())
692
            {
693
                return;
694
            }
695
696
            BufferedReader bufferedreader = new BufferedReader(new FileReader(this.optionsFile));
697
            String s = "";
698
            this.mapSoundLevels.clear();
699
700
            while ((s = bufferedreader.readLine()) != null)
701
            {
702
                try
703
                {
704
                    String[] astring = s.split(":");
705
706
                    if (astring[0].equals("mouseSensitivity"))
707
                    {
708
                        this.mouseSensitivity = this.parseFloat(astring[1]);
709
                    }
710
711
                    if (astring[0].equals("fov"))
712
                    {
713
                        this.fovSetting = this.parseFloat(astring[1]) * 40.0F + 70.0F;
714
                    }
715
716
                    if (astring[0].equals("gamma"))
717
                    {
718
                        this.gammaSetting = this.parseFloat(astring[1]);
719
                    }
720
721
                    if (astring[0].equals("saturation"))
722
                    {
723
                        this.saturation = this.parseFloat(astring[1]);
724
                    }
725
726
                    if (astring[0].equals("invertYMouse"))
727
                    {
728
                        this.invertMouse = astring[1].equals("true");
729
                    }
730
731
                    if (astring[0].equals("renderDistance"))
732
                    {
733
                        this.renderDistanceChunks = Integer.parseInt(astring[1]);
734
                    }
735
736
                    if (astring[0].equals("guiScale"))
737
                    {
738
                        this.guiScale = Integer.parseInt(astring[1]);
739
                    }
740
741
                    if (astring[0].equals("particles"))
742
                    {
743
                        this.particleSetting = Integer.parseInt(astring[1]);
744
                    }
745
746
                    if (astring[0].equals("bobView"))
747
                    {
748
                        this.viewBobbing = astring[1].equals("true");
749
                    }
750
751
                    if (astring[0].equals("anaglyph3d"))
752
                    {
753
                        this.anaglyph = astring[1].equals("true");
754
                    }
755
756
                    if (astring[0].equals("maxFps"))
757
                    {
758
                        this.limitFramerate = Integer.parseInt(astring[1]);
759
                    }
760
761
                    if (astring[0].equals("fboEnable"))
762
                    {
763
                        this.fboEnable = astring[1].equals("true");
764
                    }
765
766
                    if (astring[0].equals("difficulty"))
767
                    {
768
                        this.difficulty = EnumDifficulty.getDifficultyEnum(Integer.parseInt(astring[1]));
769
                    }
770
771
                    if (astring[0].equals("fancyGraphics"))
772
                    {
773
                        this.fancyGraphics = astring[1].equals("true");
774
                    }
775
776
                    if (astring[0].equals("ao"))
777
                    {
778
                        if (astring[1].equals("true"))
779
                        {
780
                            this.ambientOcclusion = 2;
781
                        }
782
                        else if (astring[1].equals("false"))
783
                        {
784
                            this.ambientOcclusion = 0;
785
                        }
786
                        else
787
                        {
788
                            this.ambientOcclusion = Integer.parseInt(astring[1]);
789
                        }
790
                    }
791
792
                    if (astring[0].equals("renderClouds"))
793
                    {
794
                        if (astring[1].equals("true"))
795
                        {
796
                            this.clouds = 2;
797
                        }
798
                        else if (astring[1].equals("false"))
799
                        {
800
                            this.clouds = 0;
801
                        }
802
                        else if (astring[1].equals("fast"))
803
                        {
804
                            this.clouds = 1;
805
                        }
806
                    }
807
808
                    if (astring[0].equals("resourcePacks"))
809
                    {
810
                        this.resourcePacks = (List)gson.fromJson((String)s.substring(s.indexOf(58) + 1), typeListString);
811
812
                        if (this.resourcePacks == null)
813
                        {
814
                            this.resourcePacks = Lists.<String>newArrayList();
815
                        }
816
                    }
817
818
                    if (astring[0].equals("incompatibleResourcePacks"))
819
                    {
820
                        this.incompatibleResourcePacks = (List)gson.fromJson((String)s.substring(s.indexOf(58) + 1), typeListString);
821
822
                        if (this.incompatibleResourcePacks == null)
823
                        {
824
                            this.incompatibleResourcePacks = Lists.<String>newArrayList();
825
                        }
826
                    }
827
828
                    if (astring[0].equals("lastServer") && astring.length >= 2)
829
                    {
830
                        this.lastServer = s.substring(s.indexOf(58) + 1);
831
                    }
832
833
                    if (astring[0].equals("lang") && astring.length >= 2)
834
                    {
835
                        this.language = astring[1];
836
                    }
837
838
                    if (astring[0].equals("chatVisibility"))
839
                    {
840
                        this.chatVisibility = EntityPlayer.EnumChatVisibility.getEnumChatVisibility(Integer.parseInt(astring[1]));
841
                    }
842
843
                    if (astring[0].equals("chatColors"))
844
                    {
845
                        this.chatColours = astring[1].equals("true");
846
                    }
847
848
                    if (astring[0].equals("chatLinks"))
849
                    {
850
                        this.chatLinks = astring[1].equals("true");
851
                    }
852
853
                    if (astring[0].equals("chatLinksPrompt"))
854
                    {
855
                        this.chatLinksPrompt = astring[1].equals("true");
856
                    }
857
858
                    if (astring[0].equals("chatOpacity"))
859
                    {
860
                        this.chatOpacity = this.parseFloat(astring[1]);
861
                    }
862
863
                    if (astring[0].equals("snooperEnabled"))
864
                    {
865
                        this.snooperEnabled = astring[1].equals("true");
866
                    }
867
868
                    if (astring[0].equals("fullscreen"))
869
                    {
870
                        this.fullScreen = astring[1].equals("true");
871
                    }
872
873
                    if (astring[0].equals("enableVsync"))
874
                    {
875
                        this.enableVsync = astring[1].equals("true");
876
                    }
877
878
                    if (astring[0].equals("useVbo"))
879
                    {
880
                        this.useVbo = astring[1].equals("true");
881
                    }
882
883
                    if (astring[0].equals("hideServerAddress"))
884
                    {
885
                        this.hideServerAddress = astring[1].equals("true");
886
                    }
887
888
                    if (astring[0].equals("advancedItemTooltips"))
889
                    {
890
                        this.advancedItemTooltips = astring[1].equals("true");
891
                    }
892
893
                    if (astring[0].equals("pauseOnLostFocus"))
894
                    {
895
                        this.pauseOnLostFocus = astring[1].equals("true");
896
                    }
897
898
                    if (astring[0].equals("touchscreen"))
899
                    {
900
                        this.touchscreen = astring[1].equals("true");
901
                    }
902
903
                    if (astring[0].equals("overrideHeight"))
904
                    {
905
                        this.overrideHeight = Integer.parseInt(astring[1]);
906
                    }
907
908
                    if (astring[0].equals("overrideWidth"))
909
                    {
910
                        this.overrideWidth = Integer.parseInt(astring[1]);
911
                    }
912
913
                    if (astring[0].equals("heldItemTooltips"))
914
                    {
915
                        this.heldItemTooltips = astring[1].equals("true");
916
                    }
917
918
                    if (astring[0].equals("chatHeightFocused"))
919
                    {
920
                        this.chatHeightFocused = this.parseFloat(astring[1]);
921
                    }
922
923
                    if (astring[0].equals("chatHeightUnfocused"))
924
                    {
925
                        this.chatHeightUnfocused = this.parseFloat(astring[1]);
926
                    }
927
928
                    if (astring[0].equals("chatScale"))
929
                    {
930
                        this.chatScale = this.parseFloat(astring[1]);
931
                    }
932
933
                    if (astring[0].equals("chatWidth"))
934
                    {
935
                        this.chatWidth = this.parseFloat(astring[1]);
936
                    }
937
938
                    if (astring[0].equals("showInventoryAchievementHint"))
939
                    {
940
                        this.showInventoryAchievementHint = astring[1].equals("true");
941
                    }
942
943
                    if (astring[0].equals("mipmapLevels"))
944
                    {
945
                        this.mipmapLevels = Integer.parseInt(astring[1]);
946
                    }
947
948
                    if (astring[0].equals("streamBytesPerPixel"))
949
                    {
950
                        this.streamBytesPerPixel = this.parseFloat(astring[1]);
951
                    }
952
953
                    if (astring[0].equals("streamMicVolume"))
954
                    {
955
                        this.streamMicVolume = this.parseFloat(astring[1]);
956
                    }
957
958
                    if (astring[0].equals("streamSystemVolume"))
959
                    {
960
                        this.streamGameVolume = this.parseFloat(astring[1]);
961
                    }
962
963
                    if (astring[0].equals("streamKbps"))
964
                    {
965
                        this.streamKbps = this.parseFloat(astring[1]);
966
                    }
967
968
                    if (astring[0].equals("streamFps"))
969
                    {
970
                        this.streamFps = this.parseFloat(astring[1]);
971
                    }
972
973
                    if (astring[0].equals("streamCompression"))
974
                    {
975
                        this.streamCompression = Integer.parseInt(astring[1]);
976
                    }
977
978
                    if (astring[0].equals("streamSendMetadata"))
979
                    {
980
                        this.streamSendMetadata = astring[1].equals("true");
981
                    }
982
983
                    if (astring[0].equals("streamPreferredServer") && astring.length >= 2)
984
                    {
985
                        this.streamPreferredServer = s.substring(s.indexOf(58) + 1);
986
                    }
987
988
                    if (astring[0].equals("streamChatEnabled"))
989
                    {
990
                        this.streamChatEnabled = Integer.parseInt(astring[1]);
991
                    }
992
993
                    if (astring[0].equals("streamChatUserFilter"))
994
                    {
995
                        this.streamChatUserFilter = Integer.parseInt(astring[1]);
996
                    }
997
998
                    if (astring[0].equals("streamMicToggleBehavior"))
999
                    {
1000
                        this.streamMicToggleBehavior = Integer.parseInt(astring[1]);
1001
                    }
1002
1003
                    if (astring[0].equals("forceUnicodeFont"))
1004
                    {
1005
                        this.forceUnicodeFont = astring[1].equals("true");
1006
                    }
1007
1008
                    if (astring[0].equals("allowBlockAlternatives"))
1009
                    {
1010
                        this.allowBlockAlternatives = astring[1].equals("true");
1011
                    }
1012
1013
                    if (astring[0].equals("reducedDebugInfo"))
1014
                    {
1015
                        this.reducedDebugInfo = astring[1].equals("true");
1016
                    }
1017
1018
                    if (astring[0].equals("useNativeTransport"))
1019
                    {
1020
                        this.useNativeTransport = astring[1].equals("true");
1021
                    }
1022
1023
                    if (astring[0].equals("entityShadows"))
1024
                    {
1025
                        this.entityShadows = astring[1].equals("true");
1026
                    }
1027
1028
                    if (astring[0].equals("realmsNotifications"))
1029
                    {
1030
                        this.realmsNotifications = astring[1].equals("true");
1031
                    }
1032
1033
                    for (KeyBinding keybinding : this.keyBindings)
1034
                    {
1035
                        if (astring[0].equals("key_" + keybinding.getKeyDescription()))
1036
                        {
1037
                            keybinding.setKeyCode(Integer.parseInt(astring[1]));
1038
                        }
1039
                    }
1040
1041
                    for (SoundCategory soundcategory : SoundCategory.values())
1042
                    {
1043
                        if (astring[0].equals("soundCategory_" + soundcategory.getCategoryName()))
1044
                        {
1045
                            this.mapSoundLevels.put(soundcategory, Float.valueOf(this.parseFloat(astring[1])));
1046
                        }
1047
                    }
1048
1049
                    for (EnumPlayerModelParts enumplayermodelparts : EnumPlayerModelParts.values())
1050
                    {
1051
                        if (astring[0].equals("modelPart_" + enumplayermodelparts.getPartName()))
1052
                        {
1053
                            this.setModelPartEnabled(enumplayermodelparts, astring[1].equals("true"));
1054
                        }
1055
                    }
1056
                }
1057
                catch (Exception var8)
1058
                {
1059
                    logger.warn("Skipping bad option: " + s);
1060
                }
1061
            }
1062
1063
            KeyBinding.resetKeyBindingArrayAndHash();
1064
            bufferedreader.close();
1065
        }
1066
        catch (Exception exception)
1067
        {
1068
            logger.error((String)"Failed to load options", (Throwable)exception);
1069
        }
1070
    }
1071
1072
    /**
1073
     * Parses a string into a float.
1074
     *  
1075
     * @param str The string to parse
1076
     */
1077
    private float parseFloat(String str)
1078
    {
1079
        return str.equals("true") ? 1.0F : (str.equals("false") ? 0.0F : Float.parseFloat(str));
1080
    }
1081
1082
    /**
1083
     * Saves the options to the options file.
1084
     */
1085
    public void saveOptions()
1086
    {
1087
        try
1088
        {
1089
            PrintWriter printwriter = new PrintWriter(new FileWriter(this.optionsFile));
1090
            printwriter.println("invertYMouse:" + this.invertMouse);
1091
            printwriter.println("mouseSensitivity:" + this.mouseSensitivity);
1092
            printwriter.println("fov:" + (this.fovSetting - 70.0F) / 40.0F);
1093
            printwriter.println("gamma:" + this.gammaSetting);
1094
            printwriter.println("saturation:" + this.saturation);
1095
            printwriter.println("renderDistance:" + this.renderDistanceChunks);
1096
            printwriter.println("guiScale:" + this.guiScale);
1097
            printwriter.println("particles:" + this.particleSetting);
1098
            printwriter.println("bobView:" + this.viewBobbing);
1099
            printwriter.println("anaglyph3d:" + this.anaglyph);
1100
            printwriter.println("maxFps:" + this.limitFramerate);
1101
            printwriter.println("fboEnable:" + this.fboEnable);
1102
            printwriter.println("difficulty:" + this.difficulty.getDifficultyId());
1103
            printwriter.println("fancyGraphics:" + this.fancyGraphics);
1104
            printwriter.println("ao:" + this.ambientOcclusion);
1105
1106
            switch (this.clouds)
1107
            {
1108
                case 0:
1109
                    printwriter.println("renderClouds:false");
1110
                    break;
1111
1112
                case 1:
1113
                    printwriter.println("renderClouds:fast");
1114
                    break;
1115
1116
                case 2:
1117
                    printwriter.println("renderClouds:true");
1118
            }
1119
1120
            printwriter.println("resourcePacks:" + gson.toJson((Object)this.resourcePacks));
1121
            printwriter.println("incompatibleResourcePacks:" + gson.toJson((Object)this.incompatibleResourcePacks));
1122
            printwriter.println("lastServer:" + this.lastServer);
1123
            printwriter.println("lang:" + this.language);
1124
            printwriter.println("chatVisibility:" + this.chatVisibility.getChatVisibility());
1125
            printwriter.println("chatColors:" + this.chatColours);
1126
            printwriter.println("chatLinks:" + this.chatLinks);
1127
            printwriter.println("chatLinksPrompt:" + this.chatLinksPrompt);
1128
            printwriter.println("chatOpacity:" + this.chatOpacity);
1129
            printwriter.println("snooperEnabled:" + this.snooperEnabled);
1130
            printwriter.println("fullscreen:" + this.fullScreen);
1131
            printwriter.println("enableVsync:" + this.enableVsync);
1132
            printwriter.println("useVbo:" + this.useVbo);
1133
            printwriter.println("hideServerAddress:" + this.hideServerAddress);
1134
            printwriter.println("advancedItemTooltips:" + this.advancedItemTooltips);
1135
            printwriter.println("pauseOnLostFocus:" + this.pauseOnLostFocus);
1136
            printwriter.println("touchscreen:" + this.touchscreen);
1137
            printwriter.println("overrideWidth:" + this.overrideWidth);
1138
            printwriter.println("overrideHeight:" + this.overrideHeight);
1139
            printwriter.println("heldItemTooltips:" + this.heldItemTooltips);
1140
            printwriter.println("chatHeightFocused:" + this.chatHeightFocused);
1141
            printwriter.println("chatHeightUnfocused:" + this.chatHeightUnfocused);
1142
            printwriter.println("chatScale:" + this.chatScale);
1143
            printwriter.println("chatWidth:" + this.chatWidth);
1144
            printwriter.println("showInventoryAchievementHint:" + this.showInventoryAchievementHint);
1145
            printwriter.println("mipmapLevels:" + this.mipmapLevels);
1146
            printwriter.println("streamBytesPerPixel:" + this.streamBytesPerPixel);
1147
            printwriter.println("streamMicVolume:" + this.streamMicVolume);
1148
            printwriter.println("streamSystemVolume:" + this.streamGameVolume);
1149
            printwriter.println("streamKbps:" + this.streamKbps);
1150
            printwriter.println("streamFps:" + this.streamFps);
1151
            printwriter.println("streamCompression:" + this.streamCompression);
1152
            printwriter.println("streamSendMetadata:" + this.streamSendMetadata);
1153
            printwriter.println("streamPreferredServer:" + this.streamPreferredServer);
1154
            printwriter.println("streamChatEnabled:" + this.streamChatEnabled);
1155
            printwriter.println("streamChatUserFilter:" + this.streamChatUserFilter);
1156
            printwriter.println("streamMicToggleBehavior:" + this.streamMicToggleBehavior);
1157
            printwriter.println("forceUnicodeFont:" + this.forceUnicodeFont);
1158
            printwriter.println("allowBlockAlternatives:" + this.allowBlockAlternatives);
1159
            printwriter.println("reducedDebugInfo:" + this.reducedDebugInfo);
1160
            printwriter.println("useNativeTransport:" + this.useNativeTransport);
1161
            printwriter.println("entityShadows:" + this.entityShadows);
1162
            printwriter.println("realmsNotifications:" + this.realmsNotifications);
1163
1164
            for (KeyBinding keybinding : this.keyBindings)
1165
            {
1166
                printwriter.println("key_" + keybinding.getKeyDescription() + ":" + keybinding.getKeyCode());
1167
            }
1168
1169
            for (SoundCategory soundcategory : SoundCategory.values())
1170
            {
1171
                printwriter.println("soundCategory_" + soundcategory.getCategoryName() + ":" + this.getSoundLevel(soundcategory));
1172
            }
1173
1174
            for (EnumPlayerModelParts enumplayermodelparts : EnumPlayerModelParts.values())
1175
            {
1176
                printwriter.println("modelPart_" + enumplayermodelparts.getPartName() + ":" + this.setModelParts.contains(enumplayermodelparts));
1177
            }
1178
1179
            printwriter.close();
1180
        }
1181
        catch (Exception exception)
1182
        {
1183
            logger.error((String)"Failed to save options", (Throwable)exception);
1184
        }
1185
1186
        this.sendSettingsToServer();
1187
    }
1188
1189
    public float getSoundLevel(SoundCategory sndCategory)
1190
    {
1191
        return this.mapSoundLevels.containsKey(sndCategory) ? ((Float)this.mapSoundLevels.get(sndCategory)).floatValue() : 1.0F;
1192
    }
1193
1194
    public void setSoundLevel(SoundCategory sndCategory, float soundLevel)
1195
    {
1196
        this.mc.getSoundHandler().setSoundLevel(sndCategory, soundLevel);
1197
        this.mapSoundLevels.put(sndCategory, Float.valueOf(soundLevel));
1198
    }
1199
1200
    /**
1201
     * Send a client info packet with settings information to the server
1202
     */
1203
    public void sendSettingsToServer()
1204
    {
1205
        if (this.mc.thePlayer != null)
1206
        {
1207
            int i = 0;
1208
1209
            for (EnumPlayerModelParts enumplayermodelparts : this.setModelParts)
1210
            {
1211
                i |= enumplayermodelparts.getPartMask();
1212
            }
1213
1214
            this.mc.thePlayer.sendQueue.addToSendQueue(new C15PacketClientSettings(this.language, this.renderDistanceChunks, this.chatVisibility, this.chatColours, i));
1215
        }
1216
    }
1217
1218
    public Set<EnumPlayerModelParts> getModelParts()
1219
    {
1220
        return ImmutableSet.copyOf(this.setModelParts);
1221
    }
1222
1223
    public void setModelPartEnabled(EnumPlayerModelParts modelPart, boolean enable)
1224
    {
1225
        if (enable)
1226
        {
1227
            this.setModelParts.add(modelPart);
1228
        }
1229
        else
1230
        {
1231
            this.setModelParts.remove(modelPart);
1232
        }
1233
1234
        this.sendSettingsToServer();
1235
    }
1236
1237
    public void switchModelPartEnabled(EnumPlayerModelParts modelPart)
1238
    {
1239
        if (!this.getModelParts().contains(modelPart))
1240
        {
1241
            this.setModelParts.add(modelPart);
1242
        }
1243
        else
1244
        {
1245
            this.setModelParts.remove(modelPart);
1246
        }
1247
1248
        this.sendSettingsToServer();
1249
    }
1250
1251
    /**
1252
     * Return true if the clouds should be rendered
1253
     */
1254
    public int shouldRenderClouds()
1255
    {
1256
        return this.renderDistanceChunks >= 4 ? this.clouds : 0;
1257
    }
1258
1259
    /**
1260
     * Return true if the client connect to a server using the native transport system
1261
     */
1262
    public boolean isUsingNativeTransport()
1263
    {
1264
        return this.useNativeTransport;
1265
    }
1266
1267
    public static enum Options
1268
    {
1269
        INVERT_MOUSE("options.invertMouse", false, true),
1270
        SENSITIVITY("options.sensitivity", true, false),
1271
        FOV("options.fov", true, false, 30.0F, 110.0F, 1.0F),
1272
        GAMMA("options.gamma", true, false),
1273
        SATURATION("options.saturation", true, false),
1274
        RENDER_DISTANCE("options.renderDistance", true, false, 2.0F, 16.0F, 1.0F),
1275
        VIEW_BOBBING("options.viewBobbing", false, true),
1276
        ANAGLYPH("options.anaglyph", false, true),
1277
        FRAMERATE_LIMIT("options.framerateLimit", true, false, 10.0F, 260.0F, 10.0F),
1278
        FBO_ENABLE("options.fboEnable", false, true),
1279
        RENDER_CLOUDS("options.renderClouds", false, false),
1280
        GRAPHICS("options.graphics", false, false),
1281
        AMBIENT_OCCLUSION("options.ao", false, false),
1282
        GUI_SCALE("options.guiScale", false, false),
1283
        PARTICLES("options.particles", false, false),
1284
        CHAT_VISIBILITY("options.chat.visibility", false, false),
1285
        CHAT_COLOR("options.chat.color", false, true),
1286
        CHAT_LINKS("options.chat.links", false, true),
1287
        CHAT_OPACITY("options.chat.opacity", true, false),
1288
        CHAT_LINKS_PROMPT("options.chat.links.prompt", false, true),
1289
        SNOOPER_ENABLED("options.snooper", false, true),
1290
        USE_FULLSCREEN("options.fullscreen", false, true),
1291
        ENABLE_VSYNC("options.vsync", false, true),
1292
        USE_VBO("options.vbo", false, true),
1293
        TOUCHSCREEN("options.touchscreen", false, true),
1294
        CHAT_SCALE("options.chat.scale", true, false),
1295
        CHAT_WIDTH("options.chat.width", true, false),
1296
        CHAT_HEIGHT_FOCUSED("options.chat.height.focused", true, false),
1297
        CHAT_HEIGHT_UNFOCUSED("options.chat.height.unfocused", true, false),
1298
        MIPMAP_LEVELS("options.mipmapLevels", true, false, 0.0F, 4.0F, 1.0F),
1299
        FORCE_UNICODE_FONT("options.forceUnicodeFont", false, true),
1300
        STREAM_BYTES_PER_PIXEL("options.stream.bytesPerPixel", true, false),
1301
        STREAM_VOLUME_MIC("options.stream.micVolumne", true, false),
1302
        STREAM_VOLUME_SYSTEM("options.stream.systemVolume", true, false),
1303
        STREAM_KBPS("options.stream.kbps", true, false),
1304
        STREAM_FPS("options.stream.fps", true, false),
1305
        STREAM_COMPRESSION("options.stream.compression", false, false),
1306
        STREAM_SEND_METADATA("options.stream.sendMetadata", false, true),
1307
        STREAM_CHAT_ENABLED("options.stream.chat.enabled", false, false),
1308
        STREAM_CHAT_USER_FILTER("options.stream.chat.userFilter", false, false),
1309
        STREAM_MIC_TOGGLE_BEHAVIOR("options.stream.micToggleBehavior", false, false),
1310
        BLOCK_ALTERNATIVES("options.blockAlternatives", false, true),
1311
        REDUCED_DEBUG_INFO("options.reducedDebugInfo", false, true),
1312
        ENTITY_SHADOWS("options.entityShadows", false, true),
1313
        REALMS_NOTIFICATIONS("options.realmsNotifications", false, true);
1314
1315
        private final boolean enumFloat;
1316
        private final boolean enumBoolean;
1317
        private final String enumString;
1318
        private final float valueStep;
1319
        private float valueMin;
1320
        private float valueMax;
1321
1322
        public static GameSettings.Options getEnumOptions(int ordinal)
1323
        {
1324
            for (GameSettings.Options gamesettings$options : values())
1325
            {
1326
                if (gamesettings$options.returnEnumOrdinal() == ordinal)
1327
                {
1328
                    return gamesettings$options;
1329
                }
1330
            }
1331
1332
            return null;
1333
        }
1334
1335
        private Options(String str, boolean isFloat, boolean isBoolean)
1336
        {
1337
            this(str, isFloat, isBoolean, 0.0F, 1.0F, 0.0F);
1338
        }
1339
1340
        private Options(String str, boolean isFloat, boolean isBoolean, float valMin, float valMax, float valStep)
1341
        {
1342
            this.enumString = str;
1343
            this.enumFloat = isFloat;
1344
            this.enumBoolean = isBoolean;
1345
            this.valueMin = valMin;
1346
            this.valueMax = valMax;
1347
            this.valueStep = valStep;
1348
        }
1349
1350
        public boolean getEnumFloat()
1351
        {
1352
            return this.enumFloat;
1353
        }
1354
1355
        public boolean getEnumBoolean()
1356
        {
1357
            return this.enumBoolean;
1358
        }
1359
1360
        public int returnEnumOrdinal()
1361
        {
1362
            return this.ordinal();
1363
        }
1364
1365
        public String getEnumString()
1366
        {
1367
            return this.enumString;
1368
        }
1369
1370
        public float getValueMax()
1371
        {
1372
            return this.valueMax;
1373
        }
1374
1375
        public void setValueMax(float value)
1376
        {
1377
            this.valueMax = value;
1378
        }
1379
1380
        public float normalizeValue(float value)
1381
        {
1382
            return MathHelper.clamp_float((this.snapToStepClamp(value) - this.valueMin) / (this.valueMax - this.valueMin), 0.0F, 1.0F);
1383
        }
1384
1385
        public float denormalizeValue(float value)
1386
        {
1387
            return this.snapToStepClamp(this.valueMin + (this.valueMax - this.valueMin) * MathHelper.clamp_float(value, 0.0F, 1.0F));
1388
        }
1389
1390
        public float snapToStepClamp(float value)
1391
        {
1392
            value = this.snapToStep(value);
1393
            return MathHelper.clamp_float(value, this.valueMin, this.valueMax);
1394
        }
1395
1396
        protected float snapToStep(float value)
1397
        {
1398
            if (this.valueStep > 0.0F)
1399
            {
1400
                value = this.valueStep * (float)Math.round(value / this.valueStep);
1401
            }
1402
1403
            return value;
1404
        }
1405
    }
1406
}
1407

Deobfuscated MCP 1.8.9 source of GameSettings from Marcelektro/MavenMCP-1.8.9 (net/minecraft/client/settings/GameSettings.java), stored verbatim.